;; (ffap-machine-p "mathcs" 5678 nil 'ping)
;; (ffap-machine-p "foo.bonk" nil nil 'ping)
;; (ffap-machine-p "foo.bonk.com" nil nil 'ping)
- (if (or (string-match "[^-[:alnum:].]" host) ; Illegal chars (?)
+ (if (or (string-match "[^-[:alnum:].]" host) ; Invalid chars (?)
(not (string-match "[^0-9]" host))) ; 1: a number? 2: quick reject
nil
(let* ((domain
("\\.bib\\'" . ffap-bib) ; search ffap-bib-path
("\\`\\." . ffap-home) ; .emacs, .bashrc, .profile
("\\`~/" . ffap-lcd) ; |~/misc/ffap.el.Z|
- ("^[Rr][Ff][Cc][- #]?\\([0-9]+\\)" ; no $
+ ;; This uses to have a blank, but ffap-string-at-point doesn't
+ ;; handle blanks.
+ ;; http://lists.gnu.org/archive/html/emacs-devel/2008-01/msg01058.html
+ ("^[Rr][Ff][Cc][-#]?\\([0-9]+\\)" ; no $
. ffap-rfc) ; "100% RFC2100 compliant"
(dired-mode . ffap-dired) ; maybe in a subdirectory
)
(ffap-locate-file name t ffap-bib-path))
(defun ffap-dired (name)
- (let ((pt (point)) dir try)
+ (let ((pt (point)) try)
(save-excursion
(and (progn
(beginning-of-line)
"/pub/gnu/emacs/elisp-archive/"))
(substring name 2))))
+(defcustom ffap-rfc-directories nil
+ "A list of directories to look for RFC files.
+If a given RFC isn't in these then `ffap-rfc-path' is offered."
+ :type '(repeat directory)
+ :version "23.1"
+ :group 'ffap)
+
(defvar ffap-rfc-path
(concat (ffap-host-to-filename "ftp.rfc-editor.org") "/in-notes/rfc%s.txt"))
(defun ffap-rfc (name)
- (format ffap-rfc-path
- (substring name (match-beginning 1) (match-end 1))))
+ (let ((num (match-string 1 name)))
+ (or (ffap-locate-file (format "rfc%s.txt" num) t ffap-rfc-directories)
+ (format ffap-rfc-path num))))
\f
;;; At-Point Functions:
(push fnh-elem file-name-handler-alist)
(unwind-protect
(setq guess
- (completing-read
- prompt
- 'ffap-read-file-or-url-internal
- dir
- nil
- (if dir (cons guess (length dir)) guess)
- (list 'file-name-history)
- (and buffer-file-name
- (abbreviate-file-name buffer-file-name))))
+ (let ((default-directory (if dir (expand-file-name dir)
+ default-directory)))
+ (completing-read
+ prompt
+ 'ffap-read-file-or-url-internal
+ nil
+ nil
+ (if dir (cons guess (length dir)) guess)
+ (list 'file-name-history)
+ (and buffer-file-name
+ (abbreviate-file-name buffer-file-name)))))
;; Remove the special handler manually. We used to just let-bind
;; file-name-handler-alist to preserve its value, but that caused
;; other modifications to be lost (e.g. when Tramp gets loaded
;; Note: upcoming url.el package ought to handle this automatically.
guess))
-(defun ffap-read-url-internal (string dir action)
+(defun ffap-read-url-internal (string pred action)
"Complete url's from history, treating given string as valid."
(let ((hist (ffap-soft-value "url-global-history-hash-table")))
(cond
((not action)
- (or (try-completion string hist) string))
+ (or (try-completion string hist pred) string))
((eq action t)
- (or (all-completions string hist) (list string)))
+ (or (all-completions string hist pred) (list string)))
;; action == lambda, documented where? Tests whether string is a
;; valid "match". Let us always say yes.
(t t))))
-(defun ffap-read-file-or-url-internal (string dir action)
- (unless dir
- (setq dir default-directory))
- (unless string
+(defun ffap-read-file-or-url-internal (string pred action)
+ (unless string ;Why would this ever happen?
(setq string default-directory))
(if (ffap-url-p string)
- (ffap-read-url-internal string dir action)
- (read-file-name-internal string dir action)))
+ (ffap-read-url-internal string pred action)
+ (read-file-name-internal string pred action)))
;; The rest of this page is just to work with package complete.el.
;; This code assumes that you load ffap.el after complete.el.
(x-popup-menu
t
(list "" (cons title
- (mapcar (function (lambda (i) (cons (car i) i)))
+ (mapcar (lambda (i) (cons (car i) i))
alist))))))
;; minibuffer with completion buffer:
(t
nil)))
(sit-for 0) ; redraw original screen
;; Convert string to its entry, or else the default:
- (setq choice (or (assoc choice alist) (car alist))))
- )
+ (setq choice (or (assoc choice alist) (car alist)))))
(if choice
(funcall cont choice)
(message "No choice made!") ; possible with menus
ffap-menu-text-plist)
(message "Scanning...%2d%% <%s>"
(/ (* 100 (- (point) (point-min))) range) item)))
- (or mod (set-buffer-modified-p nil))))
+ (or mod (restore-buffer-modified-p nil))))
(message "Scanning...done")
;; Remove duplicates.
(setq ffap-menu-alist ; sort by item
\f
-;;; arch-tag: 9dd3e88a-5dec-4607-bd57-60ae9ede8ebc
+;; arch-tag: 9dd3e88a-5dec-4607-bd57-60ae9ede8ebc
;;; ffap.el ends here