[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
add `read-buffer-completion-ignore-case' ?
From: |
John Paul Wallington |
Subject: |
add `read-buffer-completion-ignore-case' ? |
Date: |
Sun, 08 Jun 2008 22:28:30 +0100 |
User-agent: |
Microsoft Gnus Express, Build 513.230 |
Is it okay to install the following change?
It adds a customizable variable, `read-buffer-completion-ignore-case',
that specifies the case-sensitivity of completion for `read-buffer'.
Its default value is nil, meaning that `read-buffer' is case-sensitive
when completing buffer names.
2008-06-08 John Paul Wallington <address@hidden>
* minibuf.c (read_buffer_completion_ignore_case): New variable.
(syms_of_minibuf): Declare and initialise it.
(Fread_buffer): Bind `completion-ignore-case' to respect it.
Mention it and `read-buffer-function' in docstring.
--- minibuf.c.~1.353.~ 2008-06-05 20:28:48.000000000 +0100
+++ minibuf.c 2008-06-08 22:10:01.000000000 +0100
@@ -109,6 +109,9 @@
/* Function to call to read a buffer name. */
Lisp_Object Vread_buffer_function;
+/* Nonzero means completion ignores case when reading buffer name. */
+int read_buffer_completion_ignore_case;
+
/* Nonzero means completion ignores case. */
int completion_ignore_case;
@@ -1178,7 +1181,9 @@
If DEF is a list of default values, return its first element.
If optional third arg REQUIRE-MATCH is non-nil,
only existing buffer names are allowed.
-The argument PROMPT should be a string ending with a colon and a space. */)
+The argument PROMPT should be a string ending with a colon and a space.
+
+See also `read-buffer-completion-ignore-case' and `read-buffer-function'. */)
(prompt, def, require_match)
Lisp_Object prompt, def, require_match;
{
@@ -1189,47 +1194,54 @@
if (BUFFERP (def))
def = XBUFFER (def)->name;
- if (NILP (Vread_buffer_function))
- {
- if (!NILP (def))
- {
- /* A default value was provided: we must change PROMPT,
- editing the default value in before the colon. To achieve
- this, we replace PROMPT with a substring that doesn't
- contain the terminal space and colon (if present). They
- are then added back using Fformat. */
+ {
+ int count = SPECPDL_INDEX ();
+
+ specbind (Qcompletion_ignore_case,
+ read_buffer_completion_ignore_case ? Qt : Qnil);
- if (STRINGP (prompt))
- {
- s = SDATA (prompt);
- len = strlen (s);
- if (len >= 2 && s[len - 2] == ':' && s[len - 1] == ' ')
- len = len - 2;
- else if (len >= 1 && (s[len - 1] == ':' || s[len - 1] == ' '))
- len--;
+ if (NILP (Vread_buffer_function))
+ {
+ if (!NILP (def))
+ {
+ /* A default value was provided: we must change PROMPT,
+ editing the default value in before the colon. To achieve
+ this, we replace PROMPT with a substring that doesn't
+ contain the terminal space and colon (if present). They
+ are then added back using Fformat. */
- prompt = make_specified_string (s, -1, len,
- STRING_MULTIBYTE (prompt));
- }
+ if (STRINGP (prompt))
+ {
+ s = SDATA (prompt);
+ len = strlen (s);
+ if (len >= 2 && s[len - 2] == ':' && s[len - 1] == ' ')
+ len = len - 2;
+ else if (len >= 1 && (s[len - 1] == ':' || s[len - 1] == ' '))
+ len--;
- args[0] = build_string ("%s (default %s): ");
- args[1] = prompt;
- args[2] = CONSP (def) ? XCAR (def) : def;
- prompt = Fformat (3, args);
- }
+ prompt = make_specified_string (s, -1, len,
+ STRING_MULTIBYTE (prompt));
+ }
- return Fcompleting_read (prompt, intern ("internal-complete-buffer"),
- Qnil, require_match, Qnil, Qbuffer_name_history,
- def, Qnil);
- }
- else
- {
- args[0] = Vread_buffer_function;
- args[1] = prompt;
- args[2] = def;
- args[3] = require_match;
- return Ffuncall(4, args);
- }
+ args[0] = build_string ("%s (default %s): ");
+ args[1] = prompt;
+ args[2] = CONSP (def) ? XCAR (def) : def;
+ prompt = Fformat (3, args);
+ }
+
+ return Fcompleting_read (prompt, intern ("internal-complete-buffer"),
+ Qnil, require_match, Qnil,
Qbuffer_name_history,
+ def, Qnil);
+ }
+ else
+ {
+ args[0] = Vread_buffer_function;
+ args[1] = prompt;
+ args[2] = def;
+ args[3] = require_match;
+ return Ffuncall(4, args);
+ }
+ }
}
static Lisp_Object
@@ -2117,6 +2129,10 @@
doc: /* If this is non-nil, `read-buffer' does its work by
calling this function. */);
Vread_buffer_function = Qnil;
+ DEFVAR_BOOL ("read-buffer-completion-ignore-case",
&read_buffer_completion_ignore_case,
+ doc: /* *Non-nil means when reading a buffer name completion
ignores case. */);
+ read_buffer_completion_ignore_case = 0;
+
DEFVAR_LISP ("minibuffer-setup-hook", &Vminibuffer_setup_hook,
doc: /* Normal hook run just after entry to minibuffer. */);
Vminibuffer_setup_hook = Qnil;
2008-06-08 John Paul Wallington <address@hidden>
* cus-start.el (read-buffer-completion-ignore-case): Add.
--- cus-start.el.~1.123.~ 2008-06-05 20:28:43.000000000 +0100
+++ cus-start.el 2008-06-08 22:17:50.000000000 +0100
@@ -275,6 +275,7 @@
(choice (const nil)
(function-item iswitchb-read-buffer)
function))
+ (read-buffer-completion-ignore-case minibuffer boolean "23.1")
;; msdos.c
(dos-unsupported-char-glyph display integer)
;; process.c
- add `read-buffer-completion-ignore-case' ?,
John Paul Wallington <=