New custom variable ~org-link-preview-include-descriptive~

This option, nil by default, allow you to toggle the internal variable
=include-linked= in function =org-link-preview=. So that user can
globally enable descriptive links previewing without always pressing
=[C-u 1]= to toggle the function parameter =include-linked=.

From cf7490a06372b07c4f42e63b564e7b5884506566 Mon Sep 17 00:00:00 2001
From: stardiviner <[email protected]>
Date: Wed, 26 Aug 2026 16:37:43 +0800
Subject: [PATCH] ol: Add new custom variable
 org-link-preview-include-descriptive

* lisp/ol.el (org-link-preview-include-descriptive): allow you to
toggle the internal variable `include-linked` in function
`org-link-preview`. So that user can globally enable descriptive links
previewing without always pressing [C-u 1] to toggle the function
parameter `include-linked`.
---
 etc/ORG-NEWS |  6 ++++++
 lisp/ol.el   | 16 ++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index db6637135..d485e5135 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -406,6 +406,12 @@ The option can be customized either by
 1. setting the global variable ~org-html-base-directory~
 2. setting the file local keyword =HTML_BASE_DIRECTORY=
 
+*** New custom variable ~org-link-preview-include-descriptive~
+
+This option, nil by default, allow you to toggle the internal variable
+=include-linked= in function =org-link-preview=. So that user can
+globally enable descriptive links previewing without always pressing
+=[C-u 1]= to toggle the function parameter =include-linked=.
 
 ** New functions and changes in function arguments
 
diff --git a/lisp/ol.el b/lisp/ol.el
index 3d0e32bcc..2389ea1b8 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -590,6 +590,13 @@ (defcustom org-link-preview-batch-size 6
   :type 'natnum
   :safe #'natnump)
 
+(defcustom org-link-preview-include-descriptive nil
+  "Whether globally toggle the internal var `include-linked' in `org-link-preview'."
+  :group 'org-link
+  :package-version '(Org . "10.0")
+  :type 'boolean
+  :safe #'booleanp)
+
 (defcustom org-display-remote-inline-images 'skip
   "How to display remote inline images.
 Possible values of this option are:
@@ -2177,10 +2184,11 @@ (defun org-link-preview (&optional arg beg end)
                        (list (region-beginning) (region-end))))
                org-mode)
   (let* ((include-linked
-          (cond
-           ((member arg '(nil (4) (16)) ) nil)
-           ((member arg '(1 11)) 'include-linked)
-           (t 'include-linked)))
+          (or (cond
+               ((member arg '(nil (4) (16)) ) nil)
+               ((member arg '(1 11)) 'include-linked)
+               (t 'include-linked))
+              org-link-preview-include-descriptive))
          (interactive? (called-interactively-p 'any))
          (toggle-previews
           (lambda (&optional beg end scope remove)
-- 
2.50.1 (Apple Git-155)

-- 

[ stardiviner ]
I try to make every word tell the meaning that I want to express without 
misunderstanding.

Blog: https://stardiviner.github.io/
IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

Attachment: signature.asc
Description: PGP signature

Reply via email to