all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Masatake YAMATO <yamato@redhat.com>
To: 9511@debbugs.gnu.org
Subject: bug#9511: Moving the point to / with C-M-f and C-M-b when reading a filename from minibuffer
Date: Thu, 15 Sep 2011 17:39:06 +0900 (JST)	[thread overview]
Message-ID: <20110915.173906.185902603333825732.yamato@redhat.com> (raw)

This is a request for merge a patch to official GNU Emacs source tree.
Following patch adds a function to move the point to / with
C-M-f and C-M-b when reading a filename from minibuffer.
See also the thread at http://lists.gnu.org/archive/html/emacs-devel/2011-09/msg00155.html


2011-09-15  Masatake YAMATO  <yamato@redhat.com>

	* minibuffer.el (minibuffer-local-filename-syntax): New variable.
	(read-file-name-default): Install the syntax table.

=== modified file 'lisp/minibuffer.el'
--- lisp/minibuffer.el	2011-09-02 00:36:58 +0000
+++ lisp/minibuffer.el	2011-09-15 06:27:34 +0000
@@ -1997,6 +1997,31 @@
   (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 (cc syntax)
+		      (when (and syntax
+				 (eq (car syntax)
+				     punctuation))
+			(let* ((cons? (consp cc))
+			       (begin (if cons? (car cc) cc))
+			       (end (if cons? (cdr cc) begin))
+			       (c begin))
+			  (while (<= c end)
+			    (modify-syntax-entry c "_" table)
+			    (setq c (1+ c))))))
+		    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.
@@ -2065,7 +2090,9 @@
                                (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)))






             reply	other threads:[~2011-09-15  8:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-15  8:39 Masatake YAMATO [this message]
2011-09-15 13:03 ` bug#9511: Moving the point to / with C-M-f and C-M-b when reading a filename from minibuffer Stefan Monnier
2011-09-15 14:05   ` Masatake YAMATO
2012-04-12 19:52 ` Lars Magne Ingebrigtsen
2012-04-13  1:30   ` Masatake YAMATO
2012-04-13 21:35     ` Lars Ingebrigtsen

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=20110915.173906.185902603333825732.yamato@redhat.com \
    --to=yamato@redhat.com \
    --cc=9511@debbugs.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.