emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 71c366ba021 1/3: Reduce code duplication in webjump


From: Stefan Kangas
Subject: master 71c366ba021 1/3: Reduce code duplication in webjump
Date: Wed, 25 Oct 2023 06:31:06 -0400 (EDT)

branch: master
commit 71c366ba0216c0a551c9d02391d6565610019c63
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    Reduce code duplication in webjump
    
    * lisp/net/webjump.el (webjump): Simplify.
---
 lisp/net/webjump.el | 45 +++++++++++++++++----------------------------
 1 file changed, 17 insertions(+), 28 deletions(-)

diff --git a/lisp/net/webjump.el b/lisp/net/webjump.el
index fe7c3679876..b377d0798ed 100644
--- a/lisp/net/webjump.el
+++ b/lisp/net/webjump.el
@@ -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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]