From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id wMjfBTjuO2YMDQAAe85BDQ:P1 (envelope-from ) for ; Wed, 08 May 2024 23:27:20 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id wMjfBTjuO2YMDQAAe85BDQ (envelope-from ) for ; Wed, 08 May 2024 23:27:20 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=LtT911Es; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1715203639; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=sThFinAhngMSxdE0WHVoEil1IgWwsVTExC6VW/7PEkU=; b=GzoRvTc4yJThachZlkN2mQibyBZOB16glzfxXFiKRwL9oMfVe0JieC0Xx8A7+QG/GUCE3+ hddaBs59ne+9Dzf/47Myff1bhuVtE1ARjvAtlSRixnsUVGlRwyu5vudVjkFtYMUXNw42Dm nDwTHnJJEIflaYFYSO1ZqErne48Fhyjf2HkMFBXahCuZBjziTzEsIoQhUVrKVkborW8c3p 1xM0DF7DyegFTUqFcesoko8Yh6wZBMBjwacGssez9AcD9Avkr/QYtq4dKcdnWVL4OO0aUH IJ78plxWgfNwTOKLAI7xv9bM+pP2gejQ4l87topZYJFPPAWCHnUA/+/cN7mh4w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=LtT911Es; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1715203639; a=rsa-sha256; cv=none; b=RcZgli9PiSwj7nOOgwZ6hHIA7cYAbhPj2+ZbvIUy16743pJgc4pg8BXvbhOkdbOK+RoXBD mjwOzH2J4n8b9bayvJ+S7Op+1zlutbRf0fFeYuNb42m7fJdS4A1M3mnzL8FIYou8f8Ww1w JgYNmLhuQmAW4114v0aNub1qKRrZzKB8VFQD+MEbpE3MXd2vlBVsido9CK64iskPKP+Fry 6x7zAlDzPsrEIpco5hti6TgSegA2u+hJLrb/FESx8a4Cq2Xtjmo/ZS45F9GG/kIxEX4P+L GuhrHHNz1q6j8Iwh85mu6sOid6xebC0uQtmJnkh92ZkyLmMWFlzfZ7VsEaXJTg== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C5B35E156 for ; Wed, 8 May 2024 23:27:19 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4onv-000330-Lg; Wed, 08 May 2024 17:26:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s4ont-00032S-4v for emacs-orgmode@gnu.org; Wed, 08 May 2024 17:26:21 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4onq-0002c4-Vz for emacs-orgmode@gnu.org; Wed, 08 May 2024 17:26:20 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-61c4ebd0c99so160943a12.0 for ; Wed, 08 May 2024 14:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715203576; x=1715808376; darn=gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :from:to:cc:subject:date:message-id:reply-to; bh=sThFinAhngMSxdE0WHVoEil1IgWwsVTExC6VW/7PEkU=; b=LtT911EsXj5Nu8tU0wrKfXUdv/tt/5zw/xOXrQdBwcCLXaMtDvmQBBJlRGe9rQ0ABO Ymu/tRpJqgbhGlrTODj4p79M/UVzQ67NRJ5cwKaDP1LS74G/72cTGJcwgSOkbYF0945x SZM4iICAYLSEotiZRr9q193NJsyPZNGuYbY6FnJEA6MMWU/4IsyDOTjJPDLXArBByA07 q+2rA2vak8X+OAsp4ugJB0ciFP9cDDPAAbPNRMPS9jv5LE3gOOK7xCx1EhMUIEn9B3wD Tuls2iZ1Xv1wngppLFnVYUX0RGgqVwPR1ADAu37IdEksg1+N1UF5novnbFxS972psbvw tXqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715203576; x=1715808376; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sThFinAhngMSxdE0WHVoEil1IgWwsVTExC6VW/7PEkU=; b=U0wiQlOuzrg1ImNfUaa48jE9DONlYhQTx1RHnJ8pdjoqVo95t/2lGLwj9jT2Tbd6IX JdG8HjdKxKdkHk8yhSvByiFu4769pAytSMWv8SGduNphApxz2/sd1jJP8GOU2PI5tKa4 +3Pb4fy/glWeSWjiXx8490axMPHSqk3/nvjX6ffAgpsXxKo2cCw4hc9lnCvGRBTMt6I4 YtAbu9vOeS8FGFMZxWHXmvEMnlyGL1LsSPGb7f4teZ0D41r0L+/Ihj6odAYV7H9/Olth j5a/2HeilQQSn/Oo9Jwd+RO3GqVRgoojD2kinlp4ddjKiOgt6iqFHaZCpK9dBMsvYJIz 80Hw== X-Forwarded-Encrypted: i=1; AJvYcCWBRhpkqYccl+ugj6cO4ZBEo6PlumtjeDR6a+TwkaCEfclbIUgsPNHMQHzXn1pFFMS2Wecrs1t3wPhZMSUIetoGU7z2T7k= X-Gm-Message-State: AOJu0Yw1d/UdIZOu0ngTzOWlIMQrbzNFEvneiS9rAJ/s50ZLTJJYrdyD xPL1FLbVW+XLuVtkqE42zGZkLJ3+Pr+hTFeT/H020IyX5w2A0dp85shaBQ== X-Google-Smtp-Source: AGHT+IEn3+6gSYsLukxGd1OgrSMn1+L7IcZaRX2cg7HWlNPiwZ76KlA/WUEs+aE6Yzg98lRY/vHlnQ== X-Received: by 2002:a17:90a:b113:b0:2b6:3034:4ae6 with SMTP id 98e67ed59e1d1-2b630344c2amr2960595a91.33.1715203576302; Wed, 08 May 2024 14:26:16 -0700 (PDT) Received: from storimasta ([2804:14c:5bb1:5200::3186]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2b67126ad88sm31339a91.27.2024.05.08.14.26.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 14:26:15 -0700 (PDT) From: Bruno Cardoso To: Max Nikulin , emacs-orgmode@gnu.org Subject: Re: [PATCH] Add support for shortdoc link type In-Reply-To: References: <87zftatdkr.fsf@gmail.com> <87v83xer0d.fsf@localhost> <87wmodtqxt.fsf@gmail.com> <875xvxs9hi.fsf@localhost> <87ttjhtjx1.fsf@gmail.com> <4b69d3b8-cfe7-4ba2-b9b5-872bcaeb6fe6@gmail.com> <87v83uefpd.fsf@gmail.com> <87h6fdeb3i.fsf@gmail.com> <9f6bbe0f-7cc2-4d55-a77d-331c8f71bb2c@gmail.com> <87y18ondrt.fsf@gmail.com> <938098de-6933-4668-85b0-fbfbc02dd949@gmail.com> <87v83pnm56.fsf@gmail.com> Date: Wed, 08 May 2024 18:26:12 -0300 Message-ID: <87seysnggb.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=cardoso.bc@gmail.com; helo=mail-pg1-x52e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -9.71 X-Migadu-Queue-Id: C5B35E156 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -9.71 X-TUID: DpxiJM/w9W8y --=-=-= Content-Type: text/plain On 2024-05-08, 18:20 +0700, Max Nikulin wrote: > 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? In Emacs-29 `shortdoc' is an alias for `shortdoc-display-group'. Interactvely, it prompts the user for a group from `shortdoc--groups' (that's what I meant by "all known groups"). I'm unsure if `shortdoc-display-group' behaves differently in Emacs-28. > Likely it is better to not allow empty group or function, so "+" instead > of "*" > > "\\`\\([^:]+\\)\\(?:::\\(.+\\)\\'\\)?" > > since 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. `shortdoc-display-group' already handles empty group or function. Replacing "*" by "+" will throw an "Args out of range" error in the corner case you mentioned ("shortdoc:::file"). So I think it's fine to keep "*" there. > 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 Noted. Thank you for all your comments and suggestions, Max! --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ol-support-for-shortdoc-link-type.patch ol.el: Add support for `shortdoc' link type * lisp/ol.el: Add support for storing and inserting links to `shortdoc' documentation groups for Emacs Lisp functions. * doc/org-manual.org (External Links): Add shortdoc link type documentation. * etc/ORG-NEWS (=ol.el=: Support for =shortdoc= link type): Document the new feature. --- diff --git a/doc/org-manual.org b/doc/org-manual.org index 1feb5ed60..8894f4231 100644 --- a/doc/org-manual.org +++ 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. + + For more information, see [[info:emacs#Name Help][Name Help]] + and [[info:elisp#Documentation Groups][Documentation Groups]]. + For =file:= and =id:= links, you can additionally specify a line number, or a text search string, separated by =::=. In Org files, you @@ -3423,6 +3432,8 @@ options: | irc | =irc:/irc.com/#emacs/bob= | | help | =help:org-store-link= | | info | =info:org#External links= | +| shortdoc | =shortdoc:text-properties= | +| | =shortdoc:text-properties::#get-pos-property= | | shell | =shell:ls *.org= | | elisp | =elisp:(find-file "Elisp.org")= (Elisp form to evaluate) | | | =elisp:org-agenda= (interactive Elisp command) | diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 99dd8839c..1623873c0 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -1405,6 +1405,11 @@ place the entry in the ~Misc~ category if ~TEXINFO_DIR_CATEGORY~ is missing. =TEXINFO_DIR_TITLE= is renamed to =TEXINFO_DIR_NAME=. The old name is obsolete. +*** =ol.el=: Support for =shortdoc= link type + +Add support for storing and inserting links to =shortdoc= documentation +groups for Emacs Lisp functions. + ** New functions and changes in function arguments *** New optional argument =UPDATE-HEADING= for ~org-bibtex-yank~ diff --git a/lisp/ol.el b/lisp/ol.el index bc9682e4a..928db29e1 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -1582,6 +1582,46 @@ PATH is a symbol name, as a string." :follow #'org-link--open-help :store #'org-link--store-help) +;;;; "shortdoc" link type +(when (version<= "28.0.90" emacs-version) + (defun org-link--open-shortdoc (path _) + "Open a \"shortdoc\" type link. +PATH is a group name, \"group::#function\" or \"group::search string\"." + (string-match "\\`\\([^:]*\\)\\(?:::\\(.*\\)\\'\\)?" path) + (let* ((group (match-string 1 path)) + (str (match-string 2 path)) + (fn (and str + (eq ?# (string-to-char str)) + (intern-soft (substring str 1))))) + (condition-case nil + (progn + (shortdoc-display-group group fn) + (and str (not fn) (search-forward str nil t))) + (user-error "Unknown shortdoc group: %s" group)))) + + (defun org-link--store-shortdoc (&optional _interactive?) + "Store \"shortdoc\" type link." + (when (eq major-mode 'shortdoc-mode) + (let* ((buffer (buffer-name)) + (group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer) + (match-string 1 buffer)))) + (if (and group (assoc (intern-soft group) shortdoc--groups)) + (org-link-store-props :type "shortdoc" + :link (format "shortdoc:%s" group) + :description nil) + (user-error "Unknown shortdoc group: %s" group))))) + + (defun org-link--complete-shortdoc () + "Create a \"shortdoc\" link using completion." + (concat "shortdoc:" + (completing-read "Shortdoc summary for functions in: " + (mapcar #'car shortdoc--groups)))) + + (org-link-set-parameters "shortdoc" + :follow #'org-link--open-shortdoc + :store #'org-link--store-shortdoc + :complete #'org-link--complete-shortdoc)) + ;;;; "http", "https", "mailto", "ftp", and "news" link types (dolist (scheme '("ftp" "http" "https" "mailto" "news")) (org-link-set-parameters scheme --=-=-=--