[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate a484ffa0b6 319/372: - allowed removing (or cuttin
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate a484ffa0b6 319/372: - allowed removing (or cutting) annotations when buffer is in read-only mode. |
Date: |
Fri, 4 Feb 2022 16:59:15 -0500 (EST) |
branch: elpa/annotate
commit a484ffa0b6f8387874467582e6dd24b025158d10
Author: cage <cage@localhost>
Commit: cage <cage@invalid>
- allowed removing (or cutting) annotations when buffer is in read-only
mode.
---
annotate.el | 70 +++++++++++++++++++++++++++++++++----------------------------
1 file changed, 38 insertions(+), 32 deletions(-)
diff --git a/annotate.el b/annotate.el
index 51ebc2c962..914983c13b 100644
--- a/annotate.el
+++ b/annotate.el
@@ -295,6 +295,16 @@ annotation as defined in the database."
"Parsing failed:"
'annotate-error)
+(cl-defmacro annotate-with-disable-read-only (&body body)
+ `(let ((read-mode-p (if buffer-read-only
+ 1
+ -1)))
+ (when (= read-mode-p 1)
+ (read-only-mode -1))
+ ,@body
+ (when (= read-mode-p 1)
+ (read-only-mode 1))))
+
(defun annotate-annotations-exist-p ()
"Does this buffer contains at least one or more annotations?"
(cl-find-if 'annotationp
@@ -1184,21 +1194,22 @@ a a**
(when (> (buffer-size)
0)
(annotate-with-inhibit-modification-hooks
- ;; copy undo list
- (let ((saved-undo-list (copy-tree buffer-undo-list t)))
- ;; inhibit property removal to the undo list (and empty it too)
- (buffer-disable-undo)
- (save-excursion
- (goto-char end)
- ;; go to the EOL where the
- ;; annotated newline used to be
- (end-of-line)
- ;; strip dangling display property
- (remove-text-properties
- (point) (1+ (point)) '(display nil)))
- ;; restore undo list
- (setf buffer-undo-list saved-undo-list)
- (buffer-enable-undo)))))
+ (annotate-with-disable-read-only
+ ;; copy undo list
+ (let ((saved-undo-list (copy-tree buffer-undo-list t)))
+ ;; inhibit property removal to the undo list (and empty it too)
+ (buffer-disable-undo)
+ (save-excursion
+ (goto-char end)
+ ;; go to the EOL where the
+ ;; annotated newline used to be
+ (end-of-line)
+ ;; strip dangling display property
+ (remove-text-properties
+ (point) (1+ (point)) '(display nil)))
+ ;; restore undo list
+ (setf buffer-undo-list saved-undo-list)
+ (buffer-enable-undo))))))
(defun annotate-annotations-overlay-in-range (from-position to-position)
"Returns the annotations overlays that are enclosed in the range
@@ -1928,22 +1939,18 @@ See the variable: `annotate-use-echo-area'."
This function is not part of the public API."
(annotate-ensure-annotation (annotation)
- (save-excursion
- (with-current-buffer (current-buffer)
- (let* ((chain (annotate-find-chain annotation))
- (filename (annotate-actual-file-name))
- (info-format-p (eq (annotate-guess-file-format filename)
- :info)))
- (dolist (single-element chain)
- (goto-char (overlay-end single-element))
- (move-end-of-line nil)
- (when info-format-p
- (read-only-mode -1))
- (annotate--remove-annotation-property (overlay-start
single-element)
- (overlay-end
single-element))
- (delete-overlay single-element)
- (when info-format-p
- (read-only-mode 1))))))))
+ (save-excursion
+ (with-current-buffer (current-buffer)
+ (let* ((chain (annotate-find-chain annotation))
+ (filename (annotate-actual-file-name))
+ (info-format-p (eq (annotate-guess-file-format filename)
+ :info)))
+ (dolist (single-element chain)
+ (goto-char (overlay-end single-element))
+ (move-end-of-line nil)
+ (annotate--remove-annotation-property (overlay-start single-element)
+ (overlay-end
single-element))
+ (delete-overlay single-element)))))))
(defun annotate--delete-annotation-chain-ring (annotation-ring)
"Delete overlay of `annotation-ring' from a buffer.
@@ -2979,7 +2986,6 @@ position."
(when buffer-file-name
(annotate-show-annotation-summary buffer-file-name (point)))))
-
;;; switching database
(defun annotate-buffers-annotate-mode ()
- [nongnu] elpa/annotate e004ae7e97 281/372: - updated version;, (continued)
- [nongnu] elpa/annotate e004ae7e97 281/372: - updated version;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3e5d14fde8 287/372: - updated documentation., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 6415fb6111 294/372: - updated NEWS and CHANGELOG;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4890d2d2a2 295/372: Merge pull request #95 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 85d7c87e08 293/372: - added padding also for notes placed on the margin of the window., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate ac55086d60 301/372: - fixed typo., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3415b7ac08 321/372: - changed behaviour when user is annotation a newline character;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f33eecba7b 362/372: - prevented asking to delete a database that does not actually exists, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 1350e1d073 338/372: - fixed annotated text shown in the summary window, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3e3c1b1066 368/372: - fixed function name;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a484ffa0b6 319/372: - allowed removing (or cutting) annotations when buffer is in read-only mode.,
ELPA Syncer <=
- [nongnu] elpa/annotate 936389e36a 316/372: - prevented asking for annotation when trying to annotate a newline character., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 36d3729c27 339/372: - updated version number and docs., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a8762cd08a 344/372: - removed garbage at the end of an error message., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 9aba6305fe 342/372: Merge pull request #109 from cage2/fix-replace-button, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate bd12129213 333/372: Merge pull request #106 from cage2/fixed-call-comment-region, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 83e81e0979 369/372: - added missing docstrings and improved a bit the old ones., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f5436b2bff 366/372: - added helper functions to manage annotation's interval and 'annotate-db-merge-annotations'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 59c52e7318 162/372: - updated documentation to reflects changes in the code, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate fd9c403ecc 164/372: - changed quotation mark sentence., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a28e7b4fd2 028/372: refactored and documented export function, ELPA Syncer, 2022/02/04