[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: find-file-noselect needs save-match-data
From: |
Stefan Monnier |
Subject: |
Re: find-file-noselect needs save-match-data |
Date: |
Fri, 15 Jun 2007 10:20:49 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) |
>> Actually, I'd even argue against any such new function,
> How about adding another optional argument then?
Same deal: you're trying to solve a non-problem.
>> on the grounds that it's solving a non-problem, i.e. it will just add new
>> functions, new code, new complexity for no real benefit.
> Consider `abbreviate-file-name'. It has the following construct:
> (if (and (string-match abbreviated-home-dir filename)
> ;; If the home dir is just /, don't change it.
> (not (and (= (match-end 0) 1)
> (= (aref filename 0) ?/)))
> ;; MS-DOS root directories can come with a drive letter;
> ;; Novell Netware allows drive letters beyond `Z:'.
> (not (and (or (eq system-type 'ms-dos)
> (eq system-type 'cygwin)
> (eq system-type 'windows-nt))
> (save-match-data
> (string-match "^[a-zA-`]:/$" filename)))))
> (setq filename
> (concat "~"
> (match-string 1 filename)
> (substring filename (match-end 0)))))
Looks fine to me. I don't find it particularly unreadable and its
efficiency seems to be perfectly adequate.
Stefan
PS: By the way, the above code looks odd. The comment seems to imply that
the MS-DOS check just reproduces the preceding / check, but it's not
the case: the / check makes sure that if HOME is / then /a/b will not be
changed to ~/a/b, whereas the MS-DOS check will only prevent changing A:/ to
~ but it will not prevent changing A:/b/c to ~/b/c. I noticed this when
I considered replacing those two checks with
;; If the home dir is just /, don't change it.
;; Same thing for A:/ under FreeDOS.
(let ((home (directory-file-name (match-string 0))))
(equal home (file-name-directory home)))
- Re: find-file-noselect needs save-match-data, (continued)
- Re: find-file-noselect needs save-match-data, Miles Bader, 2007/06/13
- Re: find-file-noselect needs save-match-data, Stefan Monnier, 2007/06/13
- Re: find-file-noselect needs save-match-data, martin rudalics, 2007/06/14
- Re: find-file-noselect needs save-match-data, Richard Stallman, 2007/06/14
- Re: find-file-noselect needs save-match-data, Stefan Monnier, 2007/06/14
- Re: find-file-noselect needs save-match-data, martin rudalics, 2007/06/15
- Re: find-file-noselect needs save-match-data,
Stefan Monnier <=
- Re: find-file-noselect needs save-match-data, Herbert Euler, 2007/06/15
- Re: find-file-noselect needs save-match-data, Richard Stallman, 2007/06/15
- Re: find-file-noselect needs save-match-data, martin rudalics, 2007/06/16
- Re: find-file-noselect needs save-match-data, Richard Stallman, 2007/06/16
- Re: find-file-noselect needs save-match-data, Richard Stallman, 2007/06/15
- Re: find-file-noselect needs save-match-data, Stefan Monnier, 2007/06/15
- Re: find-file-noselect needs save-match-data, David Kastrup, 2007/06/15
- Re: find-file-noselect needs save-match-data, Richard Stallman, 2007/06/16
- Re: find-file-noselect needs save-match-data, David Kastrup, 2007/06/16
- Re: find-file-noselect needs save-match-data, Richard Stallman, 2007/06/17