all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* syntax table in minibuffer
@ 2011-09-09 23:00 Masatake YAMATO
  2011-09-10  1:44 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Masatake YAMATO @ 2011-09-09 23:00 UTC (permalink / raw)
  To: emacs-devel

Hi,

When emacs reading file name, I'd like to make the point in minibuffer 
to "/", the file name separator, with \M-\C-b and \M-\C-f. Do you want, too?

In my knowledge, I have to modify syntax table for minibuffer for
doing that. However, I cannot find something link
`minibuffer-local-filename-syntax-table'.

Could you give me hints for that?

Masatake YAMATO



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

* Re: syntax table in minibuffer
  2011-09-09 23:00 syntax table in minibuffer Masatake YAMATO
@ 2011-09-10  1:44 ` Stefan Monnier
  2011-09-12  7:47   ` Masatake YAMATO
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2011-09-10  1:44 UTC (permalink / raw)
  To: Masatake YAMATO; +Cc: emacs-devel

> When emacs reading file name, I'd like to make the point in minibuffer
> to "/", the file name separator, with \M-\C-b and \M-\C-f.
> Do you want, too?

I'm not sure I'd want that, but it does sound like a reasonable
desire, yes.

> In my knowledge, I have to modify syntax table for minibuffer for
> doing that. However, I cannot find something link
> `minibuffer-local-filename-syntax-table'.

> Could you give me hints for that?

I think you'll need to use minibuffer-with-setup-hook around the
relevant completing-read so as to setup the syntax-table with
set-syntax-table.


        Stefan



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

* Re: syntax table in minibuffer
  2011-09-10  1:44 ` Stefan Monnier
@ 2011-09-12  7:47   ` Masatake YAMATO
  2011-09-13 13:48     ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Masatake YAMATO @ 2011-09-12  7:47 UTC (permalink / raw)
  To: monnier; +Cc: emacs-devel

From: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Fri, 09 Sep 2011 21:44:19 -0400
>> When emacs reading file name, I'd like to make the point in minibuffer
>> to "/", the file name separator, with \M-\C-b and \M-\C-f.
>> Do you want, too?
> 
> I'm not sure I'd want that, but it does sound like a reasonable
> desire, yes.
> 
>> In my knowledge, I have to modify syntax table for minibuffer for
>> doing that. However, I cannot find something link
>> `minibuffer-local-filename-syntax-table'.
> 
>> Could you give me hints for that?
> 
> I think you'll need to use minibuffer-with-setup-hook around the
> relevant completing-read so as to setup the syntax-table with
> set-syntax-table.

Thank you. I've implemented base on your hit. 
New behaviors of \M-\C-f and \M-\C-b in \C-x\C-f are nice.
I'd like you to include this into the offcial emacs source tree.
We are in feature-freeze stage. What shoud I do?
Should I submit this to bug tracking system?

2011-09-12  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-12 07:38:03 +0000
@@ -1997,6 +1997,24 @@
   (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)))
+    (mapc
+     (lambda (c)
+       (modify-syntax-entry 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 +2083,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)))



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

* Re: syntax table in minibuffer
  2011-09-12  7:47   ` Masatake YAMATO
@ 2011-09-13 13:48     ` Stefan Monnier
  2011-09-13 14:17       ` Masatake YAMATO
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2011-09-13 13:48 UTC (permalink / raw)
  To: Masatake YAMATO; +Cc: emacs-devel

> Thank you. I've implemented base on your hit. 
> New behaviors of \M-\C-f and \M-\C-b in \C-x\C-f are nice.
> I'd like you to include this into the offcial Emacs source tree.

I'm not sure we want that by default.

> We are in feature-freeze stage. What shoud I do?
> Should I submit this to bug tracking system?

Please do so, yes.

> +(defvar minibuffer-local-filename-syntax 
> +  (let ((table (make-syntax-table)))
> +    (mapc
> +     (lambda (c)
> +       (modify-syntax-entry c "_" table))
> +     '(?~ ?` ?! ?@ ?# ?$ ?% ?^ ?& ?* ?( ?) ?- ?_ ?= ?+ 
> +	  ?{ ?} ?[ ?] ?| ?\; ?\" ?'
> +	  ?, ?< ?. ?> ??))

Why this particular list?  Please represent the list of chars in a way
that makes it more clear why it's chosen that way.


        Stefan



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

* Re: syntax table in minibuffer
  2011-09-13 13:48     ` Stefan Monnier
@ 2011-09-13 14:17       ` Masatake YAMATO
  2011-09-13 18:22         ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Masatake YAMATO @ 2011-09-13 14:17 UTC (permalink / raw)
  To: monnier; +Cc: emacs-devel

On Tue, 13 Sep 2011 09:48:09 -0400, Stefan Monnier <monnier@iro.umontreal.ca> wrote
>> Thank you. I've implemented base on your hit. 
>> New behaviors of \M-\C-f and \M-\C-b in \C-x\C-f are nice.
>> I'd like you to include this into the offcial Emacs source tree.
> 
> I'm not sure we want that by default.
> 
>> We are in feature-freeze stage. What shoud I do?
>> Should I submit this to bug tracking system?
> 
> Please do so, yes.

I'll do so.
 
>> +(defvar minibuffer-local-filename-syntax 
>> +  (let ((table (make-syntax-table)))
>> +    (mapc
>> +     (lambda (c)
>> +       (modify-syntax-entry c "_" table))
>> +     '(?~ ?` ?! ?@ ?# ?$ ?% ?^ ?& ?* ?( ?) ?- ?_ ?= ?+ 
>> +	  ?{ ?} ?[ ?] ?| ?\; ?\" ?'
>> +	  ?, ?< ?. ?> ??))
> 
> Why this particular list?  Please represent the list of chars in a way
> that makes it more clear why it's chosen that way.

I wanted to choose all chars which is defined as punctuation.
I wanted to convert them to symbol. So \M-\C-f and \M-\C-b can
ignore them. Is there any good way for choosing them?
If not, I have to write a function traversing a given syntax table.

Masatake YAMATO
 
> 
>         Stefan



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

* Re: syntax table in minibuffer
  2011-09-13 14:17       ` Masatake YAMATO
@ 2011-09-13 18:22         ` Stefan Monnier
  2011-09-15  8:56           ` Masatake YAMATO
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2011-09-13 18:22 UTC (permalink / raw)
  To: Masatake YAMATO; +Cc: emacs-devel

> I wanted to choose all chars which is defined as punctuation.
> I wanted to convert them to symbol. So \M-\C-f and \M-\C-b can
> ignore them. Is there any good way for choosing them?
> If not, I have to write a function traversing a given syntax table.

map-char-table should do the trick.

BTW, another way to attack the problem is to leave the syntax-table
alone, but set forward-sexp-function.


        Stefan



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

* Re: syntax table in minibuffer
  2011-09-13 18:22         ` Stefan Monnier
@ 2011-09-15  8:56           ` Masatake YAMATO
  2011-09-15 13:09             ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Masatake YAMATO @ 2011-09-15  8:56 UTC (permalink / raw)
  To: monnier; +Cc: emacs-devel

>> I wanted to choose all chars which is defined as punctuation.
>> I wanted to convert them to symbol. So \M-\C-f and \M-\C-b can
>> ignore them. Is there any good way for choosing them?
>> If not, I have to write a function traversing a given syntax table.
> 
> map-char-table should do the trick.

Thanks. I rewrote the patch using the function.

> BTW, another way to attack the problem is to leave the syntax-table
> alone, but set forward-sexp-function.

I have no idea which is better. However, it will be nice that minibuffer
can has its own major mode. e.g. minibuffer-filename-mode.

Masatake
 
> 
>         Stefan
> 



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

* Re: syntax table in minibuffer
  2011-09-15  8:56           ` Masatake YAMATO
@ 2011-09-15 13:09             ` Stefan Monnier
  2011-09-15 14:18               ` Masatake YAMATO
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2011-09-15 13:09 UTC (permalink / raw)
  To: Masatake YAMATO; +Cc: emacs-devel

>>> I wanted to choose all chars which is defined as punctuation.
>>> I wanted to convert them to symbol. So \M-\C-f and \M-\C-b can
>>> ignore them. Is there any good way for choosing them?
>>> If not, I have to write a function traversing a given syntax table.
>> map-char-table should do the trick.
> Thanks. I rewrote the patch using the function.

>> BTW, another way to attack the problem is to leave the syntax-table
>> alone, but set forward-sexp-function.
> I have no idea which is better.

Setting forward-sexp-function lets you change C-M-f in more subtle ways.
E.g. it can still jump from "/usr/^hello world" (where ^ represents
point) to "/usr/hello^ world" like it does now (and/or jump over parens)
while at the same time being able to jump from "/usr^/hello world" to
"/usr/hello world^".

> However, it will be nice that minibuffer can has its own major
> mode. e.g. minibuffer-filename-mode.

We currently don't use major modes much in the minibuffer.  But maybe we
could move in this direction.  If so, we'd probably want to create
a minibuffer-completion-mode to use as parent.  Not sure how useful it
would be, tho.


        Stefan



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

* Re: syntax table in minibuffer
  2011-09-15 13:09             ` Stefan Monnier
@ 2011-09-15 14:18               ` Masatake YAMATO
  0 siblings, 0 replies; 9+ messages in thread
From: Masatake YAMATO @ 2011-09-15 14:18 UTC (permalink / raw)
  To: monnier; +Cc: emacs-devel

>>>> I wanted to choose all chars which is defined as punctuation.
>>>> I wanted to convert them to symbol. So \M-\C-f and \M-\C-b can
>>>> ignore them. Is there any good way for choosing them?
>>>> If not, I have to write a function traversing a given syntax table.
>>> map-char-table should do the trick.
>> Thanks. I rewrote the patch using the function.
> 
>>> BTW, another way to attack the problem is to leave the syntax-table
>>> alone, but set forward-sexp-function.
>> I have no idea which is better.
> 
> Setting forward-sexp-function lets you change C-M-f in more subtle ways.
> E.g. it can still jump from "/usr/^hello world" (where ^ represents
> point) to "/usr/hello^ world" like it does now (and/or jump over parens)
> while at the same time being able to jump from "/usr^/hello world" to
> "/usr/hello world^".

It looks over engineering for me. 
To go to the whitespace M-f and M-b can be used.
 
Anyway I'd like people to try the patch.
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9511

Masatake YAMATO

>> However, it will be nice that minibuffer can has its own major
>> mode. e.g. minibuffer-filename-mode.
> 
> We currently don't use major modes much in the minibuffer.  But maybe we
> could move in this direction.  If so, we'd probably want to create
> a minibuffer-completion-mode to use as parent.  Not sure how useful it
> would be, tho.
> 
> 
>         Stefan
> 



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

end of thread, other threads:[~2011-09-15 14:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-09 23:00 syntax table in minibuffer Masatake YAMATO
2011-09-10  1:44 ` Stefan Monnier
2011-09-12  7:47   ` Masatake YAMATO
2011-09-13 13:48     ` Stefan Monnier
2011-09-13 14:17       ` Masatake YAMATO
2011-09-13 18:22         ` Stefan Monnier
2011-09-15  8:56           ` Masatake YAMATO
2011-09-15 13:09             ` Stefan Monnier
2011-09-15 14:18               ` Masatake YAMATO

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.