]> code.delx.au - gnu-emacs/blobdiff - lisp/net/quickurl.el
Merge from emacs--rel--22
[gnu-emacs] / lisp / net / quickurl.el
index 56b184af3b06b3b1dc3094499844d42b46405acd..f3da7b1164f2b4affa6b63cf0ce47a391dcb9cb9 100644 (file)
@@ -1,13 +1,14 @@
-;;; quickurl.el --- Insert an URL based on text at point in buffer.
+;;; quickurl.el --- insert an URL based on text at point in buffer
 
-;; Copyright (C) 1999,2000 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: Dave Pearson <davep@davep.org>
 ;; Maintainer: Dave Pearson <davep@davep.org>
 ;; Created: 1999-05-28
 ;; Keywords: hypermedia
 
-;; This file is part of GNU emacs.
+;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -21,8 +22,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 ;;
@@ -59,7 +60,7 @@
 ;; (("GNU"    . "http://www.gnu.org/")
 ;;  ("FSF"      "http://www.fsf.org/" "The Free Software Foundation")
 ;;  ("emacs"  . "http://www.emacs.org/")
-;;  ("hagbard"  "http://www.hagbard.demon.co.uk" "Hagbard's World"))
+;;  ("davep"    "http://www.davep.org/" "Dave's homepage"))
 ;;
 ;; In case you're wondering about the mixture of cons cells and lists,
 ;; quickurl started life using just the cons cells, there were no comments.
@@ -71,8 +72,7 @@
 ;;
 ;; quickurl is always available from:
 ;;
-;;   <URL:http://www.hagbard.demon.co.uk/archives/quickurl.el>
-;;   <URL:http://www.acemake.com/hagbard/archives/quickurl.el>
+;;   <URL:http://www.davep.org/emacs/quickurl.el>
 
 ;;; TODO:
 ;;
   :group  'abbrev
   :prefix "quickurl-")
 
-(defcustom quickurl-url-file "~/.quickurls"
+(defcustom quickurl-url-file (convert-standard-filename "~/.quickurls")
   "*File that contains the URL list."
   :type  'file
   :group 'quickurl)
@@ -257,15 +257,17 @@ returned."
 
 ;; Main code:
 
-(defun* quickurl-read (&optional (buffer (current-buffer)))
+(defun* quickurl-read (&optional buffer)
   "`read' the URL list from BUFFER into `quickurl-urls'.
 
+BUFFER, if nil, defaults to current buffer.
 Note that this function moves point to `point-min' before doing the `read'
 It also restores point after the `read'."
   (save-excursion
     (setf (point) (point-min))
-    (setq quickurl-urls (funcall quickurl-sort-function (read buffer)))))
-                       
+    (setq quickurl-urls (funcall quickurl-sort-function
+                                 (read (or buffer (current-buffer)))))))
+
 (defun quickurl-load-urls ()
   "Load the contents of `quickurl-url-file' into `quickurl-urls'."
   (when (file-exists-p quickurl-url-file)
@@ -281,7 +283,7 @@ It also restores point after the `read'."
       (pp quickurl-urls)
       (princ quickurl-postfix)
       (write-region (point-min) (point-max) quickurl-url-file nil 0))))
-  
+
 (defun quickurl-find-url (lookup)
   "Return URL associated with key LOOKUP.
 
@@ -299,14 +301,15 @@ Also display a `message' saying what the URL was unless SILENT is non-nil."
     (message "Found %s" (quickurl-url-url url))))
 
 ;;;###autoload
-(defun* quickurl (&optional (lookup (funcall quickurl-grab-lookup-function)))
+(defun* quickurl (&optional lookup)
   "Insert an URL based on LOOKUP.
 
 If not supplied LOOKUP is taken to be the word at point in the current
 buffer, this default action can be modifed via
 `quickurl-grab-lookup-function'."
   (interactive)
-  (when lookup
+  (when (or lookup
+            (setq lookup (funcall quickurl-grab-lookup-function)))
     (quickurl-load-urls)
     (let ((url (quickurl-find-url lookup)))
       (if (null url)
@@ -328,7 +331,7 @@ buffer, this default action can be modifed via
   (let ((url (quickurl-find-url lookup)))
     (when url
       (quickurl-insert url))))
-   
+
 (defun quickurl-grab-url ()
   "Attempt to grab a word/url pair from point in the current buffer.
 
@@ -371,7 +374,7 @@ is decided."
                        (read-string "URL: "     (quickurl-url-url word-url))
                        (read-string "Comment: " (quickurl-url-comment word-url)))))
   (if (zerop (length word))
-      (error "You must specify a WORD for lookup")  
+      (error "You must specify a WORD for lookup")
     (quickurl-load-urls)
     (let* ((current-url (quickurl-find-url word))
            (add-it      (if current-url
@@ -393,14 +396,15 @@ is decided."
           (message "Added %s" url))))))
 
 ;;;###autoload
-(defun* quickurl-browse-url (&optional (lookup (funcall quickurl-grab-lookup-function)))
+(defun quickurl-browse-url (&optional lookup)
   "Browse the URL associated with LOOKUP.
 
 If not supplied LOOKUP is taken to be the word at point in the
 current buffer, this default action can be modifed via
 `quickurl-grab-lookup-function'."
   (interactive)
-  (when lookup
+  (when (or lookup
+            (setq lookup (funcall quickurl-grab-lookup-function)))
     (quickurl-load-urls)
     (let ((url (quickurl-find-url lookup)))
       (if url
@@ -455,7 +459,7 @@ The key bindings for `quickurl-list-mode' are:
   (use-local-map quickurl-list-mode-map)
   (setq major-mode 'quickurl-list-mode
         mode-name  "quickurl list")
-  (run-hooks 'quickurl-list-mode-hook)
+  (run-mode-hooks 'quickurl-list-mode-hook)
   (setq buffer-read-only t
         truncate-lines   t))
 
@@ -483,8 +487,9 @@ The key bindings for `quickurl-list-mode' are:
             do (let ((start (point)))
                  (insert (format fmt (quickurl-url-description url)
                                  (quickurl-url-url url)))
-                 (put-text-property start (1- (point))
-                                    'mouse-face 'highlight)))
+                 (add-text-properties start (1- (point))
+                                    '(mouse-face highlight
+                                     help-echo "mouse-2: insert this URL"))))
       (setf (point) (point-min)))))
 
 (defun quickurl-list-add-url (word url comment)
@@ -546,7 +551,8 @@ TYPE dictates what will be inserted, options are:
 (quickurl-list-make-inserter with-lookup)
 (quickurl-list-make-inserter with-desc)
 (quickurl-list-make-inserter lookup)
-  
+
 (provide 'quickurl)
 
+;;; arch-tag: a8183ea5-80c2-4082-a7d1-b0fdf2da467e
 ;;; quickurl.el ends here