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 oM1uGTkInmEPBgAAgWs5BA (envelope-from ) for ; Wed, 24 Nov 2021 10:39:05 +0100 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 YB4hFTkInmHuBQAAB5/wlQ (envelope-from ) for ; Wed, 24 Nov 2021 09:39:05 +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 9837C3640F for ; Wed, 24 Nov 2021 10:39:04 +0100 (CET) Received: from localhost ([::1]:34778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpok3-0001aL-4v for larch@yhetil.org; Wed, 24 Nov 2021 04:39:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpohx-0007tK-J6 for emacs-orgmode@gnu.org; Wed, 24 Nov 2021 04:36:54 -0500 Received: from [2607:f8b0:4864:20::92a] (port=40513 helo=mail-ua1-x92a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mpohv-0008IP-Dz for emacs-orgmode@gnu.org; Wed, 24 Nov 2021 04:36:53 -0500 Received: by mail-ua1-x92a.google.com with SMTP id y5so3726428ual.7 for ; Wed, 24 Nov 2021 01:36:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=1pwnvbDGxHSIfv9zqOY0+JlMLvpUpQ16pA5mxX9Y8Po=; b=OHlpjFuaV8aVYM9p0P4icMJJvMit16FsfmXl8b4ML+vj/byW9wLjvZ3NRijWzygfV7 6uTQEitPIkRRBFgN2kMWgK9gGfmRFePZYqhEoNqfnbTM8hZW1238ekFBu8F/1B1bD1jB Nx3Y/wnlsOe9WADkss760ojW249nKFJZKRFSZGCmJeVOmVRsiFNXmouaR8MzWSq3N6cI x3bhyZ9Chwg1a12zcC95LBgxRzEWKvtchQ9zKRkIXCl+oKiF2Jj7EMJbiRtRvGwcFWEK ASu+yW7CHt5EVbz6M+3EqLspNXIAb6mlZuDi8ZryXFJ1idQmCyAUQw38In5V8CTWIY5v yBlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=1pwnvbDGxHSIfv9zqOY0+JlMLvpUpQ16pA5mxX9Y8Po=; b=0Qh905mXA/7sqJ8GdnrwVa5Np9vG5inY6G7XyHLXXCqSPoUVbN6/1l3a7nmNZBOtZG jzWBQuksT+wkev/rlzopQXoZ0LTdzoirwhXjtdnY+KcAzyafbyYRI75gzU9tW576f2M1 CNLcHVxcxDESIa9AcrkSVKAsVvMDxzhSap16ynmge/xK4BZd6e5zgcoRplcrhlV/GXRy wWSdC8mK+DTH/sTuWvV5B776IVNGUJIS+IYphrAzGRndqgbpMHeyuF24tkoFZkEhFpmO lJY+7JyEsoySlomq7mjFA48HKEJw6KKh2CKXZm01G16OHG9G8qM2SyHIL4fTUJnsAbVd vAtQ== X-Gm-Message-State: AOAM530mI/CDIleZKtX1JmkGje89pgW/wVpsky6g+uZdNTD/nHcMV+GV S+nIvXV+U4goq4wyNvR+cGcYhOccXBpTi8pxponn+BtkDp3SRA== X-Google-Smtp-Source: ABdhPJx69ZWwTX6MpJk3PY/+C1xjEmgziLBSKG0gw09uqWQnp3u0DrODZ5oTYwTGzSQO/6rONh6FD09omC3GZ6oRRBI= X-Received: by 2002:a67:ec10:: with SMTP id d16mr20536142vso.26.1637746608534; Wed, 24 Nov 2021 01:36:48 -0800 (PST) MIME-Version: 1.0 From: Shankar Rao Date: Wed, 24 Nov 2021 10:36:37 +0100 Message-ID: Subject: Unintended consequences of removing org-speed-commands-user To: emacs-orgmode@gnu.org Content-Type: text/plain; charset="UTF-8" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::92a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::92a; envelope-from=shankar.rao@gmail.com; helo=mail-ua1-x92a.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1637746744; 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:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=1pwnvbDGxHSIfv9zqOY0+JlMLvpUpQ16pA5mxX9Y8Po=; b=ei6jVieDETuyaIyl8f7SrM7Es+6lkkQeAnVWkdXCC/vzOL9qeF6oD9IyJl54uFtffag0Xp bmn1qARpLb54iAECVIYr+a3pzorw2fLPfRJ+O7qr2/hF2o3oMF3hGIykbgVMMFeFYoXPqE G3ayVWc5XgNHr37FcY4mV6sleC0PMIo5eq/oW9ksI8sdxkbCyUkY6MXIo0dO5YFeJaA4VF V0w6xoaTNye0faqNkXYDBseiTv8Q1z8iw0P5bQGvVvnjl4heH3G/4MbKr+sLtNEfVniqi/ viuXaPF/bdEf76rXLJLVTJ+iwfO94ArElIYs9lPAvaENvEzoWVHj5ZE3QQq5zg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1637746744; a=rsa-sha256; cv=none; b=qtHQE0zYLpvhx92oiatBI1b/siCObppmIMm2A2Hdgz7XMb9d3CDXcBpRzPHBSWD1THSJzd QmIcQzrY3SZ0d9LUdl/pF2pIirtHfSJkEkMOlo0Z/oMLW36CJv0L5DMsKAS8YG43iBDoi3 164v5PuEBekZJCUSdP5Ek+yYyC74EZDkU1+BXaxjC+vJxyAUsISHSH0UOgpAuswcCZdpLZ 15CLKE1kSLx3N+MYNL6D+6W3OKf6KeD/5dlY7kUfvSCEGTVuG2lZBsnQQco08GEEU15xoP sHDRnSq4tP/9LgFJIs1yfjHXWDBF5QIBSRqkJdyKIS5yImnRxazwZTk7hgwqZg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OHlpjFua; dmarc=pass (policy=none) header.from=gmail.com; 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: -4.09 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OHlpjFua; dmarc=pass (policy=none) header.from=gmail.com; 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: 9837C3640F X-Spam-Score: -4.09 X-Migadu-Scanner: scn1.migadu.com X-TUID: jFmZhugV5ugH Hello all, I discovered that upgrading to 9.5 broke my configuration because the variable `org-speed-commands-user' was removed. I read the thread (https://list.orgmode.org/87v9hzzhrn.fsf@gmail.com/) where this change was proposed and I completely agree that exposing the whole set of `org-speeds-commands' to the user for customization is an improvement over the previous state of affairs. However, I believe there were some unintended consequences of this change that can make it difficult to customize `org-speed-commands' for users that are not elisp gurus. The main problem is that `org-speed-commands' serves two purposes simultaneously: 1.) It contains all the mappings between speed keys and commands 2.) It contains headlines for command categories. Because of this second purpose, both the contents and order of entries in `org-speed-commands' are important. For example, suppose I want to replace the usual "n" command with my own. According to the usual conventions for alists (https://www.gnu.org/software/emacs/manual/html_node/elisp/Association-Lists.html), new associations such as this are added to the front of the list. But if I do so, by doing something like: (setq org-speed-commands (cons '("n" . #'my-org-next-heading) org-speed-commands)) Then the speed key "n" will show up twice when `org-speed-command-help' is invoked. I could first delete the old association by replacing `org-speed-commands' in the above with `(assoc-delete-all "n" org-speed-commands)', but then my modified command will no longer appear in the "Outline Navigation" section of the speed command help. Alternatively, I could replace the association for "n" using `alist-get': (setf (alist-get "n" org-speed-commands nil nil #'equal) #'my-org-next-heading) However, this solution won't work for new speed commands (e.g., if I want to bind `my-org-next-heading' to "N" instead), because in that case `alist-get' will return `nil'. Below is the relevant portion of my config file where I customize `org-speed-commands': ----- (defun alist-set (key value alist-symbol &optional testfn) "Set KEY to VALUE in alist referenced by ALIST-SYMBOL. If KEY is not present in the alist, then add (KEY. VALUE) to the front of the alist. Compare keys with TESTFN. Defaults to equal." (if-let ((keyval (assoc key (eval alist-symbol) testfn))) (setf (cdr keyval) value) (set alist-symbol (cons (cons key value) (eval alist-symbol))))) (defvar sbr-org-speed-commands-user '(("User Custom Speed Commands") ("N" . ded-org-show-next-heading-tidily) ("P" . ded-org-show-previous-heading-tidily) ("h" . sbr-org-speed-insert-subheading) ("u" . org-up-heading-or-item) ("b" . org-backward-heading-or-item) ("f" . org-forward-heading-or-item) ("p" . org-prev-heading-or-item) ("n" . org-next-heading-or-item)) "My custom Org speed commands") (dolist (keyval (reverse sbr-org-speed-commands-user)) (alist-set (car keyval) (cdr keyval) 'org-speed-commands)) ----- As you can see, I defined my own function `alist-set', which modifies an association in an alist if the key is already present, or adds the new association to the front of the list otherwise. In my opinion, functionality like `alist-set' should be built into Emacs itself. My code then constructs my own list of custom speed commands with its own section header and uses `alist-set' to add/modify speed commands. While this code works, it's a bit unsatisfying because 1.) It relies on my custom `alist-set' function 2.) It relies on knowledge of the structure of `org-speed-commands' More specifically, it requires that my new speed commands need to be inserted in reverse order into `org-speed-commands' in order to be displayed properly in `org-speed-commands-help'. I don't know what is the best solution to enable Org users to add and/or modify speed commands while also keeping the display of `org-speed-commands-help' organized. Here is what I propose: 1.) Keep the whole set of `org-speed-commands' exposed to user customization for power users 2.) Bring back `org-speed-commands-user', but instead of just appending it to `org-speed-commands' as was done prior to Org 9.5, use something like my `alist-set' above to add/modify speed command associations as needed while preserving the display order in `org-speed-commands-help'. With my proposal, Org users wouldn't have to concern themselves with the section headers in `org-speed-commands', but they would still be able to add/modify/remove commands as they wish. Let me know if anyone has a simpler alternative to achieve these goals. If there is sufficient interest in my proposal, I would be happy to provide a patch. Thanks, Shankar