unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* patches for etags and shell-command
@ 2006-01-20 16:29 John Williams
  2006-01-21 19:58 ` Richard M. Stallman
  2006-02-15 18:08 ` Francesco Potorti`
  0 siblings, 2 replies; 7+ messages in thread
From: John Williams @ 2006-01-20 16:29 UTC (permalink / raw)


Hello everyone,

This if my first post to emacs-devel, so feel free to correct my etiquette :)

I have two patches today; the first one changes shell-command so that the 
default interactive argument is the current buffer's filename.  This is inspired 
by vim, where a '%' character in a command expands to the current buffer's filename.

--- simple.el   2006-01-20 09:52:46.000000000 -0600
+++ simple-1.el 2006-01-20 10:08:41.000000000 -0600
@@ -1797,8 +1797,12 @@
  In an interactive call, the variable `shell-command-default-error-buffer'
  specifies the value of ERROR-BUFFER."

-  (interactive (list (read-from-minibuffer "Shell command: "
-                                          nil nil nil 'shell-command-history)
+  (interactive (list (read-from-minibuffer
+                      "Shell command: "
+                      nil nil nil
+                      'shell-command-history
+                      (and (buffer-file-name)
+                           (file-relative-name (buffer-file-name))))
                      current-prefix-arg
                      shell-command-default-error-buffer))
    ;; Look for a handler in case default-directory is a remote file name.

This patch corrects a bug in etags that causes completion to only consider the 
tags in a single TAGS buffer.  With the match tag completion will consider tags 
from all the active TAGS buffers.  (The diff is a bit longer than it really 
needs to be because I inadvertently changed tabs to spaces--I didn't change back 
to tabs because spaces appear to be the preferred from of indentation based on 
emacs's default settings.)

--- etags.el    2006-01-20 09:53:43.000000000 -0600
+++ etags-1.el  2006-01-20 10:14:31.000000000 -0600
@@ -747,28 +747,21 @@
  (defun tags-completion-table ()
    (or tags-completion-table
        (condition-case ()
-         (prog2
-          (message "Making tags completion table for %s..." buffer-file-name)
-          (let ((included (tags-included-tables))
-                (table (funcall tags-completion-table-function)))
-            (save-excursion
-              ;; Iterate over the list of included tables, and combine each
-              ;; included table's completion obarray to the parent obarray.
-              (while included
-                ;; Visit the buffer.
-                (let ((tags-file-name (car included)))
-                  (visit-tags-table-buffer 'same))
-                ;; Recurse in that buffer to compute its completion table.
-                (if (tags-completion-table)
-                    ;; Combine the tables.
-                    (mapatoms (lambda (sym) (intern (symbol-name sym) table))
-                              tags-completion-table))
-                (setq included (cdr included))))
-            (setq tags-completion-table table))
-          (message "Making tags completion table for %s...done"
-                   buffer-file-name))
-       (quit (message "Tags completion table construction aborted.")
-             (setq tags-completion-table nil)))))
+          (let (combined-table)
+            (save-excursion
+              (while (visit-tags-table-buffer (and combined-table t))
+                (let ((included (tags-included-tables))
+                      (table (funcall tags-completion-table-function)))
+                  (if (null combined-table)
+                      (setq combined-table table)
+                    (mapatoms (lambda (sym)
+                                (intern (symbol-name sym) combined-table))
+                              table))
+                  (message "Making tags completion table for %s...done"
+                           buffer-file-name))))
+            (setq tags-completion-table combined-table))
+        (quit (message "Tags completion table construction aborted.")
+              (setq tags-completion-table nil)))))

  ;; Completion function for tags.  Does normal try-completion,
  ;; but builds tags-completion-table on demand.

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

* Re: patches for etags and shell-command
  2006-01-20 16:29 patches for etags and shell-command John Williams
@ 2006-01-21 19:58 ` Richard M. Stallman
  2006-01-21 22:17   ` John Williams
  2006-01-22  0:38   ` Juri Linkov
  2006-02-15 18:08 ` Francesco Potorti`
  1 sibling, 2 replies; 7+ messages in thread
From: Richard M. Stallman @ 2006-01-21 19:58 UTC (permalink / raw)
  Cc: emacs-devel

    I have two patches today; the first one changes shell-command so that the 
    default interactive argument is the current buffer's filename.

Is the idea that you type M-n to bring the current buffer's filename
into the minibuffer, and then you type the rest of the command around
it?  Access to that file name would be useful, but at the same time,
this interface would be rather inconvenient to use.

    This patch corrects a bug in etags that causes completion to only
    consider the tags in a single TAGS buffer.  With the match tag
    completion will consider tags from all the active TAGS buffers.

That seems like a clean extension.  I will forward it to the etags
maintainer.

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

* Re: patches for etags and shell-command
  2006-01-21 19:58 ` Richard M. Stallman
@ 2006-01-21 22:17   ` John Williams
  2006-01-22 17:44     ` Richard M. Stallman
  2006-01-22  0:38   ` Juri Linkov
  1 sibling, 1 reply; 7+ messages in thread
From: John Williams @ 2006-01-21 22:17 UTC (permalink / raw)
  Cc: emacs-devel

Richard M. Stallman wrote:
>     I have two patches today; the first one changes shell-command so that the 
>     default interactive argument is the current buffer's filename.
> 
> Is the idea that you type M-n to bring the current buffer's filename
> into the minibuffer, and then you type the rest of the command around
> it?  Access to that file name would be useful, but at the same time,
> this interface would be rather inconvenient to use.
> 
>     This patch corrects a bug in etags that causes completion to only
>     consider the tags in a single TAGS buffer.  With the match tag
>     completion will consider tags from all the active TAGS buffers.
> 
> That seems like a clean extension.  I will forward it to the etags
> maintainer.
> 

It takes a little getting used to, but it's quite natural to use once 
you get used to M-! M-n meaning "run a shell command on the current file."

Most of the commands you'd use in conjunction with the current file name 
accept the file name as their last argument, so running a command 
usually involves this key sequence:

   M-! M-n <my-command> SPC RET

(If I'd though of it before now I would have added a space at the 
beginning of the default argument since it's probably needed anyway 99% 
of the time.)

Not being able to insert the current filename in the minibuffer seemed 
like a glaring omission when I started using Emacs after years of using 
Vim, so I would really like to see some way of achieving that 
functionality became part of Emacs.

Before I came up with the idea to use M-n, I also considered expanding 
"%" the way Vim does, but I think that's too likely to cause surprises 
to users unfamiliar with the feature.  I also tried adding a special key 
binding to insert the current file name, but I don't think the added 
flexibility is worth the cost of having to remember yet another key 
combination.

--jw

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

* Re: patches for etags and shell-command
  2006-01-21 19:58 ` Richard M. Stallman
  2006-01-21 22:17   ` John Williams
@ 2006-01-22  0:38   ` Juri Linkov
  1 sibling, 0 replies; 7+ messages in thread
From: Juri Linkov @ 2006-01-22  0:38 UTC (permalink / raw)
  Cc: jrw, emacs-devel

>     I have two patches today; the first one changes shell-command so
>     that the default interactive argument is the current buffer's filename.
>
> Is the idea that you type M-n to bring the current buffer's filename
> into the minibuffer, and then you type the rest of the command around
> it?  Access to that file name would be useful, but at the same time,
> this interface would be rather inconvenient to use.

I think using M-n to insert the buffer filename is very useful once users
know about this.  So the manual should mention it after installing.

And also M-! invoked in dired could insert a list of all marked files to
the minibuffer.  This could be used as a replacement of `!' and a special
character `*' surrounded by whitespace.  It is more reliable for users
to see the complete list of marked files in the minibuffer before running
the command than remembering all rules of using `*', `?' and whitespace
in the command run with `!' in dired.

>     This patch corrects a bug in etags that causes completion to only
>     consider the tags in a single TAGS buffer.  With the match tag
>     completion will consider tags from all the active TAGS buffers.
>
> That seems like a clean extension.  I will forward it to the etags
> maintainer.

I haven't tested this patch, but after looking at it I noticed that it
deletes the initial message:

  (message "Making tags completion table for %s..." buffer-file-name)

but retains the finishing message:

  (message "Making tags completion table for %s...done" buffer-file-name)

I think both are necessary.

-- 
Juri Linkov
http://www.jurta.org/emacs/

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

* Re: patches for etags and shell-command
  2006-01-21 22:17   ` John Williams
@ 2006-01-22 17:44     ` Richard M. Stallman
  0 siblings, 0 replies; 7+ messages in thread
From: Richard M. Stallman @ 2006-01-22 17:44 UTC (permalink / raw)
  Cc: emacs-devel

    It takes a little getting used to, but it's quite natural to use once 
    you get used to M-! M-n meaning "run a shell command on the current file."

I will add this to etc/TODO, since now's not the time for new features.

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

* Re: patches for etags and shell-command
  2006-01-20 16:29 patches for etags and shell-command John Williams
  2006-01-21 19:58 ` Richard M. Stallman
@ 2006-02-15 18:08 ` Francesco Potorti`
  1 sibling, 0 replies; 7+ messages in thread
From: Francesco Potorti` @ 2006-02-15 18:08 UTC (permalink / raw)
  Cc: emacs-devel

John, I tried to follow up on your patch to etags.el, but apparently
your mail server bounces mail coming from *.it!

Anyway, you should get this one via the list.

I was examining the patch you proposed (see below), which is intended to
correctly implement Emacs' behaviour as documented in the manual, in the
Select Tags Table node.  However it has three problems:
- it removes the starting message
- it removes helpful comments
- most importantly, it does not recursively descend into the tree of
  included tags tables

Would you please resubmit a patch that corrects these problems?

>This patch corrects a bug in etags that causes completion to only consider the 
>tags in a single TAGS buffer.  With the match tag completion will consider tags 
>from all the active TAGS buffers.  (The diff is a bit longer than it really 
>needs to be because I inadvertently changed tabs to spaces--I didn't change back 
>to tabs because spaces appear to be the preferred from of indentation based on 
>emacs's default settings.)
>
>--- etags.el    2006-01-20 09:53:43.000000000 -0600
>+++ etags-1.el  2006-01-20 10:14:31.000000000 -0600
>@@ -747,28 +747,21 @@
>  (defun tags-completion-table ()
>    (or tags-completion-table
>        (condition-case ()
>-         (prog2
>-          (message "Making tags completion table for %s..." buffer-file-name)
>-          (let ((included (tags-included-tables))
>-                (table (funcall tags-completion-table-function)))
>-            (save-excursion
>-              ;; Iterate over the list of included tables, and combine each
>-              ;; included table's completion obarray to the parent obarray.
>-              (while included
>-                ;; Visit the buffer.
>-                (let ((tags-file-name (car included)))
>-                  (visit-tags-table-buffer 'same))
>-                ;; Recurse in that buffer to compute its completion table.
>-                (if (tags-completion-table)
>-                    ;; Combine the tables.
>-                    (mapatoms (lambda (sym) (intern (symbol-name sym) table))
>-                              tags-completion-table))
>-                (setq included (cdr included))))
>-            (setq tags-completion-table table))
>-          (message "Making tags completion table for %s...done"
>-                   buffer-file-name))
>-       (quit (message "Tags completion table construction aborted.")
>-             (setq tags-completion-table nil)))))
>+          (let (combined-table)
>+            (save-excursion
>+              (while (visit-tags-table-buffer (and combined-table t))
>+                (let ((included (tags-included-tables))
>+                      (table (funcall tags-completion-table-function)))
>+                  (if (null combined-table)
>+                      (setq combined-table table)
>+                    (mapatoms (lambda (sym)
>+                                (intern (symbol-name sym) combined-table))
>+                              table))
>+                  (message "Making tags completion table for %s...done"
>+                           buffer-file-name))))
>+            (setq tags-completion-table combined-table))
>+        (quit (message "Tags completion table construction aborted.")
>+              (setq tags-completion-table nil)))))
>
>  ;; Completion function for tags.  Does normal try-completion,
>  ;; but builds tags-completion-table on demand.
>
>
>_______________________________________________
>Emacs-devel mailing list
>Emacs-devel@gnu.org
>http://lists.gnu.org/mailman/listinfo/emacs-devel
>

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

* Re: patches for etags and shell-command
       [not found] <E1F9nTR-0003HU-Ew@fencepost.gnu.org>
@ 2006-02-19 21:48 ` John Williams
  0 siblings, 0 replies; 7+ messages in thread
From: John Williams @ 2006-02-19 21:48 UTC (permalink / raw)
  Cc: emacs-devel

Francesco,

I've updated my version of tags-completion-table so it contains the same
amount of comments as the original, and I replaced the message I had
accidentally removed.  My tests indicate that recursing into the
included tags tables is not necessary because (while
(visit-tags-table-buffer (and combined-table t)) ...) visits the
included tags tables in addition to those the user has specifically visited.

(defun tags-completion-table ()
  (or tags-completion-table
      ;; No cached value for this buffer.
      (condition-case ()
          (let (current-table combined-table)
            (message "Making tags completion table for %s..."
buffer-file-name)
            (save-excursion
              ;; Iterate over all tags buffers.
              (while (visit-tags-table-buffer (and combined-table t))
                ;; Find possible completions in this buffer.
                (setq current-table (funcall
tags-completion-table-function))
                ;; Merge this buffer's comletions into the combined
                ;; table.
                (if combined-table
                    (mapatoms (lambda (sym)
                                (intern (symbol-name sym) combined-table))
                              current-table)
                  (setq combined-table current-table))))
            (message "Making tags completion table for %s...done"
                     buffer-file-name)
            ;; Cache the result a buffer-local variable.
            (setq tags-completion-table combined-table))
        (quit (message "Tags completion table construction aborted.")
              (setq tags-completion-table nil)))))

P.S. Sorry about the overly aggressive spam filtering; I've updated by
settings so you shouldn't get any more bounces from me.

jw



Richard M. Stallman wrote:

>In case you don't receive his mail.
>
>------- Start of forwarded message -------
>From: Francesco Potorti` <pot@gnu.org>
>To: John Williams <jrw@pobox.com>
>In-reply-to: <43D10FF4.8030202@pobox.com> (jrw@pobox.com)
>Organization: 
>Date: Wed, 15 Feb 2006 19:08:01 +0100
>Cc: emacs-devel@gnu.org
>Subject: Re: patches for etags and shell-command
>
>John, I tried to follow up on your patch to etags.el, but apparently
>your mail server bounces mail coming from *.it!
>
>Anyway, you should get this one via the list.
>
>I was examining the patch you proposed (see below), which is intended to
>correctly implement Emacs' behaviour as documented in the manual, in the
>Select Tags Table node.  However it has three problems:
>- - it removes the starting message
>- - it removes helpful comments
>- - most importantly, it does not recursively descend into the tree of
>  included tags tables
>
>Would you please resubmit a patch that corrects these problems?
>
>  
>
>>This patch corrects a bug in etags that causes completion to only consider the 
>>tags in a single TAGS buffer.  With the match tag completion will consider tags 
>>    
>>
>>from all the active TAGS buffers.  (The diff is a bit longer than it really 
>  
>
>>needs to be because I inadvertently changed tabs to spaces--I didn't change back 
>>to tabs because spaces appear to be the preferred from of indentation based on 
>>emacs's default settings.)
>>
>>--- etags.el    2006-01-20 09:53:43.000000000 -0600
>>+++ etags-1.el  2006-01-20 10:14:31.000000000 -0600
>>@@ -747,28 +747,21 @@
>> (defun tags-completion-table ()
>>   (or tags-completion-table
>>       (condition-case ()
>>-         (prog2
>>-          (message "Making tags completion table for %s..." buffer-file-name)
>>-          (let ((included (tags-included-tables))
>>-                (table (funcall tags-completion-table-function)))
>>-            (save-excursion
>>-              ;; Iterate over the list of included tables, and combine each
>>-              ;; included table's completion obarray to the parent obarray.
>>-              (while included
>>-                ;; Visit the buffer.
>>-                (let ((tags-file-name (car included)))
>>-                  (visit-tags-table-buffer 'same))
>>-                ;; Recurse in that buffer to compute its completion table.
>>-                (if (tags-completion-table)
>>-                    ;; Combine the tables.
>>-                    (mapatoms (lambda (sym) (intern (symbol-name sym) table))
>>-                              tags-completion-table))
>>-                (setq included (cdr included))))
>>-            (setq tags-completion-table table))
>>-          (message "Making tags completion table for %s...done"
>>-                   buffer-file-name))
>>-       (quit (message "Tags completion table construction aborted.")
>>-             (setq tags-completion-table nil)))))
>>+          (let (combined-table)
>>+            (save-excursion
>>+              (while (visit-tags-table-buffer (and combined-table t))
>>+                (let ((included (tags-included-tables))
>>+                      (table (funcall tags-completion-table-function)))
>>+                  (if (null combined-table)
>>+                      (setq combined-table table)
>>+                    (mapatoms (lambda (sym)
>>+                                (intern (symbol-name sym) combined-table))
>>+                              table))
>>+                  (message "Making tags completion table for %s...done"
>>+                           buffer-file-name))))
>>+            (setq tags-completion-table combined-table))
>>+        (quit (message "Tags completion table construction aborted.")
>>+              (setq tags-completion-table nil)))))
>>
>> ;; Completion function for tags.  Does normal try-completion,
>> ;; but builds tags-completion-table on demand.
>>

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

end of thread, other threads:[~2006-02-19 21:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-20 16:29 patches for etags and shell-command John Williams
2006-01-21 19:58 ` Richard M. Stallman
2006-01-21 22:17   ` John Williams
2006-01-22 17:44     ` Richard M. Stallman
2006-01-22  0:38   ` Juri Linkov
2006-02-15 18:08 ` Francesco Potorti`
     [not found] <E1F9nTR-0003HU-Ew@fencepost.gnu.org>
2006-02-19 21:48 ` John Williams

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).