]> git.eshelyaron.com Git - emacs.git/commitdiff
Reduce code duplication in webjump
authorStefan Kangas <stefankangas@gmail.com>
Wed, 25 Oct 2023 07:25:39 +0000 (09:25 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Wed, 25 Oct 2023 10:27:01 +0000 (12:27 +0200)
* lisp/net/webjump.el (webjump): Simplify.

lisp/net/webjump.el

index fe7c36798769a2b78ad2ef4a2642318461369d69..b377d0798ed94f1da14bab28c42eb3497d4b7ea9 100644 (file)
@@ -1,6 +1,6 @@
 ;;; webjump.el --- programmable Web hotlist  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 1996-1997, 2001-2023 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2023 Free Software Foundation, Inc.
 
 ;; Author:     Neil W. Van Dyke <nwv@acm.org>
 ;; Maintainer: emacs-devel@gnu.org
@@ -262,33 +262,22 @@ Please submit bug reports and other feedback to the author, Neil W. Van Dyke
                (completing-read "WebJump to site: " webjump-sites nil t)
                webjump-sites t))
         (name (car item))
-        (expr (cdr item)))
-    (if webjump-use-internal-browser
-        (browse-url-with-browser-kind
-         'internal (webjump-url-fix
-                    (cond ((not expr) "")
-                          ((stringp expr) expr)
-                          ((vectorp expr) (webjump-builtin expr name))
-                          ((listp expr) (eval expr t))
-                          ((symbolp expr)
-                           (if (fboundp expr)
-                               (funcall expr name)
-                             (error "WebJump URL function \"%s\" undefined"
-                                    expr)))
-                          (t (error "WebJump URL expression for \"%s\" invalid"
-                                    name)))))
-      (browse-url (webjump-url-fix
-                   (cond ((not expr) "")
-                         ((stringp expr) expr)
-                         ((vectorp expr) (webjump-builtin expr name))
-                         ((listp expr) (eval expr t))
-                         ((symbolp expr)
-                          (if (fboundp expr)
-                              (funcall expr name)
-                            (error "WebJump URL function \"%s\" undefined"
-                                   expr)))
-                         (t (error "WebJump URL expression for \"%s\" invalid"
-                                   name))))))))
+         (expr (cdr item))
+         (fun (if webjump-use-internal-browser
+                  (apply-partially #'browse-url-with-browser-kind 'internal)
+                #'browse-url)))
+    (funcall fun (webjump-url-fix
+                  (cond ((not expr) "")
+                        ((stringp expr) expr)
+                        ((vectorp expr) (webjump-builtin expr name))
+                        ((listp expr) (eval expr t))
+                        ((symbolp expr)
+                         (if (fboundp expr)
+                             (funcall expr name)
+                           (error "WebJump URL function \"%s\" undefined"
+                                  expr)))
+                        (t (error "WebJump URL expression for \"%s\" invalid"
+                                  name)))))))
 
 (defun webjump-builtin (expr name)
   (if (< (length expr) 1)