unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* add `read-buffer-completion-ignore-case' ?
@ 2008-06-08 21:28 John Paul Wallington
  2008-06-08 22:46 ` Drew Adams
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: John Paul Wallington @ 2008-06-08 21:28 UTC (permalink / raw)
  To: emacs-devel

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




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-06-10  2:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-08 21:28 add `read-buffer-completion-ignore-case' ? John Paul Wallington
2008-06-08 22:46 ` 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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).