* [BUG] org-gnus-follow-link tries to select dead frame [9.8-pre (release_9.7.15-163-g3ff21c.dirty @ /home/bidar/.local/etc/emacs/lib/org/lisp/)]
@ 2025-01-20 23:21 Björn Bidar
0 siblings, 0 replies; only message in thread
From: Björn Bidar @ 2025-01-20 23:21 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1045 bytes --]
* Description
org-gnus-follow-link tries to select the Gnus frame if the user used
gnus-other-frame, the intention is to follow the previous action of the
user and now choose that Gnus frame too.
However it doesn't check if the frame is alive or not, resulting
in (wrong-type-argument frame-live-p #<frame>).
* Preconditions
- gnus-other-frame-object is a dead frame
* Steps to preproduce
1. Try to follow org-gnus link
2. Error
* Proposed change
Use the new org-link-frame-setup activate gnus-other-frame-object if
required.
The org-gnus-no-news function did not take care of if gnus should be
called directly of if should be called using the gnus-other-frame
function, i.e. when gnus-other-frame-object is set.
Take gnus-other-frame-object into account and call it if
gnus-other-frame-object is set or when the user chooses to do so
regardless. This ensures that gnus-other-frame-object always contains an
alive frame. The side effect is gnus-other-frame is used to ensure that
Gnus is called in the correct frame.
See attached patch.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Ensure-that-gnus-other-frame-object-is-alive-before-.patch --]
[-- Type: text/x-patch, Size: 3651 bytes --]
From 4f4936aba13fe2156d74465e3f4e8df857cc6754 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= <bjorn.bidar@thaodan.de>
Date: Tue, 21 Jan 2025 00:55:15 +0200
Subject: [PATCH] Ensure that gnus-other-frame-object is alive before selecting
* lisp/ol-gnus.el (org-gnus-follow-link): Ensure that
`gnus-other-frame-object' is active before selecting it.
Error out in case frame-object is dead, i.e. wasn't activated
by `org-link-frame-setup-function'.
(org-gnus-no-new-news): Take `gnus-other-frame-object' into account.
Call gnus-other-frame with chosen action instead without.
Ensures that previous behavior of `org-gnus-follow-link' is kept.
(org-gnus-no-new-news-other-frame): New function for users who choose
to call `gnus-other-frame' regardless if previous used or not.
* lisp/ol.el (org-link-frame-setup): Include
new `org-gnus-no-news-other-frame` function.
---
lisp/ol-gnus.el | 30 ++++++++++++++++++++++++------
lisp/ol.el | 4 +++-
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/lisp/ol-gnus.el b/lisp/ol-gnus.el
index 5cddc3790..65d77ea88 100644
--- a/lisp/ol-gnus.el
+++ b/lisp/ol-gnus.el
@@ -228,7 +228,12 @@ (defun org-gnus-follow-link (&optional group article)
"Follow a Gnus link to GROUP and ARTICLE."
(require 'gnus)
(funcall (org-link-frame-setup-function 'gnus))
- (when gnus-other-frame-object (select-frame gnus-other-frame-object))
+ (when gnus-other-frame-object
+ (if (not (frame-live-p gnus-other-frame-object))
+ ;; Error out in case org-link-frame-setup did not take care of setting up
+ ;; the gnus frame if was activate previously.
+ (error "Couldn't select \'gnus-other-frame-object\', make sure it is active"))
+ (select-frame gnus-other-frame-object))
(let ((group (org-no-properties group))
(article (org-no-properties article)))
(cond
@@ -260,11 +265,24 @@ (defun org-gnus-follow-link (&optional group article)
(message "Couldn't follow Gnus link. The linked group is empty."))))
(group (gnus-group-jump-to-group group)))))
-(defun org-gnus-no-new-news ()
- "Like `\\[gnus]' but doesn't check for new news."
- (cond ((gnus-alive-p) nil)
- (org-gnus-no-server (gnus-no-server))
- (t (gnus))))
+(defun org-gnus-no-new-news (&optional other-frame)
+ "Like `\\[gnus]' but doesn't check for new news.
+In case of OTHER-FRAME or `gnus-other-frame-object' call `gnus-other-frame'.
+
+Ensures that `gnus-other-frame' is activated correctly if dead."
+ (let ((action (cond (org-gnus-no-server #'gnus-no-server)
+ (t #'gnus))))
+ (cond ((or other-frame gnus-other-frame-object)
+ (let ((gnus-other-frame-function action)
+ (gnus-other-frame-resume-function action))
+ (gnus-other-frame)))
+ (t (if (not (gnus-alive-p))
+ (funcall action))))))
+
+(defun org-gnus-no-new-news-other-frame ()
+ "Like `org-gnus-no-new-news' but always in another frame."
+ (org-gnus-no-new-news t))
+
(provide 'ol-gnus)
diff --git a/lisp/ol.el b/lisp/ol.el
index 2365ca802..6cf3d92aa 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -348,6 +348,7 @@ (defcustom org-link-frame-setup
`gnus'
`gnus-other-frame'
`org-gnus-no-new-news'
+ `org-gnus-no-new-news-other-frame'
For FILE, use any of
`find-file'
`find-file-other-window'
@@ -374,7 +375,8 @@ (defcustom org-link-frame-setup
(choice
(const gnus)
(const gnus-other-frame)
- (const org-gnus-no-new-news)))
+ (const org-gnus-no-new-news)
+ (const org-gnus-no-new-news-other-frame)))
(cons (const file)
(choice
(const find-file)
--
2.45.2
[-- Attachment #3: Type: text/plain, Size: 8316 bytes --]
* Backtrace
Debugger entered--Lisp error: (wrong-type-argument frame-live-p #<dead frame *Group* • - Emacs 0x562b2cbc8c28>)
select-frame(#<dead frame *Group* • - Emacs 0x562b2cbc8c28>)
org-gnus-follow-link("nnimap+thaodan.de:Sent" "871pxrjqne.fsf@")
org-gnus-open("nnimap+thaodan.de:Sent#871pxrjqne.fsf@" nil)
funcall(org-gnus-open "nnimap+thaodan.de:Sent#871pxrjqne.fsf@" nil)
(condition-case nil (funcall f path arg) (wrong-number-of-arguments (funcall f path)))
(progn (condition-case nil (funcall f path arg) (wrong-number-of-arguments (funcall f path))))
(if (functionp f) (progn (condition-case nil (funcall f path arg) (wrong-number-of-arguments (funcall f path)))))
(let ((f (org-link-get-parameter type :follow))) (if (functionp f) (progn (condition-case nil (funcall f path arg) (wrong-number-of-arguments (funcall f path))))))
(let nil (let ((f (org-link-get-parameter type :follow))) (if (functionp f) (progn (condition-case nil (funcall f path arg) (wrong-number-of-arguments (funcall f path)))))))
(cond ((equal type '"file") (let nil (let* ((option (org-element--property :search-option link nil nil)) (path (if option (concat path "::" option) path))) (org-link-open-as-file path (let* ((val ...)) (cond (arg ...) (... ...) (... ...))))))) ((member type '("radio" "fuzzy" "custom-id" "coderef")) (let nil (if (run-hook-with-args-until-success 'org-open-link-functions path) nil (if (not arg) (org-mark-ring-push) (switch-to-buffer-other-window (org-link--buffer-for-internals))) (let ((destination (save-excursion ...))) (if (and (<= ... destination) (>= ... destination)) nil (widen)) (goto-char destination))))) (t (let nil (let ((f (org-link-get-parameter type :follow))) (if (functionp f) (progn (condition-case nil (funcall f path arg) (wrong-number-of-arguments ...))))))))
(let ((type (org-element--property :type link nil nil)) (path (org-element--property :path link nil nil))) (cond ((equal type '"file") (let nil (let* ((option (org-element--property :search-option link nil nil)) (path (if option ... path))) (org-link-open-as-file path (let* (...) (cond ... ... ...)))))) ((member type '("radio" "fuzzy" "custom-id" "coderef")) (let nil (if (run-hook-with-args-until-success 'org-open-link-functions path) nil (if (not arg) (org-mark-ring-push) (switch-to-buffer-other-window (org-link--buffer-for-internals))) (let ((destination ...)) (if (and ... ...) nil (widen)) (goto-char destination))))) (t (let nil (let ((f (org-link-get-parameter type :follow))) (if (functionp f) (progn (condition-case nil ... ...))))))))
org-link-open((link (:standard-properties [42406 nil 42453 42538 42540 0 nil nil nil nil nil nil nil nil #<buffer emacs.org> nil nil (paragraph (:standard-properties [42396 42396 42396 42541 42541 0 nil nil element t nil nil nil nil #<buffer emacs.org> nil nil (item ...)]))] :type "gnus" :type-explicit-p t :path "nnimap+thaodan.de:Sent#871pxrjqne.fsf@" :format bracket :raw-link "gnus:nnimap+thaodan.de:Sent#871pxrjqne.fsf@" :application nil :search-option nil)) nil)
(cond ((not type) (user-error "No link found")) ((memq type '(comment comment-block node-property keyword)) (call-interactively #'org-open-at-point-global)) ((memq type '(headline inlinetask)) (org-match-line org-complex-heading-regexp) (let ((tags-beg (match-beginning 5)) (tags-end (match-end 5))) (if (and tags-beg (>= (point) tags-beg) (< (point) tags-end)) (org-tags-view arg (save-excursion (let* (... ...) (buffer-substring ... ...)))) (let* ((val (org-offer-links-in-entry ... ... arg))) (if (consp val) (let* (...) (if ... ... ...))))))) ((or (eq type 'footnote-reference) (and (eq type 'footnote-definition) (save-excursion (skip-chars-forward " \11") (let ((begin ...)) (if begin (< ... begin) (= ... ...)))))) (org-footnote-action)) ((and (eq type 'planning) (org-in-regexp org-ts-regexp-both nil t)) (org-follow-timestamp-link)) ((and (eq type 'clock) value (>= (point) (org-element-begin value)) (<= (point) (org-element-end value))) (org-follow-timestamp-link)) ((eq type 'src-block) (org-babel-open-src-block-result)) ((>= (point) (save-excursion (goto-char (org-element-end context)) (skip-chars-backward " \11") (point))) (user-error "No link found")) ((eq type 'inline-src-block) (org-babel-open-src-block-result)) ((eq type 'timestamp) (org-follow-timestamp-link)) ((eq type 'link) (org-link-open context arg)) ((memq type '(citation citation-reference)) (org-cite-follow context arg)) (t (user-error "No link found")))
(let* ((context (org-element-lineage (org-element-context) '(citation citation-reference clock comment comment-block footnote-definition footnote-reference headline inline-src-block inlinetask keyword link node-property planning src-block timestamp) t)) (type (org-element-type context)) (value (org-element--property :value context nil nil))) (cond ((not type) (user-error "No link found")) ((memq type '(comment comment-block node-property keyword)) (call-interactively #'org-open-at-point-global)) ((memq type '(headline inlinetask)) (org-match-line org-complex-heading-regexp) (let ((tags-beg (match-beginning 5)) (tags-end (match-end 5))) (if (and tags-beg (>= (point) tags-beg) (< (point) tags-end)) (org-tags-view arg (save-excursion (let* ... ...))) (let* ((val ...)) (if (consp val) (let* ... ...)))))) ((or (eq type 'footnote-reference) (and (eq type 'footnote-definition) (save-excursion (skip-chars-forward " \11") (let (...) (if begin ... ...))))) (org-footnote-action)) ((and (eq type 'planning) (org-in-regexp org-ts-regexp-both nil t)) (org-follow-timestamp-link)) ((and (eq type 'clock) value (>= (point) (org-element-begin value)) (<= (point) (org-element-end value))) (org-follow-timestamp-link)) ((eq type 'src-block) (org-babel-open-src-block-result)) ((>= (point) (save-excursion (goto-char (org-element-end context)) (skip-chars-backward " \11") (point))) (user-error "No link found")) ((eq type 'inline-src-block) (org-babel-open-src-block-result)) ((eq type 'timestamp) (org-follow-timestamp-link)) ((eq type 'link) (org-link-open context arg)) ((memq type '(citation citation-reference)) (org-cite-follow context arg)) (t (user-error "No link found"))))
(if (run-hook-with-args-until-success 'org-open-at-point-functions) nil (let* ((context (org-element-lineage (org-element-context) '(citation citation-reference clock comment comment-block footnote-definition footnote-reference headline inline-src-block inlinetask keyword link node-property planning src-block timestamp) t)) (type (org-element-type context)) (value (org-element--property :value context nil nil))) (cond ((not type) (user-error "No link found")) ((memq type '(comment comment-block node-property keyword)) (call-interactively #'org-open-at-point-global)) ((memq type '(headline inlinetask)) (org-match-line org-complex-heading-regexp) (let ((tags-beg (match-beginning 5)) (tags-end (match-end 5))) (if (and tags-beg (>= ... tags-beg) (< ... tags-end)) (org-tags-view arg (save-excursion ...)) (let* (...) (if ... ...))))) ((or (eq type 'footnote-reference) (and (eq type 'footnote-definition) (save-excursion (skip-chars-forward " \11") (let ... ...)))) (org-footnote-action)) ((and (eq type 'planning) (org-in-regexp org-ts-regexp-both nil t)) (org-follow-timestamp-link)) ((and (eq type 'clock) value (>= (point) (org-element-begin value)) (<= (point) (org-element-end value))) (org-follow-timestamp-link)) ((eq type 'src-block) (org-babel-open-src-block-result)) ((>= (point) (save-excursion (goto-char (org-element-end context)) (skip-chars-backward " \11") (point))) (user-error "No link found")) ((eq type 'inline-src-block) (org-babel-open-src-block-result)) ((eq type 'timestamp) (org-follow-timestamp-link)) ((eq type 'link) (org-link-open context arg)) ((memq type '(citation citation-reference)) (org-cite-follow context arg)) (t (user-error "No link found")))))
org-open-at-point()
(let ((warning-suppress-types (cons '(org-element org-element-parser) warning-suppress-types))) (org-open-at-point))
org-open-at-mouse((mouse-2 (#<window 14035 on emacs.org> 42477 (524 . 1069) 2228637244 nil 42477 (43 . 34) nil (8 . 5) (12 . 26))))
funcall-interactively(org-open-at-mouse (mouse-2 (#<window 14035 on emacs.org> 42477 (524 . 1069) 2228637244 nil 42477 (43 . 34) nil (8 . 5) (12 . 26))))
command-execute(org-open-at-mouse)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-01-20 23:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-20 23:21 [BUG] org-gnus-follow-link tries to select dead frame [9.8-pre (release_9.7.15-163-g3ff21c.dirty @ /home/bidar/.local/etc/emacs/lib/org/lisp/)] Björn Bidar
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).