emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add support for shortdoc link type


From: Max Nikulin
Subject: Re: [PATCH] Add support for shortdoc link type
Date: Wed, 8 May 2024 18:20:05 +0700
User-agent: Mozilla Thunderbird

On 08/05/2024 08:11, Bruno Cardoso wrote:

The following now work as expected:

- [[shortdoc:string]]
- [[shortdoc:string::#try-completion]]
- [[shortdoc:string::identical contents]]

Thanks.

Bruno, the patch should have proper commit message, see
<https://orgmode.org/worg/org-contribute.html#commit-messages>

Some minor notes:

+++ b/doc/org-manual.org
@@ -3382,6 +3382,15 @@ Here is the full set of built-in link types:
Execute a shell command upon activation. +- =shortdoc= ::
+
+  Link to short documentation summary for an Emacs Lisp function group.
+  Since Emacs 28, user command ~shortdoc-display-group~ lists all known
+  documentation groups.
I have not managed to get all known groups with `shortdoc-display-group' in Emacs-28. Is it a feature of `shortdoc' in Emacs-29?

+    (string-match "\\`\\([^:]*\\)\\(?:::\\(.*\\).*\\'\\)?" path)

My bad. In
    "\\`\\([^:]*\\)\\(?:::#\\(.*\\).*\\'\\)?"
second .* was unnecessary, it survived from an earlier variant with \\| and \\' outside of the regex group.

Likely it is better to not allow empty group or function, so "+" instead of "*"

"\\`\\([^:]+\\)\\(?:::\\(.+\\)\\'\\)?"

since <shortdoc:::file> is hardly a valid link. However it might be search text link in the list of all groups (Emacs-29+ only?).

It is related to corner cases, so I do not insist.

+    (let* ((group (match-string 1 path))
+           (str (match-string 2 path))
+           (fn (when (and str (string-match "^#" str))
+                 (intern-soft (string-remove-prefix "#" str)))))

Nitpick, feel free to ignore:
- `when' is redundant here due to `and' inside its condition.
- `string-patch-p' would not affect match groups, so it is a bit cheaper.
- Since it is already known that first character is "#", `substring' instead of `string-remove-prefix' is an extra step in microoptimization

Untested: (fn (and str (eq ?# (string-to-char str)) (substring str 1)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]