emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: add `read-buffer-completion-ignore-case' ?


From: John Paul Wallington
Subject: Re: add `read-buffer-completion-ignore-case' ?
Date: Mon, 09 Jun 2008 13:10:55 +0100
User-agent: Microsoft Gnus Express, Build 513.230

I wrote:

> 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
[...]

Doh.  That patch didn't work, 'cos I forgot to unbind_to at the end.
Here's a revised one:

--- minibuf.c.~1.353.~  2008-06-05 20:28:48.000000000 +0100
+++ minibuf.c   2008-06-09 12:57:35.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,17 +1181,25 @@
  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;
 {
   Lisp_Object args[4];
+  Lisp_Object tem;
   unsigned char *s;
   int len;
+  int count = SPECPDL_INDEX ();
+    
 
   if (BUFFERP (def))
     def = XBUFFER (def)->name;
-
+  
+  specbind (Qcompletion_ignore_case,
+           read_buffer_completion_ignore_case ? Qt : Qnil);
+  
   if (NILP (Vread_buffer_function))
     {
       if (!NILP (def))
@@ -1218,9 +1229,9 @@
          prompt = Fformat (3, args);
        }
 
-      return Fcompleting_read (prompt, intern ("internal-complete-buffer"),
-                              Qnil, require_match, Qnil, Qbuffer_name_history,
-                              def, Qnil);
+      tem = Fcompleting_read (prompt, intern ("internal-complete-buffer"),
+                             Qnil, require_match, Qnil, Qbuffer_name_history,
+                             def, Qnil);
     }
   else
     {
@@ -1228,8 +1239,9 @@
       args[1] = prompt;
       args[2] = def;
       args[3] = require_match;
-      return Ffuncall(4, args);
+      tem = Ffuncall(4, args);
     }
+  return unbind_to (count, tem);
 }
 
 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;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]