[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-remark d36debe2b4 124/173: add: factor out org-rema
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-remark d36debe2b4 124/173: add: factor out org-remark-legacy-convert |
Date: |
Fri, 28 Jan 2022 16:58:07 -0500 (EST) |
branch: externals/org-remark
commit d36debe2b460caa020414cfcee6d6be5d36385e5
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
add: factor out org-remark-legacy-convert
---
org-remark-convert-legacy.el | 102 ++++++++++++++++++++++++++++++++++++++++++
org-remark-global-tracking.el | 15 ++++---
org-remark.el | 77 ++-----------------------------
3 files changed, 114 insertions(+), 80 deletions(-)
diff --git a/org-remark-convert-legacy.el b/org-remark-convert-legacy.el
new file mode 100644
index 0000000000..48ef8c0261
--- /dev/null
+++ b/org-remark-convert-legacy.el
@@ -0,0 +1,102 @@
+;;; org-remark-convert-legacy.el --- Convert legacy Org-marginalia files to
Org-remark -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2022 Noboru Ota
+
+;; Author: Noboru Ota <me@nobiot.com>
+;; URL: https://github.com/nobiot/org-remark
+;; Last modified: 16 January 2022
+;; Created: 16 January 2022
+;; Package-Requires: ((emacs "27.1") (org "9.4"))
+;; Keywords: org-mode, annotation, writing, note-taking, marginal notes
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;; This file is part of Org-remark and contains a feature that helps users of
+;; Org-marginalia (former name of Org-remark) convert their legacy
+;; marginalia.org files to those compatible with Org-remark.
+;;
+;; (require 'org-remark-convert-legacy-data) for `org-remark' to use
+;; `org-remark-convert-legacy-data' function to automatically convert legacy
+;; data on save and load. Alternatively, use the same function as an
+;; interactive command on a marginalia.org buffer that contains legacy
+;; Org-marginalia data.
+
+;;; Code:
+
+(require 'org)
+(require 'org-remark)
+
+(defun org-remark-convert-legacy-data ()
+ "Convert the legacy Org-marginalia properties to those for Org-remark.
+
+You can call this function interactively to convert the current
+buffer. It also gets automatically triggered when you save or
+load Org-remark marginal notes file if
+`org-remark-convert-legacy' user option is non-nil.
+
+This function checks whether or not there is at least one legacy entry with
+property \"marginalia-source-file\" in the current buffer.
+
+If one found, this function will:
+
+1. Create a backup copy with the filename \"<current-file-name>_archive\"
+2. Convert all \"marginalia-*\" properties to \"org-remark-*\" equivalents
+
+- marginalia-source-file -> org-remark-file
+- marginalia-id -> org-remark-id
+- marginalia-source-beg -> org-remark-beg
+- marginalia-source-end -> org-remark-end
+
+This assumes that all the \"marginalia-*\" properties were used
+solely by Org-marginalia."
+ (interactive)
+ (org-with-wide-buffer
+ ;; Check that there is at least one legacy entry in the current buffer
+ (goto-char (point-min))
+ (when (save-excursion (org-find-property "marginalia-source-file"))
+ ;; Do the process only when there is at least one entry
+ ;; Create a backup copy
+ (let ((filename (abbreviate-file-name
+ (concat (buffer-file-name) "_archive"))))
+ (write-region (point-min) (point-max) filename)
+ (message (format "org-remark: created backup file %s" filename)))
+ ;; Scan the whole marginal notes file
+ (while (not (org-next-visible-heading 1))
+ (when-let (source-file (org-entry-get (point) "marginalia-source-file"))
+ (org-delete-property "marginalia-source-file")
+ (org-set-property org-remark-prop-source-file source-file))
+ (when-let ((id (org-entry-get (point) "marginalia-id"))
+ (beg (string-to-number
+ (org-entry-get (point)
+ "marginalia-source-beg")))
+ (end (string-to-number
+ (org-entry-get (point)
+ "marginalia-source-end"))))
+ (org-delete-property "marginalia-id")
+ (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)))
+ (goto-char (point-min))
+ (message (format "org-remark: Legacy \"marginalia-*\" properties updated
for %s"
+ (abbreviate-file-name (buffer-file-name))))
+ t)))
+
+(provide 'org-remark-convert-legacy)
+
+;;; org-remark-convert-legacy.el ends here
+
diff --git a/org-remark-global-tracking.el b/org-remark-global-tracking.el
index 8e44370afc..17662d70f5 100644
--- a/org-remark-global-tracking.el
+++ b/org-remark-global-tracking.el
@@ -4,7 +4,7 @@
;; Author: Noboru Ota <me@nobiot.com>
;; URL: https://github.com/nobiot/org-remark
-;; Last modified: 13 January 2022
+;; Last modified: 16 January 2022
;; Package-Requires: ((emacs "27.1") (org "9.4"))
;; Keywords: org-mode, annotation, writing, note-taking, marginal notes
@@ -39,7 +39,8 @@ saved in `org-remark-tracking-file' automatically loads
highlights."
:group 'org-remark
:type 'file)
-(defvar org-remark-files-tracked nil)
+(defvar org-remark-files-tracked nil
+ "List of files being tracked by `org-remark-global-tracking-mode'.")
;;;###autoload
(define-minor-mode org-remark-global-tracking-mode
@@ -55,11 +56,11 @@ locally for the file opened."
;; Activate
;; Prioritise the new `org-remark-tracking-file' over the legacy one
(when-let (tracking-file (or (when (file-exists-p
- org-remark-tracking-file)
- org-remark-tracking-file)
- (when (file-exists-p
- (org-remark-legacy-tracking-file-get))
- (org-remark-legacy-tracking-file-get))))
+ org-remark-tracking-file)
+ org-remark-tracking-file)
+ (when (file-exists-p
+ (org-remark-legacy-tracking-file-get))
+ (org-remark-legacy-tracking-file-get))))
(org-remark-tracking-load tracking-file))
;; `org-remark-tracking-save' should be added to kill hook even when no
;; tracking file existed before -- this would indicate first time use of
diff --git a/org-remark.el b/org-remark.el
index 797e6a90e6..363a51ed17 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -6,7 +6,7 @@
;; URL: https://github.com/nobiot/org-remark
;; Version: 1.0.0-rc
;; Created: 22 December 2020
-;; Last modified: 15 January 2022
+;; Last modified: 16 January 2022
;; Package-Requires: ((emacs "27.1") (org "9.4"))
;; Keywords: org-mode, annotation, writing, note-taking, marginal-notes
@@ -37,7 +37,7 @@
(require 'org)
(require 'org-id)
(require 'org-remark-global-tracking)
-(declare-function org-collect-keywords "org")
+(declare-function org-remark-convert-legacy-data "org-remark-convert-legacy")
;;;; Customization
@@ -90,17 +90,6 @@ name."
"Define if Org-remark use Org-ID to link back to the main note."
:type 'boolean)
-(defcustom org-remark-convert-legacy t
- "Specify whether or not Org-remark automatically performs data conversion.
-The conversion is done via function
-`org-remark-covert-legacy-data'. Set to nil if you do not have a
-marginalia file from the Org-marginalia package (it's the
-previous name of Org-remark).
-
-It is safe to keep it with minimal performance overhead but
-recommended to turn it off if not required."
- :type 'boolean)
-
;;;; Variables
@@ -525,64 +514,6 @@ and removing overlays are not part of the undo tree."
(org-remark-single-highlight-remove id arg)
t))
-;;;; Legacy data conversion from Org-marginalia
-
-(defun org-remark-convert-legacy-data ()
- "Convert the legacy Org-marginalia properties to those for Org-remark.
-
-You can call this function interactively to convert the current
-buffer. It also gets automatically triggered when you save or
-load Org-remark marginal notes file if
-`org-remark-convert-legacy' user option is non-nil.
-
-This function checks whether or not there is at least one legacy entry with
-property \"marginalia-source-file\" in the current buffer.
-
-If one found, this function will:
-
-1. Create a backup copy with the filename \"<current-file-name>_archive\"
-2. Convert all \"marginalia-*\" properties to \"org-remark-*\" equivalents
-
-- marginalia-source-file -> org-remark-file
-- marginalia-id -> org-remark-id
-- marginalia-source-beg -> org-remark-beg
-- marginalia-source-end -> org-remark-end
-
-This assumes that all the \"marginalia-*\" properties were used
-solely by Org-marginalia."
- (interactive)
- (org-with-wide-buffer
- ;; Check that there is at least one legacy entry in the current buffer
- (goto-char (point-min))
- (when (save-excursion (org-find-property "marginalia-source-file"))
- ;; Do the process only when there is at least one entry
- ;; Create a backup copy
- (let ((filename (abbreviate-file-name
- (concat (buffer-file-name) "_archive"))))
- (write-region (point-min) (point-max) filename)
- (message (format "org-remark: created backup file %s" filename)))
- ;; Scan the whole marginal notes file
- (while (not (org-next-visible-heading 1))
- (when-let (source-file (org-entry-get (point) "marginalia-source-file"))
- (org-delete-property "marginalia-source-file")
- (org-set-property org-remark-prop-source-file source-file))
- (when-let ((id (org-entry-get (point) "marginalia-id"))
- (beg (string-to-number
- (org-entry-get (point)
- "marginalia-source-beg")))
- (end (string-to-number
- (org-entry-get (point)
- "marginalia-source-end"))))
- (org-delete-property "marginalia-id")
- (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)))
- (goto-char (point-min))
- (message (format "org-remark: Legacy \"marginalia-*\" properties updated
for %s"
- (abbreviate-file-name (buffer-file-name))))
- t)))
-
;;;; Internal Functions
@@ -711,7 +642,7 @@ packages such as Org-roam's backlink feature."
;; If it is a new empty marginalia file
(when (and (org-remark-empty-buffer-p) org-remark-use-org-id)
(org-id-get-create))
- (when org-remark-convert-legacy (org-remark-convert-legacy-data))
+ (when (featurep 'org-remark-convert-legacy)
(org-remark-convert-legacy-data))
(org-with-wide-buffer
(let ((file-headline (or (org-find-property
org-remark-prop-source-file path)
@@ -817,7 +748,7 @@ Each highlight is a list in the following structure:
;; TODO check if there is any relevant notes for the current file
(let ((highlights))
(with-current-buffer notes-buf
- (when org-remark-convert-legacy
+ (when (featurep 'org-remark-convert-legacy)
(org-remark-convert-legacy-data))
(org-with-wide-buffer
(let ((heading (org-find-property
- [elpa] externals/org-remark 69d0259e20 146/173: docs: user manaul, (continued)
- [elpa] externals/org-remark 69d0259e20 146/173: docs: user manaul, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 62cba0ec63 148/173: fix: change now updates the marginal notes, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark f43e4afc34 152/173: add: toggle to menu; intrnl: refactor, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark f353630ddd 153/173: fix:toggle: marking when toggle hidden confuses the state, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark da77d9dfba 154/173: fix: pen menu function for 27.x, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 4782d43f0f 155/173: add: change to menu items, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 713f64b7cb 168/173: docs: minor change to the demo/marginalia.org, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 7226f4d01e 173/173: docs: add delete; add help string to menu items, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 4b5d9c3fda 171/173: fix:delete quit window if it did not exist on calling delete, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 9deaecd211 116/173: add: Legacy data facility wtih org-remark-tracking, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark d36debe2b4 124/173: add: factor out org-remark-legacy-convert,
ELPA Syncer <=
- [elpa] externals/org-remark f30ad4f570 122/173: fix: program error in save, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark b9a8409e27 126/173: docs: copyright & dates, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark e3dd998e6b 130/173: add: register the default pen function for change, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 9f492e184e 111/173: fix side-window, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 238a023021 141/173: docs: gh-html error, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark bbd5c4795e 144/173: docs: user manual, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark c6dccc3878 161/173: intrnl:create macro: check label to be a string, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark a55d0b7717 165/173: docs: README and user manaul, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 74c6756d72 109/173: keep default marginalia.org, ELPA Syncer, 2022/01/28
- [elpa] externals/org-remark 6583adaca1 134/173: intrnl: single-highlight-mark is back, ELPA Syncer, 2022/01/28