emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to hide *Org Links* buffer when insert new links?
@ 2021-05-16  5:23 Shiyao MA
  2021-05-31 12:54 ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Shiyao MA @ 2021-05-16  5:23 UTC (permalink / raw)
  To: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 183 bytes --]

Hi,

When insert org links with org-insert-link, an Org Links buffer is created.

How can I hide it?


An example image here:


https://i.stack.imgur.com/i69x8.png


-- 
Best,
Shiyao

[-- Attachment #2: Type: text/html, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to hide *Org Links* buffer when insert new links?
  2021-05-16  5:23 How to hide *Org Links* buffer when insert new links? Shiyao MA
@ 2021-05-31 12:54 ` Ihor Radchenko
  2021-09-25 16:18   ` Bastien
  0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2021-05-31 12:54 UTC (permalink / raw)
  To: Shiyao MA; +Cc: emacs-org list

[-- Attachment #1: Type: text/plain, Size: 1016 bytes --]

Shiyao MA <i@introo.me> writes:

> Hi,
>
> When insert org links with org-insert-link, an Org Links buffer is created.
>
> How can I hide it?

You cannot prevent it from being created. It is hard-coded. However, you
should be able to prevent Emacs from showing the buffer window by
modifying your display-buffer-alist:

(add-to-list 'display-buffer-alist '(("Org Links" display-buffer-no-window (allow-no-window . t))))

... except you cannot. Apparently, Org mode is being too aggressive and
ignores display-buffer-alist. I do not think that it is supposed to
happen. The patch fixing current aggressive behaviour and allowing the
above code to work is attached.

Dear All,

I do not think that unconditionally setting display-buffer-alist to nil
in org-no-popups macro is the right thing to do. I updated the macro
using pop-up-windows setting to nil instead of completely trashing
user-defined display-buffer-alist. The latter is nil by default and if
not, the user should know what he/she is doing.

Best,
Ihor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Do-not-ignore-user-defined-display-buffer-alist-in-o.patch --]
[-- Type: text/x-diff, Size: 2092 bytes --]

From c598f0208738f16b6d00c05a7338c226d15f5d12 Mon Sep 17 00:00:00 2001
Message-Id: <c598f0208738f16b6d00c05a7338c226d15f5d12.1622465359.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Mon, 31 May 2021 20:47:45 +0800
Subject: [PATCH] Do not ignore user-defined display-buffer-alist in
 org-insert-link

* lisp/ol.el (org-insert-link): Handle case when *Org Links* window is
not created.
* lisp/org-macs.el (org-no-popups): Do not override
`display-buffer-alist'. Use `pop-up-windows' instead.
---
 lisp/ol.el       | 13 +++++++------
 lisp/org-macs.el |  2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index a2cf872b8..ae0177695 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1856,12 +1856,13 @@ (defun org-insert-link (&optional complete-file link-location description)
 			     (reverse org-stored-links)
 			     "\n")))
 	(goto-char (point-min)))
-      (let ((cw (selected-window)))
-	(select-window (get-buffer-window "*Org Links*" 'visible))
-	(with-current-buffer "*Org Links*" (setq truncate-lines t))
-	(unless (pos-visible-in-window-p (point-max))
-	  (org-fit-window-to-buffer))
-	(and (window-live-p cw) (select-window cw)))
+      (when (get-buffer-window "*Org Links*" 'visible)
+        (let ((cw (selected-window)))
+	  (select-window (get-buffer-window "*Org Links*" 'visible))
+	  (with-current-buffer "*Org Links*" (setq truncate-lines t))
+	  (unless (pos-visible-in-window-p (point-max))
+	    (org-fit-window-to-buffer))
+	  (and (window-live-p cw) (select-window cw))))
       (setq all-prefixes (append (mapcar #'car abbrevs)
 				 (mapcar #'car org-link-abbrev-alist)
 				 (org-link-types)))
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index d56fc3bce..133960fea 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -170,7 +170,7 @@ (defmacro org-preserve-local-variables (&rest body)
 
 (defmacro org-no-popups (&rest body)
   "Suppress popup windows and evaluate BODY."
-  `(let (pop-up-frames display-buffer-alist)
+  `(let (pop-up-frames pop-up-windows)
      ,@body))
 
 \f
-- 
2.26.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to hide *Org Links* buffer when insert new links?
  2021-05-31 12:54 ` Ihor Radchenko
@ 2021-09-25 16:18   ` Bastien
  0 siblings, 0 replies; 3+ messages in thread
From: Bastien @ 2021-09-25 16:18 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Shiyao MA, emacs-org list

Hi Ihor,

Ihor Radchenko <yantar92@gmail.com> writes:

> I do not think that unconditionally setting display-buffer-alist to nil
> in org-no-popups macro is the right thing to do. I updated the macro
> using pop-up-windows setting to nil instead of completely trashing
> user-defined display-buffer-alist. The latter is nil by default and if
> not, the user should know what he/she is doing.

Applied, thanks.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-25 16:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-16  5:23 How to hide *Org Links* buffer when insert new links? Shiyao MA
2021-05-31 12:54 ` Ihor Radchenko
2021-09-25 16:18   ` Bastien

Code repositories for project(s) associated with this 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 NNTP newsgroup(s).