[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/ffap.el
From: |
Richard M. Stallman |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/ffap.el |
Date: |
Sat, 15 Feb 2003 14:26:25 -0500 |
Index: emacs/lisp/ffap.el
diff -c emacs/lisp/ffap.el:1.34 emacs/lisp/ffap.el:1.35
*** emacs/lisp/ffap.el:1.34 Mon Feb 10 17:21:46 2003
--- emacs/lisp/ffap.el Sat Feb 15 14:26:25 2003
***************
*** 80,90 ****
;;; Todo list:
;; * use kpsewhich
! ;; * let "/path/file#key" jump to key (tag or regexp) in /path/file
;; * find file of symbol if TAGS is loaded (like above)
;; * break long menus into multiple panes (like imenu?)
;; * notice node in "(dired)Virtual Dired" (quotes, parentheses, whitespace)
! ;; * notice "machine.dom blah blah blah path/file" (how?)
;; * as w3 becomes standard, rewrite to rely more on its functions
;; * regexp options for ffap-string-at-point, like font-lock (MCOOK)
;; * v19: could replace `ffap-locate-file' with a quieter `locate-library'
--- 80,90 ----
;;; Todo list:
;; * use kpsewhich
! ;; * let "/dir/file#key" jump to key (tag or regexp) in /dir/file
;; * find file of symbol if TAGS is loaded (like above)
;; * break long menus into multiple panes (like imenu?)
;; * notice node in "(dired)Virtual Dired" (quotes, parentheses, whitespace)
! ;; * notice "machine.dom blah blah blah dir/file" (how?)
;; * as w3 becomes standard, rewrite to rely more on its functions
;; * regexp options for ffap-string-at-point, like font-lock (MCOOK)
;; * v19: could replace `ffap-locate-file' with a quieter `locate-library'
***************
*** 124,149 ****
;; This used to test for ange-ftp or efs being present, but it should be
;; harmless (and simpler) to give it this value unconditionally.
"\\`/[^/:]+:"
! "*Paths matching this regexp are treated as remote ftp paths by ffap.
! If nil, ffap neither recognizes nor generates such paths."
:type '(choice (const :tag "Disable" nil)
(const :tag "Standard" "\\`/[^/:]+:")
regexp)
:group 'ffap)
(defcustom ffap-url-unwrap-local t
! "*If non-nil, convert `file:' url to local path before prompting."
:type 'boolean
:group 'ffap)
(defcustom ffap-url-unwrap-remote t
! "*If non-nil, convert `ftp:' url to remote path before prompting.
This is ignored if `ffap-ftp-regexp' is nil."
:type 'boolean
:group 'ffap)
(defcustom ffap-ftp-default-user "anonymous"
! "*User name in ftp paths generated by `ffap-host-to-path'.
Note this name may be omitted if it equals the default
\(either `efs-default-user' or `ange-ftp-default-user'\)."
:type 'string
--- 124,149 ----
;; This used to test for ange-ftp or efs being present, but it should be
;; harmless (and simpler) to give it this value unconditionally.
"\\`/[^/:]+:"
! "*File names matching this regexp are treated as remote ffap.
! If nil, ffap neither recognizes nor generates such names."
:type '(choice (const :tag "Disable" nil)
(const :tag "Standard" "\\`/[^/:]+:")
regexp)
:group 'ffap)
(defcustom ffap-url-unwrap-local t
! "*If non-nil, convert `file:' URL to local file name before prompting."
:type 'boolean
:group 'ffap)
(defcustom ffap-url-unwrap-remote t
! "*If non-nil, convert `ftp:' URL to remote file name before prompting.
This is ignored if `ffap-ftp-regexp' is nil."
:type 'boolean
:group 'ffap)
(defcustom ffap-ftp-default-user "anonymous"
! "*User name in ftp file names generated by `ffap-host-to-path'.
Note this name may be omitted if it equals the default
\(either `efs-default-user' or `ange-ftp-default-user'\)."
:type 'string
***************
*** 153,159 ****
;; Remote file access built into file system? HP rfa or Andrew afs:
"\\`/\\(afs\\|net\\)/."
;; afs only: (and (file-exists-p "/afs") "\\`/afs/.")
! "*Matching paths are treated as remote. nil to disable."
:type 'regexp
:group 'ffap)
--- 153,159 ----
;; Remote file access built into file system? HP rfa or Andrew afs:
"\\`/\\(afs\\|net\\)/."
;; afs only: (and (file-exists-p "/afs") "\\`/afs/.")
! "*Matching file names are treated as remote. Use nil to disable."
:type 'regexp
:group 'ffap)
***************
*** 434,440 ****
;;; Possibly Remote Resources:
! (defun ffap-replace-path-component (fullname name)
"In remote FULLNAME, replace path with NAME. May return nil."
;; Use ange-ftp or efs if loaded, but do not load them otherwise.
(let (found)
--- 434,440 ----
;;; Possibly Remote Resources:
! (defun ffap-replace-file-component (fullname name)
"In remote FULLNAME, replace path with NAME. May return nil."
;; Use ange-ftp or efs if loaded, but do not load them otherwise.
(let (found)
***************
*** 446,454 ****
ange-ftp-replace-name-component
))
(and found
! (fset 'ffap-replace-path-component found)
(funcall found fullname name))))
! ;; (ffap-replace-path-component "/address@hidden:/whatever" "/new")
(defun ffap-file-suffix (file)
"Return trailing `.foo' suffix of FILE, or nil if none."
--- 446,454 ----
ange-ftp-replace-name-component
))
(and found
! (fset 'ffap-replace-file-component found)
(funcall found fullname name))))
! ;; (ffap-replace-file-component "/address@hidden:/whatever" "/new")
(defun ffap-file-suffix (file)
"Return trailing `.foo' suffix of FILE, or nil if none."
***************
*** 485,496 ****
(defun ffap-file-remote-p (filename)
"If FILENAME looks remote, return it (maybe slightly improved)."
;; (ffap-file-remote-p "/address@hidden:/pub")
! ;; (ffap-file-remote-p "/cssun.mathcs.emory.edu://path")
;; (ffap-file-remote-p "/ffap.el:80")
(or (and ffap-ftp-regexp
(string-match ffap-ftp-regexp filename)
! ;; Convert "/host.com://path" to "/host:/path", to handle a dieing
! ;; practice of advertising ftp paths as "host.dom://path".
(if (string-match "//" filename)
;; (replace-match "/" nil nil filename)
(concat (substring filename 0 (1+ (match-beginning 0)))
--- 485,496 ----
(defun ffap-file-remote-p (filename)
"If FILENAME looks remote, return it (maybe slightly improved)."
;; (ffap-file-remote-p "/address@hidden:/pub")
! ;; (ffap-file-remote-p "/cssun.mathcs.emory.edu://dir")
;; (ffap-file-remote-p "/ffap.el:80")
(or (and ffap-ftp-regexp
(string-match ffap-ftp-regexp filename)
! ;; Convert "/host.com://dir" to "/host:/dir", to handle a dieing
! ;; practice of advertising ftp files as "host.dom://filename".
(if (string-match "//" filename)
;; (replace-match "/" nil nil filename)
(concat (substring filename 0 (1+ (match-beginning 0)))
***************
*** 505,511 ****
(let ((mach (ffap-string-at-point 'machine)))
(and (ffap-machine-p mach) mach)))
! (defsubst ffap-host-to-path (host)
"Convert HOST to something like \"/address@hidden:\" or \"/HOST:\".
Looks at `ffap-ftp-default-user', returns \"\" for \"localhost\"."
(if (equal host "localhost")
--- 505,511 ----
(let ((mach (ffap-string-at-point 'machine)))
(and (ffap-machine-p mach) mach)))
! (defsubst ffap-host-to-filename (host)
"Convert HOST to something like \"/address@hidden:\" or \"/HOST:\".
Looks at `ffap-ftp-default-user', returns \"\" for \"localhost\"."
(if (equal host "localhost")
***************
*** 518,524 ****
(concat "/" user (and user "@") host ":"))))
(defun ffap-fixup-machine (mach)
! ;; Convert a hostname into an url, an ftp path, or nil.
(cond
((not (and ffap-url-regexp (stringp mach))) nil)
;; gopher.well.com
--- 518,524 ----
(concat "/" user (and user "@") host ":"))))
(defun ffap-fixup-machine (mach)
! ;; Convert a hostname into an url, an ftp file name, or nil.
(cond
((not (and ffap-url-regexp (stringp mach))) nil)
;; gopher.well.com
***************
*** 528,534 ****
((and (string-match "\\`w\\(ww\\|eb\\)[-.]" mach))
(concat "http://" mach "/"))
;; More cases? Maybe "telnet:" for archie?
! (ffap-ftp-regexp (ffap-host-to-path mach))
))
(defvar ffap-newsgroup-regexp "^[a-z]+\\.[-+a-z_0-9.]+$"
--- 528,534 ----
((and (string-match "\\`w\\(ww\\|eb\\)[-.]" mach))
(concat "http://" mach "/"))
;; More cases? Maybe "telnet:" for archie?
! (ffap-ftp-regexp (ffap-host-to-filename mach))
))
(defvar ffap-newsgroup-regexp "^[a-z]+\\.[-+a-z_0-9.]+$"
***************
*** 580,586 ****
"Return URL as a remote file, or nil. Ignores `ffap-url-regexp'."
(and (string-match "\\`\\(ftp\\|file\\)://\\([^:/]+\\):?\\(/.*\\)" url)
(concat
! (ffap-host-to-path (substring url (match-beginning 2) (match-end 2)))
(substring url (match-beginning 3) (match-end 3)))))
;; Test: (ffap-url-unwrap-remote "ftp://foo.com/bar.boz")
--- 580,586 ----
"Return URL as a remote file, or nil. Ignores `ffap-url-regexp'."
(and (string-match "\\`\\(ftp\\|file\\)://\\([^:/]+\\):?\\(/.*\\)" url)
(concat
! (ffap-host-to-filename (substring url (match-beginning 2) (match-end
2)))
(substring url (match-beginning 3) (match-end 3)))))
;; Test: (ffap-url-unwrap-remote "ftp://foo.com/bar.boz")
***************
*** 596,605 ****
(url)))
! ;;; Path Handling:
;;
;; The upcoming ffap-alist actions need various utilities to prepare
! ;; and search paths of directories. Too many features here.
;; (defun ffap-last (l) (while (cdr l) (setq l (cdr l))) l)
;; (defun ffap-splice (func inlist)
--- 596,605 ----
(url)))
! ;;; File Name Handling:
;;
;; The upcoming ffap-alist actions need various utilities to prepare
! ;; and search directories. Too many features here.
;; (defun ffap-last (l) (while (cdr l) (setq l (cdr l))) l)
;; (defun ffap-splice (func inlist)
***************
*** 901,907 ****
(member (ffap-string-around) '("||" "|\n")))
(concat
;; lispdir.el may not be loaded yet:
! (ffap-host-to-path
(ffap-soft-value "elisp-archive-host"
"archive.cis.ohio-state.edu"))
(file-name-as-directory
--- 901,907 ----
(member (ffap-string-around) '("||" "|\n")))
(concat
;; lispdir.el may not be loaded yet:
! (ffap-host-to-filename
(ffap-soft-value "elisp-archive-host"
"archive.cis.ohio-state.edu"))
(file-name-as-directory
***************
*** 910,916 ****
(substring name 2))))
(defvar ffap-rfc-path
! (concat (ffap-host-to-path "ds.internic.net") "/rfc/rfc%s.txt"))
(defun ffap-rfc (name)
(format ffap-rfc-path
--- 910,916 ----
(substring name 2))))
(defvar ffap-rfc-path
! (concat (ffap-host-to-filename "ds.internic.net") "/rfc/rfc%s.txt"))
(defun ffap-rfc (name)
(format ffap-rfc-path
***************
*** 1077,1083 ****
;; Icky regexp avoids: default: 123: foo::bar cs:pub
;; It does match on: address@hidden: cs:/pub mathcs.emory.edu: (point at
end)
"\\`\\([^:@address@hidden:@]+:\\|address@hidden:]+\\.[^@:]+:\\|[^:]+:[~/]\\)\\([^:]\\|\\'\\)")
! "Strings matching this are coerced to ftp paths by ffap.
That is, ffap just prepends \"/\". Set to nil to disable.")
(defun ffap-file-at-point nil
--- 1077,1083 ----
;; Icky regexp avoids: default: 123: foo::bar cs:pub
;; It does match on: address@hidden: cs:/pub mathcs.emory.edu: (point at
end)
"\\`\\([^:@address@hidden:@]+:\\|address@hidden:]+\\.[^@:]+:\\|[^:]+:[~/]\\)\\([^:]\\|\\'\\)")
! "Strings matching this are coerced to ftp file names by ffap.
That is, ffap just prepends \"/\". Set to nil to disable.")
(defun ffap-file-at-point nil
***************
*** 1087,1093 ****
which may actually result in an url rather than a filename."
;; Note: this function does not need to look for url's, just
;; filenames. On the other hand, it is responsible for converting
! ;; a pseudo-url "site.com://path" to an ftp path
(let* ((case-fold-search t) ; url prefixes are case-insensitive
(data (match-data))
(string (ffap-string-at-point)) ; uses mode alist
--- 1087,1093 ----
which may actually result in an url rather than a filename."
;; Note: this function does not need to look for url's, just
;; filenames. On the other hand, it is responsible for converting
! ;; a pseudo-url "site.com://dir" to an ftp file name
(let* ((case-fold-search t) ; url prefixes are case-insensitive
(data (match-data))
(string (ffap-string-at-point)) ; uses mode alist
***************
*** 1115,1121 ****
;; Accept remote names without actual checking (too slow):
((if abs
(ffap-file-remote-p name)
! ;; Try adding a leading "/" (common omission in ftp paths):
(and
ffap-ftp-sans-slash-regexp
(string-match ffap-ftp-sans-slash-regexp name)
--- 1115,1121 ----
;; Accept remote names without actual checking (too slow):
((if abs
(ffap-file-remote-p name)
! ;; Try adding a leading "/" (common omission in ftp file names):
(and
ffap-ftp-sans-slash-regexp
(string-match ffap-ftp-sans-slash-regexp name)
***************
*** 1144,1150 ****
try))
;; Alist failed? Try to guess an active remote connection
;; from buffer variables, and try once more, both as an
! ;; absolute and relative path on that remote host.
((let* (ffap-rfs-regexp ; suppress
(remote-dir
(cond
--- 1144,1150 ----
try))
;; Alist failed? Try to guess an active remote connection
;; from buffer variables, and try once more, both as an
! ;; absolute and relative file name on that remote host.
((let* (ffap-rfs-regexp ; suppress
(remote-dir
(cond
***************
*** 1162,1171 ****
(or
(and (string-match "\\`\\(/?~?ftp\\)/" name)
(ffap-file-exists-string
! (ffap-replace-path-component
remote-dir (substring name (match-end 1)))))
(ffap-file-exists-string
! (ffap-replace-path-component remote-dir name))))))
)
(set-match-data data))))
--- 1162,1171 ----
(or
(and (string-match "\\`\\(/?~?ftp\\)/" name)
(ffap-file-exists-string
! (ffap-replace-file-component
remote-dir (substring name (match-end 1)))))
(ffap-file-exists-string
! (ffap-replace-file-component remote-dir name))))))
)
(set-match-data data))))