all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lennart Borgman <lennart.borgman.073@student.lu.se>
Cc: Thomas Link <t.link@gmx.at>, Emacs Devel <emacs-devel@gnu.org>
Subject: Re: shell-command - missing shell-quote-argument for program?
Date: Fri, 13 Oct 2006 23:26:01 +0200	[thread overview]
Message-ID: <45300469.7030107@student.lu.se> (raw)
In-Reply-To: <m3zmc137n1.fsf@kfs-l.imdomain.dk>

Kim F. Storm wrote:
> Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
>
>   
>> The author of filesets Thomas Link has replied to me that he currently 
>> does not use Emacs and cannot maintain filesets.el until that situation 
>> changes.
>>
>> I myself therefore suggest the following patch to filesets.el:
>>     
>
> Isolated, it looks ok, but if you look at filesets-quote, maybe
> it should use shell-quote-argment too, and we should
> use filesets-quote on buffer-file-name below.
>
> But it's too complex for me to follow the logic in filesets.
>   
I just printed filesets.el - 40 pages ;-)

Yes, I missed filesets-quote. It is used in 
filesets-get-quoted-selection. This is in turned used only in 
filesets-command:

    ("Grep <<selection>>"
     "grep"
     ("-n " filesets-get-quoted-selection " " "<<file-name>>"))

This is a shell command so in filesets-get-quoted-selection I think that 
shell-quote-argument should be used.

filesets-quote is also used in filesets-run-cmd--repl-fn:

              ((equal arg "<<file-name>>")
               (filesets-quote (buffer-file-name)))

filesets-rum-cmd--repl-fn is only used in filesets-run-cmd where it is 
used two times. The first use of this function looks like this

            (cond
             ((stringp fn)
              (let* ((args
                  (let ((txt ""))
                    (dolist (this args txt)
                      (setq txt
                        (concat txt
                            (filesets-run-cmd--repl-fn
                             this
                             (lambda (this)
                               (if (equal txt "") "" " ")
                               (format "%s" this))))))))
                 (cmd (concat fn " " args)))
                (filesets-cmd-show-result
                 cmd (shell-command-to-string cmd))))

What is intended is probably something like this:

                        (cond
                         ((stringp fn)
                          (let* ((args
                                  (let ((txt ""))
                                    (dolist (this args txt)
                                      (setq txt
                                            (concat txt
                                                    (if (equal txt "") 
"" " ")
                                                    
(shell-quote-argument this))))))
                                 (setq fn (shell-quote-argument fn))
                                 (cmd (concat fn " " args)))
                            (filesets-cmd-show-result
                             cmd (shell-command-to-string cmd))))


Coming this far I looked a bit more carefully at filesets-run-cmd. And I 
do not understand what it is doing. The code below is from this 
function. I have however replaced the name of the loop variable from 
"this" to "file". Further down in the function neither "file" or 
"buffer" is used. Seems strange to me. Can someone explain what the code 
does or what it was supposed to do? :

            (dolist (file files nil)
              (save-excursion
                (save-restriction
                  (let ((buffer (filesets-find-file file)))
                    (when buffer
                      (goto-char (point-min))




BTW the optional argument in (defun filesets-run-cmd--repl-fn (arg 
&optional format-fn) should not be optional I think. Leaving it out will 
result in (funcall nil ...).



>   
>> Index: filesets.el
>> ===================================================================
>> RCS file: /cvsroot/emacs/emacs/lisp/filesets.el,v
>> retrieving revision 1.29
>> diff -c -r1.29 filesets.el
>> *** filesets.el    13 Aug 2006 17:05:12 -0000    1.29
>> --- filesets.el    6 Oct 2006 13:15:12 -0000
>> ***************
>> *** 1701,1707 ****
>>             ok)
>>             t)))
>>       (when ok
>> !       (let ((cmd (format txt (buffer-file-name))))
>>       (message "Filesets: %s" cmd)
>>       (filesets-cmd-show-result cmd
>>                     (shell-command-to-string cmd))))))
>> --- 1701,1707 ----
>>             ok)
>>             t)))
>>       (when ok
>> !       (let ((cmd (format txt (shell-quote-argument (buffer-file-name)))))
>>       (message "Filesets: %s" cmd)
>>       (filesets-cmd-show-result cmd
>>                     (shell-command-to-string cmd))))))
>>     
>
>   


-- 
lennart.borgman.073@student.lu.se
http://OurComments.org/blog/

  parent reply	other threads:[~2006-10-13 21:26 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-05 14:34 shell-command - missing shell-quote-argument for program? Lennart Borgman
2006-10-05 14:53 ` Lennart Borgman
2006-10-06 11:38   ` Lennart Borgman
2006-10-06 12:34     ` Andreas Schwab
2006-10-06 12:43       ` Kim F. Storm
2006-10-06 12:49         ` David Kastrup
2006-10-06 13:34           ` Kim F. Storm
2006-10-07  1:07       ` Richard Stallman
2006-10-07 13:11         ` Andreas Schwab
2006-10-08  3:30           ` Richard Stallman
2006-10-08 15:43             ` Andreas Schwab
2006-10-08 22:27               ` Richard Stallman
2006-10-08 22:36                 ` Andreas Schwab
2006-10-09 20:08                   ` Richard Stallman
2006-10-09  9:12                 ` Kim F. Storm
2006-10-06 12:49   ` Kim F. Storm
2006-10-06 13:20   ` Lennart Borgman
2006-10-12 14:56     ` Kim F. Storm
2006-10-12 22:38       ` Richard Stallman
2006-10-13 21:26       ` Lennart Borgman [this message]
2006-10-13 23:16         ` Lennart Borgman
2006-10-14  7:13         ` Thomas Link
2006-10-13 18:13     ` Thomas Link
2006-10-13 19:55       ` Lennart Borgman
2006-10-13 21:20         ` [Bulk] " Thomas Link
2006-10-14 10:07       ` Richard Stallman
2006-10-14 14:11     ` Eli Zaretskii
     [not found]   ` <4526434B.9010606@student.lu.se>
     [not found]     ` <rzqr6xhf9l9.fsf@loveshack.ukfsn.org>
2006-10-09 22:14       ` Lennart Borgman
2006-10-10  6:46         ` Slawomir Nowaczyk
2006-10-10  7:02           ` Lennart Borgman
2006-10-12 13:52             ` Slawomir Nowaczyk
2006-10-12 14:18               ` Kim F. Storm
2006-10-15 13:50         ` Dave Love
2006-10-15 19:08           ` Lennart Borgman
2006-10-16 22:33             ` Dave Love
2006-10-16 22:37               ` Lennart Borgman
2006-10-14 14:02   ` Eli Zaretskii
2006-10-14 15:33     ` Lennart Borgman
2006-10-14 17:50       ` Andreas Schwab
2006-10-14 18:15         ` Eli Zaretskii
2006-10-15  9:30           ` Lennart Borgman
2006-10-15 20:43             ` Kim F. Storm
2006-10-14 18:22       ` Eli Zaretskii
2006-10-14 23:02       ` Kim F. Storm
2006-10-15  9:00         ` Lennart Borgman
2006-10-15  9:35           ` Lennart Borgman
2006-10-15 20:42             ` Kim F. Storm
2006-10-15 10:12       ` Richard Stallman
2006-10-15 14:14       ` Slawomir Nowaczyk
2006-10-15 10:12     ` Richard Stallman
2006-10-15 19:13       ` Lennart Borgman
2006-10-15 20:43         ` Kim F. Storm
2006-10-05 19:36 ` Stefan Monnier
2006-10-05 19:58 ` Eli Zaretskii
2006-10-05 20:21   ` Lennart Borgman

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=45300469.7030107@student.lu.se \
    --to=lennart.borgman.073@student.lu.se \
    --cc=emacs-devel@gnu.org \
    --cc=t.link@gmx.at \
    /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.