Use `called-interactively-p' instead of `interactive-p'.
[bpt/emacs.git] / lisp / net / quickurl.el
index 22794a4..8a7e73f 100644 (file)
@@ -1,6 +1,7 @@
 ;;; quickurl.el --- insert an URL based on text at point in buffer
 
-;; Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
 ;; Author: Dave Pearson <davep@davep.org>
 ;; Maintainer: Dave Pearson <davep@davep.org>
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; 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
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,9 +21,7 @@
 ;; GNU General Public License for more details.
 
 ;; 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.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 ;;
 (require 'pp)
 (require 'browse-url)
 
-;; Attempt to handle older/other emacs.
-(eval-and-compile
-  ;; If customize isn't available just use defvar instead.
-  (unless (fboundp 'defgroup)
-    (defmacro defgroup  (&rest rest) nil)
-    (defmacro defcustom (symbol init docstring &rest rest)
-      `(defvar ,symbol ,init ,docstring))))
-
 ;; Customize options.
 
 (defgroup quickurl nil
@@ -256,14 +247,16 @@ 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'."
@@ -298,14 +291,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)
@@ -374,7 +368,7 @@ is decided."
     (quickurl-load-urls)
     (let* ((current-url (quickurl-find-url word))
            (add-it      (if current-url
-                            (if (interactive-p)
+                            (if (called-interactively-p 'interactive)
                                 (y-or-n-p (format "\"%s\" exists, replace URL? " word))
                               t)
                           t)))
@@ -388,18 +382,19 @@ is decided."
         (quickurl-save-urls)
         (when (get-buffer quickurl-list-buffer-name)
           (quickurl-list-populate-buffer))
-        (when (interactive-p)
+        (when (called-interactively-p 'interactive)
           (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
@@ -454,7 +449,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))
 
@@ -549,4 +544,5 @@ TYPE dictates what will be inserted, options are:
 
 (provide 'quickurl)
 
+;; arch-tag: a8183ea5-80c2-4082-a7d1-b0fdf2da467e
 ;;; quickurl.el ends here