unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#10160: 24.0.91; diff-hunk-file-names returns quoted file names
@ 2011-11-29 11:32 Michael Albinus
  2011-11-29 18:50 ` Stefan Monnier
  2021-07-16 13:50 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Albinus @ 2011-11-29 11:32 UTC (permalink / raw)
  To: 10160

diff-hunk-file-names reads file names from the *Diff* buffer. The first
line (the diff command itself) can contain labels, marked with -L. If
these labels contains quoted characters like in remote file names, the
quotation is returned. Example:

diff -c -L /ftp\:slbhao\:/home/albinus/src/tramp/lisp/tramp.el -L /ftp\:slbhao\:/home/albinus/src/emacs/lisp/net/tramp.el /tmp/ange-ftp13518wvE.el /tmp/ange-ftp1351895K.el

Such quoted file names result in problems when used as parameter for
file name functions, like in diff-find-file-name.


In GNU Emacs 24.0.91.14 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.6)
 of 2011-11-28 on detlef
Windowing system distributor `GraphOn Corporation', version 11.0.60900000
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Group

Minor modes in effect:
  gnus-undo-mode: t
  display-time-mode: t
  shell-dirtrack-mode: t
  iswitchb-mode: t
  icomplete-mode: t
  show-paren-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<f2> <escape> x r e p o r t <tab> <return>

Recent messages:
Reading active file from news via nntp...
Opening nntp server on news...failed: >>> (error Selecting deleted buffer)
Opening connection to imap.gmx.net via tls...
Reading active file via nnml...
Reading incoming mail from pop...
nnml: Reading incoming mail (no new mail)...done
Reading active file via nnml...done
Reading active file via nndraft...done
Checking new news...done
Warning: Opening nntp server on news...failed: >>> (error Selecting deleted buffer)

Load-path shadows:
/home/albinus/.emacs.d/elpa/debbugs-0.3/debbugs hides ~/lisp/debbugs
/home/albinus/.emacs.d/elpa/debbugs-0.3/debbugs-gnu hides ~/lisp/debbugs-gnu
~/src/tramp/lisp/tramp-uu hides /home/albinus/src/emacs/lisp/net/tramp-uu
~/src/tramp/lisp/tramp-cmds hides /home/albinus/src/emacs/lisp/net/tramp-cmds
~/src/tramp/lisp/tramp-cache hides /home/albinus/src/emacs/lisp/net/tramp-cache
~/src/tramp/lisp/tramp-gvfs hides /home/albinus/src/emacs/lisp/net/tramp-gvfs
~/src/tramp/lisp/tramp-gw hides /home/albinus/src/emacs/lisp/net/tramp-gw
~/src/tramp/lisp/tramp hides /home/albinus/src/emacs/lisp/net/tramp
~/src/tramp/lisp/tramp-smb hides /home/albinus/src/emacs/lisp/net/tramp-smb
~/src/tramp/lisp/tramp-sh hides /home/albinus/src/emacs/lisp/net/tramp-sh
~/src/tramp/lisp/trampver hides /home/albinus/src/emacs/lisp/net/trampver
~/src/tramp/lisp/tramp-ftp hides /home/albinus/src/emacs/lisp/net/tramp-ftp
~/src/tramp/lisp/tramp-compat hides /home/albinus/src/emacs/lisp/net/tramp-compat
~/lisp/soap-client hides /home/albinus/src/emacs/lisp/net/soap-client
~/lisp/dbus hides /home/albinus/src/emacs/lisp/net/dbus

Features:
(shadow sort mail-extr warnings emacsbug pop3 utf-7 gnutls nnimap
parse-time utf7 nndraft nnmh netrc nnml network-stream starttls tls
gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg gnus-art
mm-uu mml2015 epg-config mm-view mml-smime smime dig mailcap gnus-cache
nnir gnus-sum nnnil smtpmail sendmail gnus-demon nntp gnus-group
gnus-undo nnmail mail-source nnoo gnus-start gnus-spec gnus-int
gnus-range message rfc822 mml mml-sec mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils
mailheader gnus-win gnus gnus-ems nnheader mail-utils wid-edit
debbugs-autoloads package tabulated-list cperl-mode easymenu time tramp
tramp-compat auth-source eieio byte-opt bytecomp byte-compile cconv
macroexp assoc gnus-util mm-util mail-prsvr password-cache shell
pcomplete comint ring format-spec advice help-fns advice-preload cl
tramp-loaddefs iswitchb jka-compr icomplete paren ps-print ps-def lpr vc
ediff-merg ediff-diff ediff-wind ediff-help ediff-util ediff-mult
ediff-init ediff vc-dispatcher dired regexp-opt time-date tooltip
ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd
fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer loaddefs button faces cus-face files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)





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

* bug#10160: 24.0.91; diff-hunk-file-names returns quoted file names
  2011-11-29 11:32 bug#10160: 24.0.91; diff-hunk-file-names returns quoted file names Michael Albinus
@ 2011-11-29 18:50 ` Stefan Monnier
  2011-11-29 19:01   ` Michael Albinus
  2021-07-16 13:50 ` Lars Ingebrigtsen
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2011-11-29 18:50 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 10160

> diff-hunk-file-names reads file names from the *Diff* buffer. The first
> line (the diff command itself) can contain labels, marked with -L. If
> these labels contains quoted characters like in remote file names, the
> quotation is returned. Example:

> diff -c -L /ftp\:slbhao\:/home/albinus/src/tramp/lisp/tramp.el -L /ftp\:slbhao\:/home/albinus/src/emacs/lisp/net/tramp.el /tmp/ange-ftp13518wvE.el /tmp/ange-ftp1351895K.el

> Such quoted file names result in problems when used as parameter for
> file name functions, like in diff-find-file-name.

Not sure what to do about them: this "parsing the diff command line" is
brittle in any case because this line is printed by various tools, and
I don't think they're very consistent in how they handle quoting.
We should probably try to minimize the problem first, by using relative
file names when possible.


        Stefan





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

* bug#10160: 24.0.91; diff-hunk-file-names returns quoted file names
  2011-11-29 18:50 ` Stefan Monnier
@ 2011-11-29 19:01   ` Michael Albinus
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Albinus @ 2011-11-29 19:01 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 10160

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> diff-hunk-file-names reads file names from the *Diff* buffer. The first
>> line (the diff command itself) can contain labels, marked with -L. If
>> these labels contains quoted characters like in remote file names, the
>> quotation is returned. Example:
>
>> diff -c -L /ftp\:slbhao\:/home/albinus/src/tramp/lisp/tramp.el -L
>> /ftp\:slbhao\:/home/albinus/src/emacs/lisp/net/tramp.el
>> /tmp/ange-ftp13518wvE.el /tmp/ange-ftp1351895K.el
>
>> Such quoted file names result in problems when used as parameter for
>> file name functions, like in diff-find-file-name.
>
> Not sure what to do about them: this "parsing the diff command line" is
> brittle in any case because this line is printed by various tools, and
> I don't think they're very consistent in how they handle quoting.
> We should probably try to minimize the problem first, by using relative
> file names when possible.

In my use case, it was superfluous, because the correct file names are
also parsed in the diff output (thanks to the -L label option). I don't
know whether we could generalize this, trusting just the given file
names of the diff result.

(And, btw, ediff could also use the -L argument. This would look better
than the local temp file names, as produced by Tramp for remote
files. But this is another story).

>         Stefan

Best regards, Michael.





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

* bug#10160: 24.0.91; diff-hunk-file-names returns quoted file names
  2011-11-29 11:32 bug#10160: 24.0.91; diff-hunk-file-names returns quoted file names Michael Albinus
  2011-11-29 18:50 ` Stefan Monnier
@ 2021-07-16 13:50 ` Lars Ingebrigtsen
  2021-08-14 13:51   ` Lars Ingebrigtsen
  1 sibling, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-16 13:50 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 10160

Michael Albinus <michael.albinus@gmx.de> writes:

> diff-hunk-file-names reads file names from the *Diff* buffer. The first
> line (the diff command itself) can contain labels, marked with -L. If
> these labels contains quoted characters like in remote file names, the
> quotation is returned. Example:
>
> diff -c -L /ftp\:slbhao\:/home/albinus/src/tramp/lisp/tramp.el -L /ftp\:slbhao\:/home/albinus/src/emacs/lisp/net/tramp.el /tmp/ange-ftp13518wvE.el /tmp/ange-ftp1351895K.el

Looking at the code, it just returns the first two "words" after
"diff -OPTION":

             ;; this assumes that there are no spaces in filenames
	     (when (re-search-backward
		    "^diff \\(-\\S-+ +\\)*\\(\\S-+\\)\\( +\\(\\S-+\\)\\)?"
		    nil t)
	       (list (if old (match-string 2) (match-string 4))
		     (if old (match-string 4) (match-string 2)))))))))

I guess we could filter out "-L +\\S-+" before matching?  But I don't
think I've ever seen "-L" in the wild, so I don't know whether it's
worth doing.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#10160: 24.0.91; diff-hunk-file-names returns quoted file names
  2021-07-16 13:50 ` Lars Ingebrigtsen
@ 2021-08-14 13:51   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-14 13:51 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 10160

Lars Ingebrigtsen <larsi@gnus.org> writes:

> I guess we could filter out "-L +\\S-+" before matching?  But I don't
> think I've ever seen "-L" in the wild, so I don't know whether it's
> worth doing.

Nobody had an opinion, but it seemed easy enough to add, so I've done so
in Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2021-08-14 13:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-29 11:32 bug#10160: 24.0.91; diff-hunk-file-names returns quoted file names Michael Albinus
2011-11-29 18:50 ` Stefan Monnier
2011-11-29 19:01   ` Michael Albinus
2021-07-16 13:50 ` Lars Ingebrigtsen
2021-08-14 13:51   ` Lars Ingebrigtsen

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