[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-remark 14996bc1ce 30/67: refactor: notes-set-proper
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-remark 14996bc1ce 30/67: refactor: notes-set-properties & new-headline |
Date: |
Sat, 22 Jul 2023 06:59:02 -0400 (EDT) |
branch: externals/org-remark
commit 14996bc1cee740b1acea9eeee67d5d9970216d26
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
refactor: notes-set-properties & new-headline
---
org-remark-convert-legacy.el | 7 +++++--
org-remark.el | 41 ++++++++++++++++++++++++-----------------
2 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/org-remark-convert-legacy.el b/org-remark-convert-legacy.el
index 99463a543f..8168f5daec 100644
--- a/org-remark-convert-legacy.el
+++ b/org-remark-convert-legacy.el
@@ -4,7 +4,7 @@
;; Author: Noboru Ota <me@nobiot.com>
;; URL: https://github.com/nobiot/org-remark
-;; Last modified: 16 January 2022
+;; Last modified: 29 May 2023
;; Created: 16 January 2022
;; Package-Requires: ((emacs "27.1") (org "9.4"))
;; Keywords: org-mode, annotation, writing, note-taking, marginal notes
@@ -90,7 +90,10 @@ solely by Org-marginalia."
(org-delete-property "marginalia-source-beg")
(org-delete-property "marginalia-source-end")
(org-set-property org-remark-prop-id id)
- (org-remark-notes-set-properties beg end)))
+ (let ((props))
+ (plist-put props org-remark-prop-source-beg (number-to-string beg))
+ (plist-put props org-remark-prop-source-end (number-to-string end))
+ (org-remark-notes-set-properties props))))
(goto-char (point-min))
(message (format "org-remark: Legacy \"marginalia-*\" properties updated
for %s"
(abbreviate-file-name (buffer-file-name))))
diff --git a/org-remark.el b/org-remark.el
index e0e919927c..4ba88cbe17 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -6,7 +6,7 @@
;; URL: https://github.com/nobiot/org-remark
;; Version: 1.1.0
;; Created: 22 December 2020
-;; Last modified: 21 May 2023
+;; Last modified: 29 May 2023
;; Package-Requires: ((emacs "27.1") (org "9.4"))
;; Keywords: org-mode, annotation, note-taking, marginal-notes, wp,
@@ -886,6 +886,17 @@ buffer for automatic sync."
;;; Return notes-props
notes-props))
+(defun org-remark-new-headline (level title props)
+ ""
+ ;; If file-headline does not exist, create one at the bottom
+ (goto-char (point-max))
+ ;; Ensure to be in the beginning of line to add a new headline
+ (when (eolp) (open-line 1) (forward-line 1) (beginning-of-line))
+ (insert-char (string-to-char "*") level)
+ (insert (concat " " title "\n"))
+ (org-remark-notes-set-properties props)
+ (org-back-to-heading) (point))
+
(defun org-remark-highlight-add-source-headline-maybe (level source-buf
notes-buf)
"Add a new source headline if not yet present in NOTES-BUF.
Return the point of beginning of source headline regardless of it
@@ -905,15 +916,8 @@ Assume the current buffer is NOTES-BUF."
;; Return the beginning point of the headline. Create if not present
(or (org-find-property
org-remark-prop-source-file source-name)
- (progn
- ;; If file-headline does not exist, create one at the bottom
- (goto-char (point-max))
- ;; Ensure to be in the beginning of line to add a new headline
- (when (eolp) (open-line 1) (forward-line 1) (beginning-of-line))
- (insert-char (string-to-char "*") level)
- (insert (concat " " title "\n"))
- (org-set-property org-remark-prop-source-file source-name)
- (org-back-to-heading) (point))))))
+ (org-remark-new-headline
+ level title (list org-remark-prop-source-file source-name))))))
(defun org-remark-highlight-add-or-update-highlight-headline (highlight
source-buf notes-buf)
"Add a new HIGHLIGHT headlne to the NOTES-BUF or update it.
@@ -944,6 +948,9 @@ beginning of source-headline, which should be one level up."
(run-hook-with-args-until-success
'org-remark-highlight-link-to-source-functions filename))
orgid (org-remark-highlight-get-org-id beg))
+ ;; TODO ugly to add the beg end after setq above
+ (plist-put props org-remark-prop-source-beg (number-to-string beg))
+ (plist-put props org-remark-prop-source-end (number-to-string end))
(when link (plist-put props "org-remark-link" link)))
;;; Make it explicit that we are now in the notes-buf, though it is
;;; functionally redundant.
@@ -958,7 +965,7 @@ beginning of source-headline, which should be one level up."
;; Don't update the headline text when it already exists
;; Let the user decide how to manage the headlines
;; (org-edit-headline text)
- (org-remark-notes-set-properties beg end props))
+ (org-remark-notes-set-properties props))
;; No headline with the marginal notes ID property. Create a new one
;; at the end of the file's entry
(org-narrow-to-subtree)
@@ -972,7 +979,7 @@ beginning of source-headline, which should be one level up."
;; org-remark-original-text should be added only when this
;; headline is created. No update afterwards
(plist-put props "org-remark-original-text" text)
- (org-remark-notes-set-properties beg end props)
+ (org-remark-notes-set-properties props)
(when (and orgid org-remark-use-org-id)
(insert (concat "[[id:" orgid "]" "[" title "]]"))))
(list :body (org-remark-notes-get-body)
@@ -1134,7 +1141,7 @@ only one of the marginal notes buffer per session."
;; set the variable and return the indirect buffer
(setq org-remark-last-notes-buffer ibuf)))
-(defun org-remark-notes-set-properties (beg end &optional props)
+(defun org-remark-notes-set-properties (props)
"Set properties for the headline in the notes file.
Return t.
@@ -1154,10 +1161,10 @@ drawer.
In order to avoid adding org-remark-* overlay properties to Org
properties, add prefix \"*\"."
- (org-set-property org-remark-prop-source-beg
- (number-to-string beg))
- (org-set-property org-remark-prop-source-end
- (number-to-string end))
+ ;; (org-set-property org-remark-prop-source-beg
+ ;; (number-to-string beg))
+ ;; (org-set-property org-remark-prop-source-end
+ ;; (number-to-string end))
;; Delete property. Prefer `org-entry-delete' over
;; `org-delete-property' as the former is silent.
- [elpa] externals/org-remark 090156bed2 21/67: feat: org-remark-nov-mode minor mode, (continued)
- [elpa] externals/org-remark 090156bed2 21/67: feat: org-remark-nov-mode minor mode, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark ef7e02d542 34/67: fix: annotation body to be nil when no body text, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark aa58058ec4 38/67: refactor: add-headlines (WIP), ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark c38f46e806 42/67: refactor(highlight-add): remove spurflous/obsolete elements, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark b94c64e381 45/67: feature: Make icons customizable, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark f1ea78bcf1 47/67: refactor: highlight-add, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark f21ab48aad 62/67: refactor: simple name replace org-remark-get-epub-source, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 160de610f8 64/67: fix: make sure new top-level headline is appended, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark fea8103b9b 65/67: fix(legacy): compilation warning #66, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 32149d5135 25/67: fix: Exclude pdfs from default file type #57, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 14996bc1ce 30/67: refactor: notes-set-properties & new-headline,
ELPA Syncer <=
- [elpa] externals/org-remark 356c87468a 31/67: feature(nov) find-source and link correctly (WIP), ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 0d4902f9eb 43/67: docs: flymake, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark d7ae7158bd 48/67: fix(adjust-position) newline char prevent string match, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 4900be37ba 57/67: docs: Fix erroneous newline, ELPA Syncer, 2023/07/22
- [elpa] externals/org-remark 498354ace4 67/67: docs: README with configuration for nov.el, ELPA Syncer, 2023/07/22