From: jpw@pobox.com (John Paul Wallington)
To: emacs-devel@gnu.org
Subject: add `read-buffer-completion-ignore-case' ?
Date: Sun, 08 Jun 2008 22:28:30 +0100 [thread overview]
Message-ID: <m13anny5tt.fsf@pobox.com> (raw)
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 <jpw@pobox.com>
* 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);
+ }
+ }
}
\f
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 <jpw@pobox.com>
* 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
next reply other threads:[~2008-06-08 21:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-08 21:28 John Paul Wallington [this message]
2008-06-08 22:46 ` add `read-buffer-completion-ignore-case' ? Drew Adams
2008-06-08 22:51 ` doc strings for read-*-completion-ignore-case [was: add `read-buffer-completion-ignore-case' ?] Drew Adams
2008-06-09 1:53 ` add `read-buffer-completion-ignore-case' ? Stefan Monnier
2008-06-09 2:59 ` Miles Bader
2008-06-09 6:45 ` Drew Adams
2008-06-09 8:45 ` Eli Zaretskii
2008-06-09 9:09 ` David Kastrup
2008-06-09 9:10 ` Juanma Barranquero
2008-06-10 1:15 ` Stefan Monnier
2008-06-10 1:26 ` Miles Bader
2008-06-10 2:41 ` Stefan Monnier
2008-06-09 12:10 ` John Paul Wallington
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m13anny5tt.fsf@pobox.com \
--to=jpw@pobox.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.