[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-remark 32149d5135 25/67: fix: Exclude pdfs from def
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-remark 32149d5135 25/67: fix: Exclude pdfs from default file type #57 |
Date: |
Sat, 22 Jul 2023 06:59:01 -0400 (EDT) |
branch: externals/org-remark
commit 32149d5135b6a7502f77c8533acf6451fc790a6c
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>
fix: Exclude pdfs from default file type #57
The fix is applied to more generic case, not specific to PDF files.
Unlike epub files via nov-mode or websites via eww-mode, pdf-view-mode
buffers are actually visiting buffers. And yet, it is also derived from
special-mode, which means the buffers visited are meant to be read-only.
The fix implemented is to add a check to
'org-remark-source-find-file-name'. It now does the following:
1. Check whether or not the source buffer visited is derived from
special-mode.
2. If so, its notes buffer should be found by a mode-specific function,
not passing buffer-file-name
---
org-remark-global-tracking.el | 12 ++++++----
org-remark.el | 52 ++++++++++++++++++++++---------------------
2 files changed, 35 insertions(+), 29 deletions(-)
diff --git a/org-remark-global-tracking.el b/org-remark-global-tracking.el
index b963085f49..43c6d68449 100644
--- a/org-remark-global-tracking.el
+++ b/org-remark-global-tracking.el
@@ -99,9 +99,12 @@ When the current buffer is visiting a file, the name of
marginal
notes file will be \"FILE-notes.org\", adding \"-notes.org\" as a
suffix to the file name without the extension."
(if buffer-file-name
- (concat (file-name-sans-extension
- (file-name-nondirectory (org-remark-source-find-file-name)))
- "-notes.org")
+ (let ((source-filename (org-remark-source-find-file-name)))
+ (when (and (stringp source-filename)
+ (file-exists-p source-filename))
+ (concat (file-name-sans-extension
+ (file-name-nondirectory source-filename))
+ "-notes.org")))
;; If buffer is not visiting a file, a default file name. If this
;; file name is not suitable, either override the function or set
;; the user option to a custom function.
@@ -141,7 +144,8 @@ This function is meant to be added to `find-file-hook' by
We use this filename to identify the source buffer in all
operations related to marginal notes.
Assumes that we are currently in the source buffer."
- (let ((filename (or buffer-file-name
+ (let ((filename (or (and (not (derived-mode-p 'special-mode))
+ buffer-file-name)
(run-hook-with-args-until-success
'org-remark-source-find-file-name-functions))))
filename))
diff --git a/org-remark.el b/org-remark.el
index d41b4a346e..f51706dbf9 100644
--- a/org-remark.el
+++ b/org-remark.el
@@ -731,7 +731,8 @@ round-trip back to the notes file."
(id (if id id (substring (org-id-uuid) 0 8)))
(filename (org-remark-source-find-file-name)))
(if (not filename)
- (message "org-remark: Highlights not saved; buffer is not supported")
+ (message (format "org-remark: Highlights not saved.\
+ This buffer (%s) is not supported" (symbol-name major-mode)))
(org-with-wide-buffer
(overlay-put ov 'face (if face face 'org-remark-highlighter))
(while properties
@@ -1292,30 +1293,31 @@ configuration. It automatically turns on
`org-remark-mode'.
Otherwise, do not forget to turn on `org-remark-mode' manually to
load the highlights"
;; Loop highlights and add them to the current buffer
- (let ((notes-buf (find-file-noselect (org-remark-notes-get-file-name)))
- (source-buf (current-buffer))
- (overlays)) ;; highlight overlays
- (dolist (highlight (org-remark-highlights-get notes-buf) overlays)
- (let* ((location (plist-get highlight :location))
- (beg (car location))
- (end (cdr location))
- (id (plist-get highlight :id))
- (ov (org-remark-find-overlay-in beg end id)))
- ;; In order to update the overlay, it is first gets deleted
- ;; and newly loaded. This way, we avoid duplicate of the same
- ;; highlight.
-
- ;; FIXME Currently the when clause is used to guard against
- ;; the case wheremarkre a highlight overlay is not found. It should
- ;; be an edge case but the highlight could have moved to a
- ;; completely new location where the old location does not
- ;; overlap with the new location at all.
- (when ov (org-remark-highlight-clear ov))
- (push (org-remark-highlight-load highlight) overlays)))
- (unless update (org-remark-notes-setup notes-buf source-buf))
- (run-hook-with-args 'org-remark-highlights-after-load-hook
- overlays notes-buf))
- t)
+ (let (overlays) ;; highlight overlays
+ (when-let* ((notes-filename (org-remark-notes-get-file-name))
+ (notes-buf (find-file-noselect notes-filename))
+ (source-buf (current-buffer)))
+ (dolist (highlight (org-remark-highlights-get notes-buf) overlays)
+ (let* ((location (plist-get highlight :location))
+ (beg (car location))
+ (end (cdr location))
+ (id (plist-get highlight :id))
+ (ov (org-remark-find-overlay-in beg end id)))
+ ;; In order to update the overlay, it is first gets deleted
+ ;; and newly loaded. This way, we avoid duplicate of the same
+ ;; highlight.
+
+ ;; FIXME Currently the when clause is used to guard against
+ ;; the case wheremarkre a highlight overlay is not found. It should
+ ;; be an edge case but the highlight could have moved to a
+ ;; completely new location where the old location does not
+ ;; overlap with the new location at all.
+ (when ov (org-remark-highlight-clear ov))
+ (push (org-remark-highlight-load highlight) overlays)))
+ (unless update (org-remark-notes-setup notes-buf source-buf))
+ (run-hook-with-args 'org-remark-highlights-after-load-hook
+ overlays notes-buf)
+ t)))
(defun org-remark-highlights-get-positions (&optional reverse)
"Return list of the beginning point of all visible highlights in this buffer.
- [elpa] externals/org-remark e1b7a3a1ba 19/67: Merge remote-tracking branch 'sati-bodhi/main' into dev/nov.el, (continued)
- [elpa] externals/org-remark e1b7a3a1ba 19/67: Merge remote-tracking branch 'sati-bodhi/main' into dev/nov.el, ELPA Syncer, 2023/07/22
- [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 <=
- [elpa] externals/org-remark 14996bc1ce 30/67: refactor: notes-set-properties & new-headline, ELPA Syncer, 2023/07/22
- [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