]> code.delx.au - gnu-emacs/blobdiff - lisp/ffap.el
* term.el (term-default-fg-color, term-default-bg-color): Fix custom type.
[gnu-emacs] / lisp / ffap.el
index a8455189cb92224e88c67ec6f5046080af71b8f3..98421936b96239e72830d615d05567e7ebc5cd9f 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ffap.el --- find file (or url) at point
 
-;; Copyright (C) 1995-1997, 2000-201 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1997, 2000-2013 Free Software Foundation, Inc.
 
 ;; Author: Michelangelo Grigni <mic@mathcs.emory.edu>
 ;; Maintainer: FSF
@@ -34,7 +34,7 @@
 ;; README's, MANIFEST's, and so on.  Submit bugs or suggestions with
 ;; M-x ffap-bug.
 ;;
-;; For the default installation, add this line to your .emacs file:
+;; For the default installation, add this line to your init file:
 ;;
 ;; (ffap-bindings)                      ; do default key bindings
 ;;
@@ -160,7 +160,7 @@ If the value is a list of strings, that specifies a list of URL
 schemes (e.g. \"ftp\"); in that case, only convert those URLs."
   :type '(choice (repeat string) boolean)
   :group 'ffap
-  :version "24.2")
+  :version "24.3")
 
 (defcustom ffap-ftp-default-user "anonymous"
   "User name in ftp file names generated by `ffap-host-to-path'.
@@ -206,7 +206,7 @@ Sensible values are nil, \"news\", or \"mailto\"."
 ;; those features interesting but not clear winners (a matter of
 ;; personal taste) I try to leave options to enable them.  Read
 ;; through this section for features that you like, put an appropriate
-;; enabler in your .emacs file.
+;; enabler in your init file.
 
 (defcustom ffap-dired-wildcards "[*?][^/]*\\'"
   "A regexp matching filename wildcard characters, or nil.
@@ -482,18 +482,12 @@ Returned values:
 
 (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)
-    (mapc
-     (function (lambda (sym) (and (fboundp sym) (setq found sym))))
-     '(
-       efs-replace-path-component
-       ange-ftp-replace-path-component
-       ange-ftp-replace-name-component
-       ))
-    (and found
-        (fset 'ffap-replace-file-component found)
-        (funcall found fullname name))))
+  ;; Use efs if loaded, but do not load it otherwise.
+  (if (fboundp 'efs-replace-path-component)
+      (funcall 'efs-replace-path-component fullname name)
+    (and (stringp fullname)
+        (stringp name)
+        (concat (file-remote-p fullname) name))))
 ;; (ffap-replace-file-component "/who@foo.com:/whatever" "/new")
 
 (defun ffap-file-suffix (file)
@@ -1698,10 +1692,12 @@ Only intended for interactive use."
       (set-window-dedicated-p win wdp))
     value))
 
-(defun ffap--toggle-read-only (buffer)
-  (with-current-buffer buffer
-    (with-no-warnings
-      (toggle-read-only 1))))
+(defun ffap--toggle-read-only (buffer-or-list)
+  (dolist (buffer (if (listp buffer-or-list)
+                     buffer-or-list
+                   (list buffer-or-list)))
+    (with-current-buffer buffer
+      (read-only-mode 1))))
 
 (defun ffap-read-only ()
   "Like `ffap', but mark buffer as read-only.
@@ -1710,8 +1706,7 @@ Only intended for interactive use."
   (let ((value (call-interactively 'ffap)))
     (unless (or (bufferp value) (bufferp (car-safe value)))
       (setq value (current-buffer)))
-    (mapc #'ffap--toggle-read-only
-         (if (listp value) value (list value)))
+    (ffap--toggle-read-only value)
     value))
 
 (defun ffap-read-only-other-window ()
@@ -1719,8 +1714,7 @@ Only intended for interactive use."
 Only intended for interactive use."
   (interactive)
   (let ((value (ffap-other-window)))
-    (mapc #'ffap--toggle-read-only
-         (if (listp value) value (list value)))
+    (ffap--toggle-read-only value)
     value))
 
 (defun ffap-read-only-other-frame ()
@@ -1728,8 +1722,7 @@ Only intended for interactive use."
 Only intended for interactive use."
   (interactive)
   (let ((value (ffap-other-frame)))
-    (mapc #'ffap--toggle-read-only
-         (if (listp value) value (list value)))
+    (ffap--toggle-read-only value)
     value))
 
 (defun ffap-alternate-file ()