[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-remark 51c3d91585 11/75: refactor: create macro & m
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-remark 51c3d91585 11/75: refactor: create macro & menus |
Date: |
Fri, 6 Oct 2023 12:59:16 -0400 (EDT) |
branch: externals/org-remark
commit 51c3d91585ee12353f83b3ce9b823932f3f515ad
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
refactor: create macro & menus
The `org-remark-create` macro has been changed to include the
line-highlight pen. This means that if the user creates pens in their
init file and compile it, they would need to recompile it.
---
org-remark-line.el | 26 ++++++++++++++-----------
org-remark.el | 57 ++++++++++++++++++++++++++++++++----------------------
2 files changed, 49 insertions(+), 34 deletions(-)
diff --git a/org-remark-line.el b/org-remark-line.el
index 20100ea936..c436738321 100644
--- a/org-remark-line.el
+++ b/org-remark-line.el
@@ -5,7 +5,7 @@
;; Author: Noboru Ota <me@nobiot.com>
;; URL: https://github.com/nobiot/org-remark
;; Created: 01 August 2023
-;; Last modified: 03 August 2023
+;; Last modified: 04 August 2023
;; Package-Requires: ((emacs "27.1") (org "9.4"))
;; Keywords: org-mode, annotation, note-taking, marginal-notes, wp
@@ -28,7 +28,7 @@
;;; Code:
-;;(require 'org-remark)
+(require 'org-remark)
(defface org-remark-line-highlighter
'((((class color) (min-colors 88) (background light))
@@ -76,15 +76,19 @@ by `overlays-in'."
(set-window-margins nil 2)))
;;;###autoload
-(defun org-remark-mark-line (beg end &optional id mode)
- (interactive (org-remark-beg-end 'line))
- (org-remark-highlight-mark beg end id mode ;; LINE line function different
- ;; LINE needs to be the suffix of a
- ;; function: `org-remark-mark-'
- "line" nil ;; LINE important to put
- ;; the suffix of the label
- ;; to call this correct function
- (list 'org-remark-type 'line)))
+;; (defun org-remark-mark-line (beg end &optional id mode)
+;; (interactive (org-remark-beg-end 'line))
+;; (org-remark-highlight-mark beg end id mode ;; LINE line function
different
+;; ;; LINE needs to be the suffix of a
+;; ;; function: `org-remark-mark-'
+;; "line" nil ;; LINE important to put
+;; ;; the suffix of the label
+;; ;; to call this correct function
+;; (list 'org-remark-type 'line)))
+
+(org-remark-create "line"
+ 'org-remark-line-highlighter
+ '(org-remark-type line))
(cl-defmethod org-remark-beg-end ((org-remark-type (eql 'line)))
(let ((bol (org-remark-line-pos-bol (point))))
diff --git a/org-remark.el b/org-remark.el
index d395ef9a4d..84679aabcf 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -1,4 +1,4 @@
- ;;; org-remark.el --- Highlight & annotate any text files -*-
lexical-binding: t; -*-
+;;; org-remark.el --- Highlight & annotate any text files -*- lexical-binding:
t; -*-
;; Copyright (C) 2020-2023 Free Software Foundation, Inc.
@@ -6,7 +6,7 @@
;; URL: https://github.com/nobiot/org-remark
;; Version: 1.1.0
;; Created: 22 December 2020
-;; Last modified: 03 August 2023
+;; Last modified: 05 August 2023
;; Package-Requires: ((emacs "27.1") (org "9.4"))
;; Keywords: org-mode, annotation, note-taking, marginal-notes, wp,
@@ -198,7 +198,6 @@ add additional controls for the overlay properties")
;;;; Macros to create user-defined highlighter pen functions
-
(defmacro org-remark-create (label &optional face properties)
"Create and register new highlighter pen functions.
@@ -247,7 +246,8 @@ highlight. In this case, no new ID gets generated.
When the pen itself defines the help-echo property, it will have
the priority over the excerpt of the marginal notes."
(or face "`org-remark-highlighter'") properties)
- (interactive (org-remark-region-or-word))
+ (interactive (org-remark-beg-end
+ (quote ,(plist-get (eval properties)
'org-remark-type))))
(org-remark-highlight-mark beg end id mode ,label ,face ,properties))
;; Register to `org-remark-available-pens'
@@ -266,7 +266,9 @@ the priority over the excerpt of the marginal notes."
(lambda ()
(interactive)
(org-remark-change
- #',(intern (format "org-remark-mark-%s" label)))))))))
+ #',(intern (format "org-remark-mark-%s" label))))
+ :enable (org-remark-pen-same-type-at-point-p
+ (quote ,(plist-get (eval properties)
'org-remark-type))))))))
;;;; Minor mode
@@ -340,35 +342,42 @@ recommended to turn it on as part of Emacs initialization.
(define-key-after org-remark-menu-map
[org-remark-open]
'(menu-item "Open" org-remark-open
- :help "Display and move to marginal notes for highlight at
point"))
+ :help "Display and move to marginal notes for highlight at point"
+ :enable (org-remark-find-dwim)))
(define-key-after org-remark-menu-map
[org-remark-view]
'(menu-item "View" org-remark-view
- :help "Display marginal notes for highlight at point; stay in
current buffer"))
+ :help "Display marginal notes for highlight at point; stay in
current buffer"
+ :enable (org-remark-find-dwim)))
(define-key-after org-remark-menu-map
[org-remark-view-next]
- '(menu-item "View next" org-remark-view-next))
+ '(menu-item "View next" org-remark-view-next
+ :enable org-remark-highlights))
(define-key-after org-remark-menu-map
[org-remark-view-prev]
- '(menu-item "View previous" org-remark-view-prev))
+ '(menu-item "View previous" org-remark-view-prev
+ :enable org-remark-highlights))
(define-key-after org-remark-menu-map
[org-remark-toggle]
'(menu-item "Toggle" org-remark-toggle
- :help "Toggle showing/hiding of highlights in current buffer"))
+ :help "Toggle showing/hiding of highlights in current buffer"
+ :enable org-remark-highlights))
(define-key-after org-remark-menu-map
[org-remark-remove]
'(menu-item "Remove" org-remark-remove
- :help "Remove highlight at point, keeping the marginal notes
entry"))
+ :help "Remove highlight at point, keeping the marginal notes
entry"
+ :enable (org-remark-find-dwim)))
(define-key-after org-remark-menu-map
[org-remark-delete]
'(menu-item "Delete" org-remark-delete
- :help "Delete highlight at point and the marginal notes entry"))
+ :help "Delete highlight at point and the marginal notes entry"
+ :enable (org-remark-find-dwim)))
;; Make pen functions menu
(defvar org-remark-pen-map
@@ -384,15 +393,18 @@ recommended to turn it on as part of Emacs initialization.
(define-key-after org-remark-change-pen-map
[org-remark-change]
- '(menu-item "default pen" (lambda ()
- (interactive)
- (org-remark-change #'org-remark-mark))))
+ '(menu-item "default pen"
+ (lambda ()
+ (interactive)
+ (org-remark-change #'org-remark-mark))
+ :enable (org-remark-pen-same-type-at-point-p nil)))
;; Add change menu to the parent menu
(define-key-after org-remark-menu-map
[org-remark-change-pens]
- (list 'menu-item "Change to..." org-remark-change-pen-map)
- 'org-remark-toggle)
+ `(menu-item "Change to..." ,org-remark-change-pen-map
+ :enable (org-remark-find-dwim)
+ 'org-remark-toggle))
;; Add pen menu to the parent menu
(define-key org-remark-menu-map
@@ -404,6 +416,11 @@ recommended to turn it on as part of Emacs initialization.
[menu-bar org-remark]
(list 'menu-item "Org-remark" org-remark-menu-map))
+(defun org-remark-pen-same-type-at-point-p (org-remark-type)
+ "Return t if the highlight's type is the same as ORG-REMARK-TYPE."
+ (eql org-remark-type
+ (overlay-get (org-remark-find-dwim (point)) 'org-remark-type)))
+
;;;; Commands
@@ -1653,12 +1670,6 @@ If FILENAME is nil, return nil."
(with-current-buffer (find-file-noselect (org-remark-notes-get-file-name))
(funcall org-remark-source-file-name filename))))
-;; (defvar org-remark-beg-end-dwim-functions '(org-remark-region-or-word))
-
-;; (defun org-remark-beg-end-dwim ()
-;; (run-hook-with-args-until-success
-;; 'org-remark-beg-end-dwim-functions))
-
(cl-defgeneric org-remark-beg-end (_org-remark-type)
(org-remark-region-or-word))
- [elpa] externals/org-remark 15150c8d40 07/75: feat(line): highlight a whole line, (continued)
- [elpa] externals/org-remark 15150c8d40 07/75: feat(line): highlight a whole line, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark a2311005ff 08/75: fix(line): Ensure line hl ovs are always at bol, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 6b4c196f86 12/75: feat: icon for line highlight, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 3a9884e5df 26/75: fix(line): When buffer is first created, window may not be created, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 199702118a 30/75: fix(line): Disable line-mode should disable the margins, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 447fc2beaf 04/75: feat(line): highlight level headline text, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark ded8fddddd 01/75: initial prototype to explore what needs to change, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 0f2bf566ee 10/75: docs(info): source comments, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark f679d00c0a 06/75: refactor(line): loading and renaming the el file, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 2bba54b535 05/75: fix: selecting wrong highlight when opening, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 51c3d91585 11/75: refactor: create macro & menus,
ELPA Syncer <=
- [elpa] externals/org-remark ae376d860d 09/75: refactor(line): method name change, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 89ee82935c 14/75: fix: window margins do not persist, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 16958accc2 02/75: refactor: org-remark-mark, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark da73102a2d 19/75: fix(line): When source is narrowed line-hl moves the wrong place, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 79ad1baf7e 20/75: refactor(line): no need for text-scale-mode-hook, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 0829e27379 39/75: fix(line): redraw instead of reload when window size changes, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 4156342f88 40/75: refactor(line): make spacer overlay, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 9f86daaee6 43/75: feat(line):Redraw can now change the margin side, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark 175ba6d06e 44/75: fix(line):when line-icon is an image, it fails to carry face, ELPA Syncer, 2023/10/06
- [elpa] externals/org-remark a879b66013 59/75: docs: docstring for new auto-delete feature, ELPA Syncer, 2023/10/06