comparison src/minibuf.c @ 97121:dd58348427b8

(read_buffer_completion_ignore_case): New var. (Fread_buffer): Use it.
author Chong Yidong <cyd@stupidchicken.com>
date Wed, 30 Jul 2008 15:26:31 +0000
parents a17231a1f8f8
children be7f6252008c
comparison
equal deleted inserted replaced
97120:d3b0c34318bb 97121:dd58348427b8
111 111
112 /* Nonzero means completion ignores case. */ 112 /* Nonzero means completion ignores case. */
113 113
114 int completion_ignore_case; 114 int completion_ignore_case;
115 Lisp_Object Qcompletion_ignore_case; 115 Lisp_Object Qcompletion_ignore_case;
116 int read_buffer_completion_ignore_case;
116 117
117 /* List of regexps that should restrict possible completions. */ 118 /* List of regexps that should restrict possible completions. */
118 119
119 Lisp_Object Vcompletion_regexp_list; 120 Lisp_Object Vcompletion_regexp_list;
120 121
1176 Prompt with PROMPT. 1177 Prompt with PROMPT.
1177 Optional second arg DEF is value to return if user enters an empty line. 1178 Optional second arg DEF is value to return if user enters an empty line.
1178 If DEF is a list of default values, return its first element. 1179 If DEF is a list of default values, return its first element.
1179 If optional third arg REQUIRE-MATCH is non-nil, 1180 If optional third arg REQUIRE-MATCH is non-nil,
1180 only existing buffer names are allowed. 1181 only existing buffer names are allowed.
1181 The argument PROMPT should be a string ending with a colon and a space. */) 1182 The argument PROMPT should be a string ending with a colon and a space.
1183 If `read-buffer-completion-ignore-case' is non-nil, completion ignores
1184 case while reading the buffer name.
1185 If `read-buffer-function' is non-nil, this works by calling it as a
1186 function, instead of the usual behavior. */)
1182 (prompt, def, require_match) 1187 (prompt, def, require_match)
1183 Lisp_Object prompt, def, require_match; 1188 Lisp_Object prompt, def, require_match;
1184 { 1189 {
1185 Lisp_Object args[4]; 1190 Lisp_Object args[4], result;
1186 unsigned char *s; 1191 unsigned char *s;
1187 int len; 1192 int len;
1193 int count = SPECPDL_INDEX ();
1188 1194
1189 if (BUFFERP (def)) 1195 if (BUFFERP (def))
1190 def = XBUFFER (def)->name; 1196 def = XBUFFER (def)->name;
1197
1198 specbind (Qcompletion_ignore_case,
1199 read_buffer_completion_ignore_case ? Qt : Qnil);
1191 1200
1192 if (NILP (Vread_buffer_function)) 1201 if (NILP (Vread_buffer_function))
1193 { 1202 {
1194 if (!NILP (def)) 1203 if (!NILP (def))
1195 { 1204 {
1216 args[1] = prompt; 1225 args[1] = prompt;
1217 args[2] = CONSP (def) ? XCAR (def) : def; 1226 args[2] = CONSP (def) ? XCAR (def) : def;
1218 prompt = Fformat (3, args); 1227 prompt = Fformat (3, args);
1219 } 1228 }
1220 1229
1221 return Fcompleting_read (prompt, intern ("internal-complete-buffer"), 1230 result = Fcompleting_read (prompt, intern ("internal-complete-buffer"),
1222 Qnil, require_match, Qnil, Qbuffer_name_history, 1231 Qnil, require_match, Qnil, Qbuffer_name_history,
1223 def, Qnil); 1232 def, Qnil);
1224 } 1233 }
1225 else 1234 else
1226 { 1235 {
1227 args[0] = Vread_buffer_function; 1236 args[0] = Vread_buffer_function;
1228 args[1] = prompt; 1237 args[1] = prompt;
1229 args[2] = def; 1238 args[2] = def;
1230 args[3] = require_match; 1239 args[3] = require_match;
1231 return Ffuncall(4, args); 1240 result = Ffuncall(4, args);
1232 } 1241 }
1242 return unbind_to (count, result);
1233 } 1243 }
1234 1244
1235 static Lisp_Object 1245 static Lisp_Object
1236 minibuf_conform_representation (string, basis) 1246 minibuf_conform_representation (string, basis)
1237 Lisp_Object string, basis; 1247 Lisp_Object string, basis;
2109 2119
2110 DEFVAR_LISP ("read-buffer-function", &Vread_buffer_function, 2120 DEFVAR_LISP ("read-buffer-function", &Vread_buffer_function,
2111 doc: /* If this is non-nil, `read-buffer' does its work by calling this function. */); 2121 doc: /* If this is non-nil, `read-buffer' does its work by calling this function. */);
2112 Vread_buffer_function = Qnil; 2122 Vread_buffer_function = Qnil;
2113 2123
2124 DEFVAR_BOOL ("read-buffer-completion-ignore-case",
2125 &read_buffer_completion_ignore_case,
2126 doc: /* *Non-nil means completion ignores case when reading a buffer name. */);
2127 read_buffer_completion_ignore_case = 0;
2128
2114 DEFVAR_LISP ("minibuffer-setup-hook", &Vminibuffer_setup_hook, 2129 DEFVAR_LISP ("minibuffer-setup-hook", &Vminibuffer_setup_hook,
2115 doc: /* Normal hook run just after entry to minibuffer. */); 2130 doc: /* Normal hook run just after entry to minibuffer. */);
2116 Vminibuffer_setup_hook = Qnil; 2131 Vminibuffer_setup_hook = Qnil;
2117 2132
2118 DEFVAR_LISP ("minibuffer-exit-hook", &Vminibuffer_exit_hook, 2133 DEFVAR_LISP ("minibuffer-exit-hook", &Vminibuffer_exit_hook,