summaryrefslogtreecommitdiff
path: root/lisp/minibuffer.el
diff options
context:
space:
mode:
authorMasatake YAMATO <yamato@redhat.com>2012-04-13 23:43:03 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2012-04-13 23:43:03 +0200
commit09b95ce39ba378b3fe116379c85af5a5a42599cd (patch)
treeeb4ede80437bdbaecdcfab073d1fdbacdb5af94b /lisp/minibuffer.el
parent4b63a9ca3d6451521cdcd2274e9ab1c9b16ba092 (diff)
downloademacs-09b95ce39ba378b3fe116379c85af5a5a42599cd.tar.gz
Make `C-M-f' and friends work better when prompting for file names
* minibuffer.el (minibuffer-local-filename-syntax): New variable to allow `C-M-f' and `C-M-b' to move to the nearest path separator.
Diffstat (limited to 'lisp/minibuffer.el')
-rw-r--r--lisp/minibuffer.el18
1 files changed, 17 insertions, 1 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index bcc6a808d22..eb731897212 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2045,6 +2045,21 @@ and `read-file-name-function'."
(funcall (or read-file-name-function #'read-file-name-default)
prompt dir default-filename mustmatch initial predicate))
+(defvar minibuffer-local-filename-syntax
+ (let ((table (make-syntax-table))
+ (punctuation (car (string-to-syntax "."))))
+ ;; Convert all punctuation entries to symbol.
+ (map-char-table (lambda (c syntax)
+ (when (eq (car syntax) punctuation)
+ (modify-syntax-entry c "_" table)))
+ table)
+ (mapc
+ (lambda (c)
+ (modify-syntax-entry c "." table))
+ '(?/ ?: ?\\))
+ table)
+ "Syntax table to be used in minibuffer for reading file name.")
+
;; minibuffer-completing-file-name is a variable used internally in minibuf.c
;; to determine whether to use minibuffer-local-filename-completion-map or
;; minibuffer-local-completion-map. It shouldn't be exported to Elisp.
@@ -2113,7 +2128,8 @@ See `read-file-name' for the meaning of the arguments."
(lambda ()
(with-current-buffer
(window-buffer (minibuffer-selected-window))
- (read-file-name--defaults dir initial)))))
+ (read-file-name--defaults dir initial))))
+ (set-syntax-table minibuffer-local-filename-syntax))
(completing-read prompt 'read-file-name-internal
pred mustmatch insdef
'file-name-history default-filename)))