mirror of
https://github.com/protesilaos/denote.git
synced 2026-09-10 07:16:20 -04:00
Make denote-link-description-with-signature-and-title return the active region even if empty
This commit is contained in:
parent
6a1e7a11d1
commit
eaa00f2fd4
11
README.org
11
README.org
|
|
@ -1745,11 +1745,12 @@ When ~denote-link~ is called with a prefix argument (=C-u= by
|
|||
default), it formats links like =[[denote:IDENTIFIER]]=. The user
|
||||
might prefer its simplicity.
|
||||
|
||||
The description of the link is taken from the target file's front
|
||||
matter or, if that is not available, from the file name. If the
|
||||
region is active, its text is used as the link's description instead.
|
||||
If the active region has no text, the inserted link uses just the
|
||||
identifier, as with the =C-u= prefix mentioned above.
|
||||
By default, the description of the link is taken from the signature of
|
||||
the file, if present, and the target file's front matter's title or, if
|
||||
that is not available, from the file name. If the region is active, its
|
||||
text is used as the link's description instead. If the active region
|
||||
has no text, the inserted link uses just the identifier, as with the
|
||||
=C-u= prefix mentioned above.
|
||||
|
||||
Inserted links are automatically buttonized and remain active for as
|
||||
long as the buffer is available. In Org this is handled by the major
|
||||
|
|
|
|||
13
denote.el
13
denote.el
|
|
@ -3204,16 +3204,16 @@ file is returned as the description.")
|
|||
(defun denote-link-description-with-signature-and-title (file region-text)
|
||||
"Return description from FILE as \"signature title\".
|
||||
|
||||
If REGION-TEXT is not empty (or nil), the description is the text
|
||||
of the active region instead.
|
||||
If REGION-TEXT is non-nil, the description is the text of the
|
||||
active region instead.
|
||||
|
||||
The format is specified in variable
|
||||
`denote--link-signature-format'. If a signature is not present,
|
||||
`denote--link-signature-format'. If a signature is not present,
|
||||
only the title is returned."
|
||||
(let* ((file-type (denote-filetype-heuristics file))
|
||||
(signature (denote-retrieve-filename-signature file))
|
||||
(title (denote--retrieve-title-or-filename file file-type)))
|
||||
(cond ((and region-text (not (string-empty-p region-text)))
|
||||
(cond (region-text
|
||||
region-text)
|
||||
(signature
|
||||
(format denote--link-signature-format signature title))
|
||||
|
|
@ -3257,7 +3257,10 @@ With optional ID-ONLY as a non-nil argument, such as with a
|
|||
universal prefix (\\[universal-argument]), insert links with just
|
||||
the identifier and no further description. In this case, the
|
||||
link format is always [[denote:IDENTIFIER]]. If the DESCRIPTION
|
||||
is empty, the link is also as if ID-ONLY were non-nil.
|
||||
is empty, the link is also as if ID-ONLY were non-nil. The
|
||||
default value of `denote-link-description-function' returns an
|
||||
empty string when the region is empty. Thus, the link will have
|
||||
no description in this case.
|
||||
|
||||
When called from Lisp, FILE is a string representing a full file
|
||||
system path. FILE-TYPE is a symbol as described in
|
||||
|
|
|
|||
Loading…
Reference in a new issue