From: Philip Kaludercic <philipk@posteo.net>
To: Jan Rehders <jan@sheijk.net>
Cc: emacs-devel@gnu.org
Subject: Re: Adding new package org-menu to nongnu elpa
Date: Fri, 15 Nov 2024 13:45:54 +0000 [thread overview]
Message-ID: <87jzd4ehkd.fsf@posteo.net> (raw)
In-Reply-To: <F4C06F55-0D0A-4F4C-B76B-35A071FA1A5E@sheijk.net> (Jan Rehders's message of "Thu, 14 Nov 2024 22:01:04 +0900")
[-- Attachment #1: Type: text/plain, Size: 359 bytes --]
Jan Rehders <jan@sheijk.net> writes:
> Hello,
Hi,
> I’d like to offer my package org-menu to be included in nongnu elpa. 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:
[-- Attachment #2: Type: text/plain, Size: 8717 bytes --]
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 -*- lexical-binding: t; coding: utf-8 -*-
+;;; org-menu.el --- A discoverable menu for org-mode using transient -*- lexical-binding: t -*-
;;
-;; Copyright 2021 Jan Rehders
+;; Copyright 2021 Jan Rehders
;;
;; Author: Jan Rehders <nospam@sheijk.net>
;; 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:
(require 'org)
@@ -52,27 +52,23 @@
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)
(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)
-(defcustom org-menu-expand-snippet-function 'org-menu-expand-snippet-default
+(defcustom org-menu-expand-snippet-function #'org-menu-expand-snippet-default
"The function used to expand a snippet.
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)
(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))
(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. `CYCLE-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 element."
#+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'?
-(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))
(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" 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}\"
+ (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 element."
#+attr_org: :width ${3:400px}
[[file:$2]]
"))
- (_
- (insert (format "unknown snippet type %s" snippet-id))))))
+ (_
+ (insert (format "unknown snippet type %s" snippet-id)))))
;; 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 element."
(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))))
@@ -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 before/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 of an issue, as org already uses cl-lib...)
(setq start (prog1 end (setq end start))))
(goto-char start)
@@ -582,14 +576,17 @@ the point will be at end of region. Will add spaces before/after text if
(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 (used below)
(interactive)
- (cond
- ((looking-back "")
- (backward-delete-char 1))
- ((looking-at "")
- (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)))))
(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' criteria if
(interactive)
(org-columns t))
+;; 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.
-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
(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) ;obsoletion warning!
["Archive to"
("t" "tree" org-archive-subtree :transient t)
("s" "sibling" org-archive-to-archive-sibling :transient t)
[-- Attachment #3: Type: text/plain, Size: 34 bytes --]
--
Philip Kaludercic on siskin
next prev parent reply other threads:[~2024-11-15 13:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-14 13:01 Adding new package org-menu to nongnu elpa Jan Rehders
2024-11-15 13:45 ` Philip Kaludercic [this message]
2024-11-15 16:20 ` Jan Rehders
2024-11-16 0:54 ` Philip Kaludercic
2024-11-16 6:30 ` Adam Porter
2024-11-17 14:02 ` Jan Rehders
2024-11-17 4:38 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87jzd4ehkd.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=emacs-devel@gnu.org \
--cc=jan@sheijk.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).