[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-remark 4ee9e23e50 100/173: intrnl: refactor fn name
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-remark 4ee9e23e50 100/173: intrnl: refactor fn names |
Date: |
Fri, 28 Jan 2022 16:58:05 -0500 (EST) |
branch: externals/org-remark
commit 4ee9e23e5024660e1c2308e3fd493b44d25d4309
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
intrnl: refactor fn names
---
org-remark.el | 79 ++++++++++++++++++++++++++++++-----------------------------
1 file changed, 40 insertions(+), 39 deletions(-)
diff --git a/org-remark.el b/org-remark.el
index 46591c782d..043fa42e7c 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -5,7 +5,7 @@
;; Author: Noboru Ota <me@nobiot.com>
;; URL: https://github.com/nobiot/org-remark
;; Version: 0.0.7
-;; Last modified: 2022-01-03T191527
+;; Last modified: 2022-01-03T200655
;; Package-Requires: ((emacs "27.1") (org "9.4"))
;; Keywords: org-mode, annotation, writing, note-taking, marginal-notes
@@ -189,7 +189,7 @@ sorted in the ascending order; this is a property of the
variable
used for `org-remark-next' and `org-remark-prev'."
(or face "`org-remark-highlight'") properties)
(interactive "r")
- (org-remark-highlight beg end ,label ,face ,properties id)))
+ (org-remark-single-highlight-mark beg end ,label ,face ,properties id)))
;; Don't use category (symbol) as a property -- it's a special one of text
;; properties. If you use it, the value also need to be a symbol; otherwise,
you
@@ -257,11 +257,11 @@ in the current buffer. Each highlight is represented by
an overlay."
(file-name-sans-extension
(file-name-nondirectory (buffer-file-name))))))
(org-remark-housekeep)
- (org-remark-sort-highlights-list)
+ (org-remark-highlights-sort)
(dolist (h org-remark-highlights)
(let ((orgid (and org-remark-use-org-id
(org-entry-get (overlay-start h) "ID" 'INHERIT))))
- (org-remark-save-single-highlight h title source-path orgid)))
+ (org-remark-single-highlight-save h title source-path orgid)))
;; Tracking
(when org-remark-global-tracking-mode
(add-to-list 'org-remark-files-tracked
@@ -312,9 +312,9 @@ are not part of the undo tree."
(delete ov org-remark-highlights)
(delete-overlay ov)))
(org-remark-housekeep)
- (org-remark-sort-highlights-list)
+ (org-remark-highlights-sort)
;; Update the notes file accordingly
- (org-remark-remove-single-highlight id arg)
+ (org-remark-single-highlight-remove id arg)
t))
(defun org-remark-next ()
@@ -406,7 +406,8 @@ are still recorded in the marginalia file."
;;;;; Private
-(defun org-remark-highlight (beg end label face properties &optional id)
+(defun org-remark-single-highlight-mark
+ (beg end label face properties &optional id)
"Highlight the selected region between BEG and END.
This function performs the main work for the command created via
`org-remark-create-pen'.
@@ -451,9 +452,9 @@ passed. If so, no new ID gets generated."
(deactivate-mark)
(unless (buffer-modified-p) (restore-buffer-modified-p t))))
(org-remark-housekeep)
- (org-remark-sort-highlights-list))
+ (org-remark-highlights-sort))
-(defun org-remark-save-single-highlight (highlight title path orgid)
+(defun org-remark-single-highlight-save (highlight title path orgid)
"Save a single HIGHLIGHT in the notes file with properties.
The notes file is specified by PATH.
@@ -524,6 +525,30 @@ feature."
(insert (concat "[[file:" path "]" "[" title "]]"))))))
(when (buffer-modified-p) (save-buffer) t))))
+(defun org-remark-single-highlight-remove (id &optional delete-notes)
+ "Remove the highlight entry for ID for current buffer.
+By default, it deletes only the properties of the entry keeping
+the headline intact. You can pass DELETE-NOTES and delete the
+all notes of the entry."
+ (with-current-buffer (find-file-noselect org-remark-notes-file-path)
+ (org-with-wide-buffer
+ (when-let ((id-headline (org-find-property org-remark-prop-id id)))
+ (goto-char id-headline)
+ (org-narrow-to-subtree)
+ (dolist (prop (org-entry-properties))
+ (when (string-prefix-p "org-remark-" (downcase (car prop)))
+ (org-delete-property (car prop))))
+ ;; Backward compatible
+ (org-delete-property org-remark-prop-id)
+ (org-delete-property org-remark-prop-source-beg)
+ (org-delete-property org-remark-prop-source-end)
+ (when delete-notes
+ ;; TODO I would love to add the y-n prompt if there is any notes
written
+ (delete-region (point-min)(point-max))
+ (message "Deleted the marginal notes."))
+ (when (buffer-modified-p) (save-buffer))))
+ t))
+
(defun org-remark-notes-set-properties (id beg end &optional props)
"Set properties for the headline in the notes file.
Return t.
@@ -602,7 +627,7 @@ Each highlight is a list in the following structure:
highlights))))
highlights))))))
-(defun org-remark-list-highlights-positions (&optional reverse)
+(defun org-remark-highlights-get-positions (&optional reverse)
"Return list of beg points of highlights in this buffer.
By default, the list is in ascending order.
If REVERSE is non-nil, return list in the descending order.
@@ -629,8 +654,8 @@ If none, return nil."
(when list
(if reverse (reverse list) list)))))
-(defun org-remark-sort-highlights-list ()
- "Utility function to sort `org-remark-sort-highlights'.
+(defun org-remark-highlights-sort ()
+ "Utility function to sort `org-remark-highlights'.
It checks if there is any element exists for `org-remark-highlights'.
Instead of receiving it as an arg, it assumes its existence. It
also distructively updates `org-remark-highlights'.
@@ -645,7 +670,7 @@ It returns t when sorting is done."
(defun org-remark-find-next-highlight ()
"Return the beg point of the next highlight.
Look through `org-remark-highlights' list."
- (when-let ((points (org-remark-list-highlights-positions)))
+ (when-let ((points (org-remark-highlights-get-positions)))
;; Find the first occurance of p > (point). If none, this means all the
;; points occur before the current point. Take the first one. Assume
;; `org-remark-highlights' is sorted in the ascending order (it is).
@@ -654,7 +679,7 @@ Look through `org-remark-highlights' list."
(defun org-remark-find-prev-highlight ()
"Return the beg point of the previous highlight.
Look through `org-remark-highlights' list (in descending order)."
- (when-let ((points (org-remark-list-highlights-positions 'reverse)))
+ (when-let ((points (org-remark-highlights-get-positions 'reverse)))
;; Find the first occurance of p < (point). If none, this means all the
;; points occur before the current point. Take the first one. Assume
;; `org-remark-highlights' is sorted in the descending order .
@@ -687,30 +712,6 @@ the show/hide state."
(overlay-put highlight 'face (overlay-get highlight 'org-remark-face)))
t))
-(defun org-remark-remove-single-highlight (id &optional delete-notes)
- "Remove the highlight entry for ID for current buffer.
-By default, it deletes only the properties of the entry keeping
-the headline intact. You can pass DELETE-NOTES and delete the
-all notes of the entry."
- (with-current-buffer (find-file-noselect org-remark-notes-file-path)
- (org-with-wide-buffer
- (when-let ((id-headline (org-find-property org-remark-prop-id id)))
- (goto-char id-headline)
- (org-narrow-to-subtree)
- (dolist (prop (org-entry-properties))
- (when (string-prefix-p "org-remark-" (downcase (car prop)))
- (org-delete-property (car prop))))
- ;; Backward compatible
- (org-delete-property org-remark-prop-id)
- (org-delete-property org-remark-prop-source-beg)
- (org-delete-property org-remark-prop-source-end)
- (when delete-notes
- ;; TODO I would love to add the y-n prompt if there is any notes
written
- (delete-region (point-min)(point-max))
- (message "Deleted the marginal notes."))
- (when (buffer-modified-p) (save-buffer))))
- t))
-
(defun org-remark-housekeep ()
"Housekeep the internal variable `org-remark-highlights'.
This is a private function; housekeep is automatically done on
@@ -732,7 +733,7 @@ Case 2. The overlay points to no buffer
;; when you delete a region that contains a highlight overlay.
(when (and (overlay-buffer ov)
(= (overlay-start ov) (overlay-end ov)))
- (org-remark-remove-single-highlight (overlay-get ov 'org-remark-id))
+ (org-remark-single-highlight-remove (overlay-get ov 'org-remark-id))
(delete-overlay ov))
(unless (overlay-buffer ov)
(setq org-remark-highlights (delete ov org-remark-highlights))))
- [elpa] externals/org-remark 60cbbc4e99 083/173: Merge dev/0.0.6-revise, (continued)
- [elpa] externals/org-remark 60cbbc4e99 083/173: Merge dev/0.0.6-revise, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 2d11de2ec2 085/173: docs: README, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 3037be5ebc 087/173: docs: update README with global-tracking-mode, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark b988d580d8 090/173: add: Create pen to have different colors, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 02d7b56265 088/173: fix: tracking does not save for the first file, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 7242c83d8f 094/173: copyright year, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark f988330790 091/173: add: make-pen props work as intended, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark bdbde4eda8 093/173: refactor: macro to make different pen, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark b3a8e3e2ec 097/173: add: Org-HANA: Org to Highlight & ANnotate Any text file (HANA), ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark f7e796cd6b 095/173: chg: don't update headline text; various refactors, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 4ee9e23e50 100/173: intrnl: refactor fn names,
ELPA Syncer <=
- [elpa] externals/org-remark ecb82aebbe 101/173: intrnl correct some minor errors, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark fd5cab5ac2 102/173: rm: org-marginalia*.el, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 51b0c08f25 104/173: docs: NEWS, README etc. for name change, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 0c6aad188a 106/173: doc:README minor change for grammar, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark a98120b18c 107/173: add ::line-number to file line, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 366b169e55 108/173: add: pen-factory & available pens for change, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 8e558a3549 110/173: add browse-next/prev; open/visit; change open to side window, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 70cf67bc26 112/173: intrnl: refactor view, open, browse (view-next/prev), ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 84999b19c6 115/173: add: org-remark-convert-legacy-data as a standalone command, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark d2135790a7 114/173: intrnl: refactor empty-buffer-p, ELPA Syncer, 2022/01/28