diff options
| author | Joakim Verona | 2012-12-05 08:35:07 +0100 |
|---|---|---|
| committer | Joakim Verona | 2012-12-05 08:35:07 +0100 |
| commit | 3076e0dfbafc9bd7e293fb7aa750abfd91790538 (patch) | |
| tree | db335c56e94294180ce2fe3f640db7f0a679ad79 | |
| parent | 62b8a78dac23bece15b57c985222f9b6852fd224 (diff) | |
| parent | a368019460b1a22a84acc8e8836f60e97ebbcb25 (diff) | |
| download | emacs-3076e0dfbafc9bd7e293fb7aa750abfd91790538.tar.gz emacs-3076e0dfbafc9bd7e293fb7aa750abfd91790538.zip | |
auto upstream
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/ffap.el | 194 |
2 files changed, 101 insertions, 102 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 77eed9ed918..b6f03d4a5d3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,14 @@ | |||
| 1 | 2012-12-05 Chong Yidong <cyd@gnu.org> | 1 | 2012-12-05 Chong Yidong <cyd@gnu.org> |
| 2 | 2 | ||
| 3 | * ffap.el (ffap-url-regexp): Don't require matching at front of | ||
| 4 | string (Bug#4952). | ||
| 5 | (ffap-url-p): If only a substring matches, return that. | ||
| 6 | (ffap-url-at-point): Use the return value of ffap-url-p. | ||
| 7 | (ffap-read-file-or-url, ffap-read-file-or-url-internal) | ||
| 8 | (find-file-at-point, dired-at-point, dired-at-point-prompter) | ||
| 9 | (ffap-guess-file-name-at-point): Likewise. | ||
| 10 | (ffap-replace-file-component): Fix typo. | ||
| 11 | |||
| 3 | * info.el (info-display-manual): Add existing Info buffers, whose | 12 | * info.el (info-display-manual): Add existing Info buffers, whose |
| 4 | files may not be in Info-directory-list, to the completion. | 13 | files may not be in Info-directory-list, to the completion. |
| 5 | (info--manual-names): New helper function. | 14 | (info--manual-names): New helper function. |
diff --git a/lisp/ffap.el b/lisp/ffap.el index 4c75609fe01..00be6b91571 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el | |||
| @@ -181,7 +181,7 @@ Note this name may be omitted if it equals the default | |||
| 181 | ;; Could just use `url-nonrelative-link' of w3, if loaded. | 181 | ;; Could just use `url-nonrelative-link' of w3, if loaded. |
| 182 | ;; This regexp is not exhaustive, it just matches common cases. | 182 | ;; This regexp is not exhaustive, it just matches common cases. |
| 183 | (concat | 183 | (concat |
| 184 | "\\`\\(" | 184 | "\\(" |
| 185 | "news\\(post\\)?:\\|mailto:\\|file:" ; no host ok | 185 | "news\\(post\\)?:\\|mailto:\\|file:" ; no host ok |
| 186 | "\\|" | 186 | "\\|" |
| 187 | "\\(ftp\\|https?\\|telnet\\|gopher\\|www\\|wais\\)://" ; needs host | 187 | "\\(ftp\\|https?\\|telnet\\|gopher\\|www\\|wais\\)://" ; needs host |
| @@ -484,7 +484,7 @@ Returned values: | |||
| 484 | "In remote FULLNAME, replace path with NAME. May return nil." | 484 | "In remote FULLNAME, replace path with NAME. May return nil." |
| 485 | ;; Use efs if loaded, but do not load it otherwise. | 485 | ;; Use efs if loaded, but do not load it otherwise. |
| 486 | (if (fboundp 'efs-replace-path-component) | 486 | (if (fboundp 'efs-replace-path-component) |
| 487 | (funcall efs-replace-path-component fullname name) | 487 | (funcall 'efs-replace-path-component fullname name) |
| 488 | (and (stringp fullname) | 488 | (and (stringp fullname) |
| 489 | (stringp name) | 489 | (stringp name) |
| 490 | (concat (file-remote-p fullname) name)))) | 490 | (concat (file-remote-p fullname) name)))) |
| @@ -606,10 +606,11 @@ Looks at `ffap-ftp-default-user', returns \"\" for \"localhost\"." | |||
| 606 | 606 | ||
| 607 | (defsubst ffap-url-p (string) | 607 | (defsubst ffap-url-p (string) |
| 608 | "If STRING looks like an URL, return it (maybe improved), else nil." | 608 | "If STRING looks like an URL, return it (maybe improved), else nil." |
| 609 | (let ((case-fold-search t)) | 609 | (when (and (stringp string) ffap-url-regexp) |
| 610 | (and ffap-url-regexp (string-match ffap-url-regexp string) | 610 | (let* ((case-fold-search t) |
| 611 | ;; I lied, no improvement: | 611 | (match (string-match ffap-url-regexp string))) |
| 612 | string))) | 612 | (cond ((eq match 0) string) |
| 613 | (match (substring string match)))))) | ||
| 613 | 614 | ||
| 614 | ;; Broke these out of ffap-fixup-url, for use of ffap-url package. | 615 | ;; Broke these out of ffap-fixup-url, for use of ffap-url package. |
| 615 | (defun ffap-url-unwrap-local (url) | 616 | (defun ffap-url-unwrap-local (url) |
| @@ -1122,10 +1123,8 @@ Assumes the buffer has not changed." | |||
| 1122 | (equal (ffap-string-around) "<>") | 1123 | (equal (ffap-string-around) "<>") |
| 1123 | ;; (ffap-user-p name): | 1124 | ;; (ffap-user-p name): |
| 1124 | (not (string-match "~" (expand-file-name (concat "~" name))))) | 1125 | (not (string-match "~" (expand-file-name (concat "~" name))))) |
| 1125 | (setq name (concat "mailto:" name)))) | 1126 | (setq name (concat "mailto:" name))) |
| 1126 | 1127 | ((ffap-url-p name))))))) | |
| 1127 | (if (ffap-url-p name) | ||
| 1128 | name))))) | ||
| 1129 | 1128 | ||
| 1130 | (defvar ffap-gopher-regexp | 1129 | (defvar ffap-gopher-regexp |
| 1131 | "^.*\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *\\(.*\\) *$" | 1130 | "^.*\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *\\(.*\\) *$" |
| @@ -1297,13 +1296,11 @@ which may actually result in an URL rather than a filename." | |||
| 1297 | (let (dir) | 1296 | (let (dir) |
| 1298 | ;; Tricky: guess may have or be a local directory, like "w3/w3.elc" | 1297 | ;; Tricky: guess may have or be a local directory, like "w3/w3.elc" |
| 1299 | ;; or "w3/" or "../el/ffap.el" or "../../../" | 1298 | ;; or "w3/" or "../el/ffap.el" or "../../../" |
| 1300 | (or (ffap-url-p guess) | 1299 | (unless (ffap-url-p guess) |
| 1301 | (progn | 1300 | (unless (ffap-file-remote-p guess) |
| 1302 | (or (ffap-file-remote-p guess) | 1301 | (setq guess |
| 1303 | (setq guess | 1302 | (abbreviate-file-name (expand-file-name guess)))) |
| 1304 | (abbreviate-file-name (expand-file-name guess)) | 1303 | (setq dir (file-name-directory guess))) |
| 1305 | )) | ||
| 1306 | (setq dir (file-name-directory guess)))) | ||
| 1307 | (let ((minibuffer-completing-file-name t) | 1304 | (let ((minibuffer-completing-file-name t) |
| 1308 | (completion-ignore-case read-file-name-completion-ignore-case) | 1305 | (completion-ignore-case read-file-name-completion-ignore-case) |
| 1309 | (fnh-elem (cons ffap-url-regexp 'url-file-handler))) | 1306 | (fnh-elem (cons ffap-url-regexp 'url-file-handler))) |
| @@ -1327,11 +1324,8 @@ which may actually result in an URL rather than a filename." | |||
| 1327 | ;; other modifications to be lost (e.g. when Tramp gets loaded | 1324 | ;; other modifications to be lost (e.g. when Tramp gets loaded |
| 1328 | ;; during the completing-read call). | 1325 | ;; during the completing-read call). |
| 1329 | (setq file-name-handler-alist (delq fnh-elem file-name-handler-alist)))) | 1326 | (setq file-name-handler-alist (delq fnh-elem file-name-handler-alist)))) |
| 1330 | ;; Do file substitution like (interactive "F"), suggested by MCOOK. | 1327 | (or (ffap-url-p guess) |
| 1331 | (or (ffap-url-p guess) (setq guess (substitute-in-file-name guess))) | 1328 | (substitute-in-file-name guess)))) |
| 1332 | ;; Should not do it on url's, where $ is a common (VMS?) character. | ||
| 1333 | ;; Note: upcoming url.el package ought to handle this automatically. | ||
| 1334 | guess)) | ||
| 1335 | 1329 | ||
| 1336 | (defun ffap-read-url-internal (string pred action) | 1330 | (defun ffap-read-url-internal (string pred action) |
| 1337 | "Complete URLs from history, treating given string as valid." | 1331 | "Complete URLs from history, treating given string as valid." |
| @@ -1346,11 +1340,10 @@ which may actually result in an URL rather than a filename." | |||
| 1346 | (t t)))) | 1340 | (t t)))) |
| 1347 | 1341 | ||
| 1348 | (defun ffap-read-file-or-url-internal (string pred action) | 1342 | (defun ffap-read-file-or-url-internal (string pred action) |
| 1349 | (unless string ;Why would this ever happen? | 1343 | (let ((url (ffap-url-p string))) |
| 1350 | (setq string default-directory)) | 1344 | (if url |
| 1351 | (if (ffap-url-p string) | 1345 | (ffap-read-url-internal url pred action) |
| 1352 | (ffap-read-url-internal string pred action) | 1346 | (read-file-name-internal (or string default-directory) pred action)))) |
| 1353 | (read-file-name-internal string pred action))) | ||
| 1354 | 1347 | ||
| 1355 | ;; The rest of this page is just to work with package complete.el. | 1348 | ;; The rest of this page is just to work with package complete.el. |
| 1356 | ;; This code assumes that you load ffap.el after complete.el. | 1349 | ;; This code assumes that you load ffap.el after complete.el. |
| @@ -1441,30 +1434,31 @@ and the functions `ffap-file-at-point' and `ffap-url-at-point'." | |||
| 1441 | (let (current-prefix-arg) ; we already interpreted it | 1434 | (let (current-prefix-arg) ; we already interpreted it |
| 1442 | (call-interactively ffap-file-finder)) | 1435 | (call-interactively ffap-file-finder)) |
| 1443 | (or filename (setq filename (ffap-prompter))) | 1436 | (or filename (setq filename (ffap-prompter))) |
| 1444 | (cond | 1437 | (let ((url (ffap-url-p filename))) |
| 1445 | ((ffap-url-p filename) | 1438 | (cond |
| 1446 | (let (current-prefix-arg) ; w3 2.3.25 bug, reported by KPC | 1439 | (url |
| 1447 | (funcall ffap-url-fetcher filename))) | 1440 | (let (current-prefix-arg) |
| 1448 | ((and ffap-pass-wildcards-to-dired | 1441 | (funcall ffap-url-fetcher url))) |
| 1449 | ffap-dired-wildcards | 1442 | ((and ffap-pass-wildcards-to-dired |
| 1450 | (string-match ffap-dired-wildcards filename)) | 1443 | ffap-dired-wildcards |
| 1451 | (funcall ffap-directory-finder filename)) | 1444 | (string-match ffap-dired-wildcards filename)) |
| 1452 | ((and ffap-dired-wildcards | 1445 | (funcall ffap-directory-finder filename)) |
| 1453 | (string-match ffap-dired-wildcards filename) | 1446 | ((and ffap-dired-wildcards |
| 1454 | find-file-wildcards | 1447 | (string-match ffap-dired-wildcards filename) |
| 1455 | ;; Check if it's find-file that supports wildcards arg | 1448 | find-file-wildcards |
| 1456 | (memq ffap-file-finder '(find-file find-alternate-file))) | 1449 | ;; Check if it's find-file that supports wildcards arg |
| 1457 | (funcall ffap-file-finder (expand-file-name filename) t)) | 1450 | (memq ffap-file-finder '(find-file find-alternate-file))) |
| 1458 | ((or (not ffap-newfile-prompt) | 1451 | (funcall ffap-file-finder (expand-file-name filename) t)) |
| 1459 | (file-exists-p filename) | 1452 | ((or (not ffap-newfile-prompt) |
| 1460 | (y-or-n-p "File does not exist, create buffer? ")) | 1453 | (file-exists-p filename) |
| 1461 | (funcall ffap-file-finder | 1454 | (y-or-n-p "File does not exist, create buffer? ")) |
| 1462 | ;; expand-file-name fixes "~/~/.emacs" bug sent by CHUCKR. | 1455 | (funcall ffap-file-finder |
| 1463 | (expand-file-name filename))) | 1456 | ;; expand-file-name fixes "~/~/.emacs" bug sent by CHUCKR. |
| 1464 | ;; User does not want to find a non-existent file: | 1457 | (expand-file-name filename))) |
| 1465 | ((signal 'file-error (list "Opening file buffer" | 1458 | ;; User does not want to find a non-existent file: |
| 1466 | "no such file or directory" | 1459 | ((signal 'file-error (list "Opening file buffer" |
| 1467 | filename)))))) | 1460 | "no such file or directory" |
| 1461 | filename))))))) | ||
| 1468 | 1462 | ||
| 1469 | ;; Shortcut: allow {M-x ffap} rather than {M-x find-file-at-point}. | 1463 | ;; Shortcut: allow {M-x ffap} rather than {M-x find-file-at-point}. |
| 1470 | ;;;###autoload | 1464 | ;;;###autoload |
| @@ -1820,25 +1814,26 @@ If `dired-at-point-require-prefix' is set, the prefix meaning is reversed." | |||
| 1820 | (let (current-prefix-arg) ; already interpreted | 1814 | (let (current-prefix-arg) ; already interpreted |
| 1821 | (call-interactively ffap-directory-finder)) | 1815 | (call-interactively ffap-directory-finder)) |
| 1822 | (or filename (setq filename (dired-at-point-prompter))) | 1816 | (or filename (setq filename (dired-at-point-prompter))) |
| 1823 | (cond | 1817 | (let ((url (ffap-url-p filename))) |
| 1824 | ((ffap-url-p filename) | 1818 | (cond |
| 1825 | (funcall ffap-url-fetcher filename)) | 1819 | (url |
| 1826 | ((and ffap-dired-wildcards | 1820 | (funcall ffap-url-fetcher url)) |
| 1827 | (string-match ffap-dired-wildcards filename)) | 1821 | ((and ffap-dired-wildcards |
| 1828 | (funcall ffap-directory-finder filename)) | 1822 | (string-match ffap-dired-wildcards filename)) |
| 1829 | ((file-exists-p filename) | 1823 | (funcall ffap-directory-finder filename)) |
| 1830 | (if (file-directory-p filename) | 1824 | ((file-exists-p filename) |
| 1825 | (if (file-directory-p filename) | ||
| 1826 | (funcall ffap-directory-finder | ||
| 1827 | (expand-file-name filename)) | ||
| 1831 | (funcall ffap-directory-finder | 1828 | (funcall ffap-directory-finder |
| 1832 | (expand-file-name filename)) | 1829 | (concat (expand-file-name filename) "*")))) |
| 1833 | (funcall ffap-directory-finder | 1830 | ((and (file-writable-p |
| 1834 | (concat (expand-file-name filename) "*")))) | 1831 | (or (file-name-directory (directory-file-name filename)) |
| 1835 | ((and (file-writable-p | 1832 | filename)) |
| 1836 | (or (file-name-directory (directory-file-name filename)) | 1833 | (y-or-n-p "Directory does not exist, create it? ")) |
| 1837 | filename)) | 1834 | (make-directory filename) |
| 1838 | (y-or-n-p "Directory does not exist, create it? ")) | 1835 | (funcall ffap-directory-finder filename)) |
| 1839 | (make-directory filename) | 1836 | ((error "No such file or directory `%s'" filename)))))) |
| 1840 | (funcall ffap-directory-finder filename)) | ||
| 1841 | ((error "No such file or directory `%s'" filename))))) | ||
| 1842 | 1837 | ||
| 1843 | (defun dired-at-point-prompter (&optional guess) | 1838 | (defun dired-at-point-prompter (&optional guess) |
| 1844 | ;; Does guess and prompt step for find-file-at-point. | 1839 | ;; Does guess and prompt step for find-file-at-point. |
| @@ -1851,23 +1846,23 @@ If `dired-at-point-require-prefix' is set, the prefix meaning is reversed." | |||
| 1851 | (ffap-url-regexp "Dired file or URL: ") | 1846 | (ffap-url-regexp "Dired file or URL: ") |
| 1852 | (t "Dired file: ")) | 1847 | (t "Dired file: ")) |
| 1853 | (prog1 | 1848 | (prog1 |
| 1854 | (setq guess (or guess | 1849 | (setq guess |
| 1855 | (let ((guess (ffap-guesser))) | 1850 | (let ((guess (or guess (ffap-guesser)))) |
| 1856 | (if (or (not guess) | 1851 | (cond |
| 1857 | (ffap-url-p guess) | 1852 | ((null guess) nil) |
| 1858 | (ffap-file-remote-p guess)) | 1853 | ((ffap-url-p guess)) |
| 1859 | guess | 1854 | ((ffap-file-remote-p guess) |
| 1860 | (setq guess (abbreviate-file-name | 1855 | guess) |
| 1861 | (expand-file-name guess))) | 1856 | ((progn |
| 1862 | (cond | 1857 | (setq guess (abbreviate-file-name |
| 1863 | ;; Interpret local directory as a directory. | 1858 | (expand-file-name guess))) |
| 1864 | ((file-directory-p guess) | 1859 | ;; Interpret local directory as a directory. |
| 1865 | (file-name-as-directory guess)) | 1860 | (file-directory-p guess)) |
| 1866 | ;; Get directory component from local files. | 1861 | (file-name-as-directory guess)) |
| 1867 | ((file-regular-p guess) | 1862 | ;; Get directory component from local files. |
| 1868 | (file-name-directory guess)) | 1863 | ((file-regular-p guess) |
| 1869 | (guess)))) | 1864 | (file-name-directory guess)) |
| 1870 | )) | 1865 | (guess)))) |
| 1871 | (and guess (ffap-highlight)))) | 1866 | (and guess (ffap-highlight)))) |
| 1872 | (ffap-highlight t))) | 1867 | (ffap-highlight t))) |
| 1873 | 1868 | ||
| @@ -1916,22 +1911,17 @@ Only intended for interactive use." | |||
| 1916 | (defun ffap-guess-file-name-at-point () | 1911 | (defun ffap-guess-file-name-at-point () |
| 1917 | "Try to get a file name at point. | 1912 | "Try to get a file name at point. |
| 1918 | This hook is intended to be put in `file-name-at-point-functions'." | 1913 | This hook is intended to be put in `file-name-at-point-functions'." |
| 1919 | (when (fboundp 'ffap-guesser) | 1914 | (let ((guess (ffap-guesser))) |
| 1920 | ;; Logic from `ffap-read-file-or-url' and `dired-at-point-prompter'. | 1915 | (when (stringp guess) |
| 1921 | (let ((guess (ffap-guesser))) | 1916 | (let ((url (ffap-url-p guess))) |
| 1922 | (setq guess | 1917 | (or url |
| 1923 | (if (or (not guess) | 1918 | (progn |
| 1924 | (and (fboundp 'ffap-url-p) | 1919 | (unless (ffap-file-remote-p guess) |
| 1925 | (ffap-url-p guess)) | 1920 | (setq guess |
| 1926 | (and (fboundp 'ffap-file-remote-p) | 1921 | (abbreviate-file-name (expand-file-name guess)))) |
| 1927 | (ffap-file-remote-p guess))) | 1922 | (if (file-directory-p guess) |
| 1928 | guess | 1923 | (file-name-as-directory guess) |
| 1929 | (abbreviate-file-name (expand-file-name guess)))) | 1924 | guess))))))) |
| 1930 | (when guess | ||
| 1931 | (if (file-directory-p guess) | ||
| 1932 | (file-name-as-directory guess) | ||
| 1933 | guess))))) | ||
| 1934 | |||
| 1935 | 1925 | ||
| 1936 | ;;; Offer default global bindings (`ffap-bindings'): | 1926 | ;;; Offer default global bindings (`ffap-bindings'): |
| 1937 | 1927 | ||