On 2024-05-02, 17:41 +0700, Max Nikulin <maniku...@gmail.com> wrote:

> `condition-case' may help to avoid the internal `shortdoc--groups' 
> variable here. As to completion, it is better to ask for public API. 
> However emacs developers likely will decline such request.
>
> Consider the following just as ideas.
>
> - Support of search options. Buttons in help pages move point to 
> specific functions.
>
> <shortdoc:file::#find-file>
>
> - At first I considered adding shortdoc to help links that may call 
> either `describe-function' or `describe-variable', but it is unlikely 
> possible.

Hi Max,

Thanks for your suggestions. Indeed `condition-case' might be better there.

I implemented the search option by borrowing the regexp from `ol-info':

(defun org-link--open-shortdoc (path _)
  "Open a \"shortdoc\" type link.
PATH is a group name or \"group::#function\"."
  (string-match "\\`\\([^#:]*\\)\\(?:[#:]:?\\(.*\\)\\)?\\'" path)
  (let ((group (match-string 1 path))
        (fn (match-string 2 path)))
    (condition-case nil
        (progn
          (shortdoc-display-group group)
          (when fn
            (re-search-forward (concat "^(" (string-remove-prefix "#" fn))
                               nil t)
            (beginning-of-line)))
      (error (message "Unknown shortdoc group: %s" group)))))

It works, but I'm not quite sure if this is the best approach.

It curently matches all the cases below, as I got confused about the correct 
link syntax:

shortdoc:text-properties:get-pos-property
shortdoc:text-properties::get-pos-property
shortdoc:text-properties#get-pos-property
shortdoc:text-properties:#get-pos-property
shortdoc:text-properties::#get-pos-property


Best,

Bruno.

Reply via email to