From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id KIEfFPWAjWCwpQAAgWs5BA (envelope-from ) for ; Sat, 01 May 2021 18:25:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id oLTDD/WAjWA8aQAAB5/wlQ (envelope-from ) for ; Sat, 01 May 2021 16:25:25 +0000 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 9676114C89 for ; Sat, 1 May 2021 18:25:24 +0200 (CEST) Received: from localhost ([::1]:58666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcsQl-0007lx-NJ for larch@yhetil.org; Sat, 01 May 2021 12:25:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcsQ6-0007lo-9O for emacs-orgmode@gnu.org; Sat, 01 May 2021 12:24:42 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:45957) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcsQ6-0001Vv-2G; Sat, 01 May 2021 12:24:42 -0400 Received: from [2a01:e34:ec2b:7150:d6e0:9bd3:fb7e:77db] (port=45308 helo=guerry) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1lcsQ5-0006FJ-Pv; Sat, 01 May 2021 12:24:41 -0400 Received: by guerry (Postfix, from userid 1000) id 915651A60EE4; Sat, 1 May 2021 18:24:39 +0200 (CEST) From: Bastien To: Gustavo Barros Subject: Re: [Feature Request] More flexibility in org-speed-commands customization In-Reply-To: <87v9hzzhrn.fsf@gmail.com> (Gustavo Barros's message of "Mon, 03 Aug 2020 15:49:48 -0300") Organization: GNU References: <87v9hzzhrn.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) X-Woof-Patch: confirmed Date: Sat, 01 May 2021 18:24:39 +0200 Message-ID: <87v982a0c8.fsf@bzg.fr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1619886324; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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; bh=JnjeVYZqYxwX2JHvg7PgC/j0cVdqqv66S4aBbEP7FEc=; b=CuLMPH9kpw1aRo2N0LvXiMsiveLVWfFTfUefrxWOzAV3Qw/OIBt9tkfyZcYPg2nOMwaJUy JNYKfdtAznuzSS4H8/g0eNLgFdovHB5HF+0ZXWJhz/V2CMIZF6pJwyia4nN1P64hjr2dAt S1AL/NF5DFbjjrWV+enMjnCdFyam6s4sql79hogGPkvDbuqZh61z9rGYfHQFYDnWnYEsBD s/tK5CkF6EzBfRaqKh7IH5X65G/6yi/xkZ2bLElpy/Gs33p3iZA6Px0PyfVV0L9mq7ORHj ee1tTAsqWSDEBrkfaeBJJb0dcVgUQLoA1KAPYCZmCGS5MTiQk9lVhoYMDFl3mw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619886324; a=rsa-sha256; cv=none; b=sao6nqGeapMGgdha3QqXQJG5oZeRzI0rhwcBMAvNImyn/3Et7wLEQiEjEgXfxaTu16+pqP W4wEw/rwQ2dlYY60pAE6WsuT1fKizIPgBXf8aNJK7gOzWPcwzzM806yn8buYeuW4Wl+5mt YnEqyX/n/lH63WCc22n/ZRhGLjordIaAIngDNhPIXdpkcvL7FfNrZX60ixhtgRfugjrQU3 5GQ1zMmCoJzHS1IJGAtwpSkurCwnWCarF470pd5EpktLb15TY5kv6oUyCsVXG4oozoU6vn 2NBlU7TgPHHdYtu2m45ewP/C0QPJJrS1901LhgboqcRn921pPU/7jZah3UA1yg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.86 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 9676114C89 X-Spam-Score: -2.86 X-Migadu-Scanner: scn0.migadu.com X-TUID: t/dTLdaYE3LP --=-=-= Content-Type: text/plain Hi Gustavo, Gustavo Barros writes: > I don't know if there is a strong reason to hard-code the set of keys > in `org-speed-commands-default'. But, if there isn't, could you > consider (somehow) exposing the whole set of `org-speed-commands' to > user customization? Well, no, I don't see a strong reason to hard-code the set of speedy keys. See the attached patch, which proposes to use just one option `org-speed-commands'. This would be a breaking change, but I don't think we do otherwise. Would this suit your needs? What do you think about the change? -- Bastien --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=refactor-speed-commands.patch diff --git a/lisp/org-keys.el b/lisp/org-keys.el index 07ff85349..5da606b36 100644 --- a/lisp/org-keys.el +++ b/lisp/org-keys.el @@ -696,28 +696,6 @@ star at the beginning of the headline, you can do this: (const :tag "At beginning of headline stars" t) (function))) -(defcustom org-speed-commands-user nil - "Alist of additional speed commands. -This list will be checked before `org-speed-commands-default' -when the variable `org-use-speed-commands' is non-nil -and when the cursor is at the beginning of a headline. -The car of each entry is a string with a single letter, which must -be assigned to `self-insert-command' in the global map. -The cdr is either a command to be called interactively, a function -to be called, or a form to be evaluated. -An entry that is just a list with a single string will be interpreted -as a descriptive headline that will be added when listing the speed -commands in the Help buffer using the `?' speed command." - :group 'org-structure - :type '(repeat :value ("k" . ignore) - (choice :value ("k" . ignore) - (list :tag "Descriptive Headline" (string :tag "Headline")) - (cons :tag "Letter and Command" - (string :tag "Command letter") - (choice - (function) - (sexp)))))) - (defcustom org-speed-command-hook '(org-speed-command-activate org-babel-speed-command-activate) "Hook for activating speed commands at strategic locations. @@ -737,7 +715,7 @@ hook. The default setting is `org-speed-command-activate'." :version "24.1" :type 'hook) -(defconst org-speed-commands-default +(defcustom org-speed-commands '(("Outline Navigation") ("n" . (org-speed-move-safe 'org-next-visible-heading)) ("p" . (org-speed-move-safe 'org-previous-visible-heading)) @@ -762,8 +740,7 @@ hook. The default setting is `org-speed-command-activate'." ("l" . org-metaleft) ("R" . org-shiftmetaright) ("L" . org-shiftmetaleft) - ("i" . (progn (forward-char 1) (call-interactively - 'org-insert-heading-respect-content))) + ("i" . (progn (forward-char 1) (call-interactively 'org-insert-heading-respect-content))) ("^" . org-sort) ("w" . org-refile) ("a" . org-archive-subtree-default-with-confirmation) @@ -782,8 +759,7 @@ hook. The default setting is `org-speed-command-activate'." (":" . org-set-tags-command) ("e" . org-set-effort) ("E" . org-inc-effort) - ("W" . (lambda(m) (interactive "sMinutes before warning: ") - (org-entry-put (point) "APPT_WARNTIME" m))) + ("W" . (lambda (m) (interactive "sMinutes before warning: ") (org-entry-put (point) "APPT_WARNTIME" m))) ("Agenda Views etc") ("v" . org-agenda) ("/" . org-sparse-tree) @@ -792,7 +768,27 @@ hook. The default setting is `org-speed-command-activate'." ("?" . org-speed-command-help) ("<" . (org-agenda-set-restriction-lock 'subtree)) (">" . (org-agenda-remove-restriction-lock))) - "The default speed commands.") + "Alist of speed commands. + +The car of each entry is a string with a single letter, which +must be assigned to `self-insert-command' in the global map. + +The cdr is either a command to be called interactively, a +function to be called, or a form to be evaluated. + +An entry that is just a list with a single string will be +interpreted as a descriptive headline that will be added when +listing the speed commands in the Help buffer using the `?' speed +command." + :group 'org-structure + :type '(repeat :value ("k" . ignore) + (choice :value ("k" . ignore) + (list :tag "Descriptive Headline" (string :tag "Headline")) + (cons :tag "Letter and Command" + (string :tag "Command letter") + (choice + (function) + (sexp)))))) (defun org-print-speed-command (e) (if (> (length (car e)) 1) @@ -815,11 +811,8 @@ hook. The default setting is `org-speed-command-activate'." (unless org-use-speed-commands (user-error "Speed commands are not activated, customize `org-use-speed-commands'")) (with-output-to-temp-buffer "*Help*" - (princ "User-defined Speed commands\n===========================\n") - (mapc #'org-print-speed-command org-speed-commands-user) - (princ "\n") - (princ "Built-in Speed commands\n=======================\n") - (mapc #'org-print-speed-command org-speed-commands-default)) + (princ "Speed commands\n===========================\n") + (mapc #'org-print-speed-command org-speed-commands)) (with-current-buffer "*Help*" (setq truncate-lines t))) @@ -835,13 +828,11 @@ If not, return to the original position and throw an error." (defun org-speed-command-activate (keys) "Hook for activating single-letter speed commands. -`org-speed-commands-default' specifies a minimal command set. -Use `org-speed-commands-user' for further customization." +See `org-speed-commands' for configuring them." (when (or (and (bolp) (looking-at org-outline-regexp)) (and (functionp org-use-speed-commands) (funcall org-use-speed-commands))) - (cdr (assoc keys (append org-speed-commands-user - org-speed-commands-default))))) + (cdr (assoc keys org-speed-commands)))) ;;; Babel speed keys --=-=-=--