From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: Adding new package org-menu to nongnu elpa Date: Fri, 15 Nov 2024 13:45:54 +0000 Message-ID: <87jzd4ehkd.fsf@posteo.net> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7190"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Jan Rehders Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 15 14:47:04 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tBwf9-0001hz-OK for ged-emacs-devel@m.gmane-mx.org; Fri, 15 Nov 2024 14:47:03 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBweG-0000wf-FW; Fri, 15 Nov 2024 08:46:08 -0500 Original-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 1tBweD-0000wI-SW for emacs-devel@gnu.org; Fri, 15 Nov 2024 08:46:06 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBwe8-0002yM-Du for emacs-devel@gnu.org; Fri, 15 Nov 2024 08:46:05 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id BB920240101 for ; Fri, 15 Nov 2024 14:45:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1731678357; bh=7a1JtJcpGqA8yq06X/K1+RgwpfcEvGBo4bUFWSlFR+M=; h=From:To:Cc:Subject:Autocrypt:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:From; b=WPyhU6kRn1Yp5b6CQ5nj5f/ZN9JZ7vQrhdahLbkirTE/o/Bg+TRQitWQ4RVIO6cPl nujOc3JO9/jCUhxTQH7+8xNJ6Gjevh72OdiOQ/34fxmzBaRpTElXwlLRTKpQcFkIGq ius5ubk+P9ciqttY4u30TazUMFIWt7SdQFSeK42sZOAVgIV/fqwsZSWZ4W8hUNbFwu MVdeeFLyYI6bSagvVYpsBr3nLKo88zLURx3c6XCyqG5hkFppu2nSldDX5ziPpoaMuy tIp5DKKnw2mtFyVA1daai5uWZu0v175sxkPSa+R65pn/S2Rrz6TBmd6HF5fd61HLwX 7MmNRghjEyijQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4XqdZr5WC7z6tvk; Fri, 15 Nov 2024 14:45:56 +0100 (CET) In-Reply-To: (Jan Rehders's message of "Thu, 14 Nov 2024 22:01:04 +0900") Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM OpenPGP: id=philipk@posteo.net; url="https://keys.openpgp.org/vks/v1/by-email/philipk@posteo.net"; preference=signencrypt Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:325464 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jan Rehders writes: > Hello, Hi, > I=E2=80=99d like to offer my package org-menu to be included in nongnu el= pa. I believe it has enough users to warrant making it easier to install Popularity is no precondition for a package to be added to NonGNU ELPA. We can add the package, just consider the following comments and suggestions: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable diff --git a/org-menu.el b/org-menu.el index df82c18..f4f5066 100644 --- a/org-menu.el +++ b/org-menu.el @@ -1,6 +1,6 @@ -;;; org-menu.el --- A discoverable menu for org-mode using transient -*- l= exical-binding: t; coding: utf-8 -*- +;;; org-menu.el --- A discoverable menu for org-mode using transient -*- l= exical-binding: t -*- ;; -;; Copyright 2021 Jan Rehders +;; Copyright 2021 Jan Rehders ;; ;; Author: Jan Rehders ;; Version: 0.1alpha @@ -23,19 +23,19 @@ ;; Boston, MA 02111-1307, USA. ;; ;;; Commentary: -;; -;; Usage: -;; + +;;;; Usage: + ;; Add this to your ~/.emacs to bind the menu to `C-c m': ;; ;; (with-eval-after-load 'org ;; (require 'org-menu) ;; not needed if installing by package manager -;; (define-key org-mode-map (kbd "C-c m") 'org-menu)) +;; (define-key org-mode-map (kbd "C-c m") #'org-menu)) ;; ;; The menu should be pretty self-explanatory. It is context dependent and ;; offers different commands for headlines, tables, timestamps, etc. ;; The task menu provides entry points for task that work from anywhere. -;; + ;;; Code: =20 (require 'org) @@ -52,27 +52,23 @@ =20 Use this if you prefer to be consistent with magit. It will also change some other bindings to use Q instead of q." - :group 'org-menu :type 'boolean) =20 (defcustom org-menu-global-toc-depth 10 "The number of heading levels to show when displaying the global content= ." - :group 'org-menu - :type 'integer) + :type 'natnum) =20 -(defcustom org-menu-expand-snippet-function 'org-menu-expand-snippet-defau= lt +(defcustom org-menu-expand-snippet-function #'org-menu-expand-snippet-defa= ult "The function used to expand a snippet. =20 See `org-menu-expand-snippet-default' for a list of snippet ids which need to be supported. `org-menu-expand-snippet-yasnippet' shows how to invoke snippets." - :group 'org-menu :type 'function) =20 (defun org-menu-show-columns-view-options-p () "Return whether `org-columns' mode is active." - (and (boundp 'org-columns-overlays) - (not (null org-columns-overlays)))) + (bound-and-true-p org-columns-overlays)) =20 (defun org-menu-show-heading-options-p () "Whether to show commands operating on headings." @@ -109,8 +105,7 @@ Conditions have been adapted from `org-insert-link'" (unless (org-menu-show-columns-view-options-p) (or ;; Use variable from org-compat to support Emacs 26 - ;; this produces a warning in newer Emacs which we can't avoid - (org-in-regexp org-bracket-link-regexp 1) + (org-in-regexp (symbol-value 'org-bracket-link-regexp) 1) (when (boundp 'org-link-angle-re) (org-in-regexp org-link-angle-re)) (when (boundp 'org-link-plain-re) @@ -135,7 +130,7 @@ true the items will only be added if on a heading. `CY= CLE-FUNCTION' is the function to be used to cycle visibility of current element." (setq cycle-function (or cycle-function #'org-cycle)) `(["Navigate" - ,@(when check-for-heading '(:if org-menu-show-heading-options-p)) + ,@(and check-for-heading '(:if org-menu-show-heading-options-p)) ("p" "prev" org-previous-visible-heading :transient t) ("n" "next" org-next-visible-heading :transient t) ("c" "cycle" ,cycle-function :transient t) @@ -164,30 +159,30 @@ function to be used to cycle visibility of current el= ement." #+attr_org: :width 400px [[file:plot.svg]] ")) - (_ (insert (format "unknown snippet type %s" snippet-id))))) + (_ (insert (format "unknown snippet type %s" snippet-id))))) ;or use `= pcase-exhaustive'? =20 -(autoload 'yas-expand-snippet "yasnippet") -(autoload 'yas-expand-from-trigger-key "yasnippet") +;; You are require'ing yasnippet anyway, so there is no need to mess with = autoloads +(declare-function yas-expand-snippet "yasnippet" (snippet &optional start = end expand-env)) +(declare-function yas-expand-from-trigger-key "yasnippet" (&optional field= )) =20 (defun org-menu-expand-snippet-yasnippet (snippet-id) "Expand a yasnippet for each `SNIPPET-ID'." - (if (not (require 'yasnippet nil 'noerror)) - (message "error: yasnippet not installed, could not expand %s" snipp= et-id) - - (pcase snippet-id - ('block - (insert "beg") - (yas-expand-from-trigger-key)) - ('option - (insert "opt") - (yas-expand-from-trigger-key)) - ('subscript - (yas-expand-snippet "${1:text}_{${2:sub}}")) - ('superscript - (yas-expand-snippet "${1:text}^{${2:super}}")) - ('plot - (yas-expand-snippet - "#+plot: type:${1:2d} file:\"${2:plot.svg}\" + (unless (require 'yasnippet nil 'noerror) + (error "Yasnippet not installed, could not expand %s" snippet-id)) + (pcase snippet-id + ('block + (insert "beg") + (yas-expand-from-trigger-key)) + ('option + (insert "opt") + (yas-expand-from-trigger-key)) + ('subscript + (yas-expand-snippet "${1:text}_{${2:sub}}")) + ('superscript + (yas-expand-snippet "${1:text}^{${2:super}}")) + ('plot + (yas-expand-snippet + "#+plot: type:${1:2d} file:\"${2:plot.svg}\" | A | B | |---+----| | 1 | 10 | @@ -197,8 +192,8 @@ function to be used to cycle visibility of current elem= ent." #+attr_org: :width ${3:400px} [[file:$2]] ")) - (_ - (insert (format "unknown snippet type %s" snippet-id)))))) + (_ + (insert (format "unknown snippet type %s" snippet-id))))) =20 ;; If yasnippet gets loaded it will be used automatically (with-eval-after-load 'yasnippet @@ -214,7 +209,7 @@ function to be used to cycle visibility of current elem= ent." (interactive) (save-excursion (outline-hide-subtree) - (org-show-children 4) + (org-show-children 4) ;there is an obsoletion warning here! (org-goto-first-child) (org-reveal '(4)))) =20 @@ -541,7 +536,6 @@ Named `NAME' with `DEFINITION'." If region is active it will be surrounded by `LEFT' and `RIGHT' and the point will be at end of region. Will add spaces before/after text if `SURROUND-WHITESPACE' is true and it's needed." - (let ((start (point)) (end (point))) (when (region-active-p) @@ -549,7 +543,7 @@ the point will be at end of region. Will add spaces be= fore/after text if end (region-end)) (deactivate-mark)) (when (> start end) - ;; swap variables w/o importing cl-lib + ;; swap variables w/o importing cl-lib (this wouldn't be that much o= f an issue, as org already uses cl-lib...) (setq start (prog1 end (setq end start)))) =20 (goto-char start) @@ -582,14 +576,17 @@ the point will be at end of region. Will add spaces = before/after text if =20 (defun org-menu-toggle-nbspace () "Will remove non-breaking space before/after point or insert it if none = found." + ;; ^ + ;; Non-breaking or zero-width space? \u200b is zero-width (us= ed below) (interactive) - (cond - ((looking-back "=E2=80=8B") - (backward-delete-char 1)) - ((looking-at "=E2=80=8B") - (delete-char 1)) - (t - (insert "\u200b")))) + (let ((zww (eval-when-compile (string (char-from-name "ZERO WIDTH SPACE"= ))))) + (save-excursion + ;; By moving back first, we will avoid just removing the space + ;; before /or/ after as handled by the cond expression. + (skip-chars-backward zww) + (if (looking-at (rx (+ (literal zww)))) + (replace-match "") + (insert zww))))) =20 (defun org-menu-text-format-items (check-for-table) "Items to format text. @@ -704,12 +701,13 @@ Will add an ':if org-menu-show-text-options-p' criter= ia if (interactive) (org-columns t)) =20 +;; Can you explain why you are copying code org-colview.el? It is not +;; clear to me why you don't try to call it directly. +(declare-function org-agenda-do-context-action ()) (defun org-menu-columns-next () "Move into the next row when org-columns is active. =20 -Code copied from lambda in org-colview.el after - (org-defkey org-columns-map [down] -" +Code copied from lambda in org-colview.el from `org-columns-map'." (interactive) (let ((col (current-column))) (beginning-of-line 2) @@ -805,7 +803,7 @@ Code copied from lambda in org-colview.el after =20 (transient-insert-suffix 'org-menu-archive (list 0) `["Archive" - ,@(org-menu-heading-navigate-items nil #'org-force-cycle-archived) + ,@(org-menu-heading-navigate-items nil #'org-force-cycle-archived) ;ob= soletion warning! ["Archive to" ("t" "tree" org-archive-subtree :transient t) ("s" "sibling" org-archive-to-archive-sibling :transient t) --=-=-= Content-Type: text/plain -- Philip Kaludercic on siskin --=-=-=--