From ee57860915308dc9bf30172cfd94f8985b536361 Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Mon, 23 Dec 2024 11:59:16 +0530 Subject: [PATCH] Error if org-link-frame-setup is ill-defined * lisp/ol.el (org-link-frame-setup-function): Define new helper function get the frame-setup-function for the corresponding link-type. * lisp/ol-gnus.el (org-gnus-follow-link): * lisp/org.el (org-open-file): Use the new function to better inform the user when the user option `org-link-frame-setup-function' is ill-defined. Reported-by: Eric Fraga Link: https://list.orgmode.org/874j39vz29.fsf@ucl.ac.uk/ --- lisp/ol-gnus.el | 2 +- lisp/ol.el | 10 ++++++++++ lisp/org.el | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lisp/ol-gnus.el b/lisp/ol-gnus.el index b9ee8683f..2b20e80b2 100644 --- a/lisp/ol-gnus.el +++ b/lisp/ol-gnus.el @@ -227,7 +227,7 @@ (defun org-gnus-open (path _) (defun org-gnus-follow-link (&optional group article) "Follow a Gnus link to GROUP and ARTICLE." (require 'gnus) - (funcall (cdr (assq 'gnus org-link-frame-setup))) + (funcall (org-link-frame-setup-function)) (when gnus-other-frame-object (select-frame gnus-other-frame-object)) (let ((group (org-no-properties group)) (article (org-no-properties article))) diff --git a/lisp/ol.el b/lisp/ol.el index fa16b5920..102b68bab 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -1539,6 +1539,16 @@ (defun org-link-add-angle-brackets (s) (unless (equal (substring s -1) ">") (setq s (concat s ">"))) s) +(defun org-link-frame-setup-function (link-type) + "Return the frame setup function for the link type LINK-TYPE. +This signals an error if the value of the key LINK-TYPE in +`org-link-frame-setup' is not a function." + (let ((fun (cdr (assq link-type org-link-frame-setup)))) + (if (functionp fun) + fun + (error "The frame setup configuration `%S' for `%s' link type is ill-defined" + fun link-type)))) + ;;; Built-in link types diff --git a/lisp/org.el b/lisp/org.el index 2e91dd508..2c35bed5f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8489,7 +8489,7 @@ (defun org-open-file (path &optional in-emacs line search) (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait)))) ((or (stringp cmd) (eq cmd 'emacs)) - (funcall (cdr (assq 'file org-link-frame-setup)) file) + (funcall (org-link-frame-setup-function 'file) file) (widen) (cond (line (org-goto-line line) (when (derived-mode-p 'org-mode) (org-fold-reveal))) @@ -8517,7 +8517,7 @@ (defun org-open-file (path &optional in-emacs line search) ;; `org-file-apps' with sexp instead of a function for `cmd'. (user-error "Please see Org News for version 9.0 about \ `org-file-apps'--Error: Deprecated usage of %S" cmd)) - (t (funcall (cdr (assq 'file org-link-frame-setup)) file))) + (t (funcall (org-link-frame-setup-function 'file) file))) (funcall save-position-maybe))) ;;;###autoload -- 2.45.2