Use `with-silent-modifications' instead of `org-unmodified' when it makes sense
* org-macs.el: Add a comment on when to use `org-unmodified' and when to use `with-silent-modifications'. * org-colview.el (org-columns-display-here) (org-columns-remove-overlays, org-columns-quit) (org-columns-edit-value, org-columns-compute-all) (org-columns-compute, org-agenda-colview-compute): * org-clock.el (org-clock-sum): * org.el (org-refresh-category-properties) (org-refresh-properties, org-entry-blocked-p) (org-agenda-prepare-buffers): Use `with-silent-modifications' instead of `org-unmodified'. Thanks to Stefan Monnier for reminding me about `with-silent-modifications'!
This commit is contained in:
parent
64aae2fd29
commit
43c8aa02cc
|
@ -1700,7 +1700,7 @@ each headline in the time range with point at the headline. Headlines for
|
||||||
which HEADLINE-FILTER returns nil are excluded from the clock summation.
|
which HEADLINE-FILTER returns nil are excluded from the clock summation.
|
||||||
PROPNAME lets you set a custom text property instead of :org-clock-minutes."
|
PROPNAME lets you set a custom text property instead of :org-clock-minutes."
|
||||||
(interactive)
|
(interactive)
|
||||||
(org-unmodified
|
(with-silent-modifications
|
||||||
(let* ((re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*"
|
(let* ((re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*"
|
||||||
org-clock-string
|
org-clock-string
|
||||||
"[ \t]*\\(?:\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)\\|=>[ \t]+\\([0-9]+\\):\\([0-9]+\\)\\)"))
|
"[ \t]*\\(?:\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)\\|=>[ \t]+\\([0-9]+\\):\\([0-9]+\\)\\)"))
|
||||||
|
|
|
@ -223,7 +223,7 @@ This is the compiled version of the format.")
|
||||||
(setq s2 (org-columns-add-ellipses (or modval val) width))
|
(setq s2 (org-columns-add-ellipses (or modval val) width))
|
||||||
(setq string (format f s2))
|
(setq string (format f s2))
|
||||||
;; Create the overlay
|
;; Create the overlay
|
||||||
(org-unmodified
|
(with-silent-modifications
|
||||||
(setq ov (org-columns-new-overlay
|
(setq ov (org-columns-new-overlay
|
||||||
beg (setq beg (1+ beg)) string (if dateline face1 face)))
|
beg (setq beg (1+ beg)) string (if dateline face1 face)))
|
||||||
(overlay-put ov 'keymap org-columns-map)
|
(overlay-put ov 'keymap org-columns-map)
|
||||||
|
@ -332,7 +332,7 @@ for the duration of the command.")
|
||||||
(remove-hook 'post-command-hook 'org-columns-hscoll-title 'local))
|
(remove-hook 'post-command-hook 'org-columns-hscoll-title 'local))
|
||||||
(move-marker org-columns-begin-marker nil)
|
(move-marker org-columns-begin-marker nil)
|
||||||
(move-marker org-columns-top-level-marker nil)
|
(move-marker org-columns-top-level-marker nil)
|
||||||
(org-unmodified
|
(with-silent-modifications
|
||||||
(mapc 'delete-overlay org-columns-overlays)
|
(mapc 'delete-overlay org-columns-overlays)
|
||||||
(setq org-columns-overlays nil)
|
(setq org-columns-overlays nil)
|
||||||
(let ((inhibit-read-only t))
|
(let ((inhibit-read-only t))
|
||||||
|
@ -384,7 +384,7 @@ CPHR is the complex heading regexp to use for parsing ITEM."
|
||||||
(defun org-columns-quit ()
|
(defun org-columns-quit ()
|
||||||
"Remove the column overlays and in this way exit column editing."
|
"Remove the column overlays and in this way exit column editing."
|
||||||
(interactive)
|
(interactive)
|
||||||
(org-unmodified
|
(with-silent-modifications
|
||||||
(org-columns-remove-overlays)
|
(org-columns-remove-overlays)
|
||||||
(let ((inhibit-read-only t))
|
(let ((inhibit-read-only t))
|
||||||
(remove-text-properties (point-min) (point-max) '(read-only t))))
|
(remove-text-properties (point-min) (point-max) '(read-only t))))
|
||||||
|
@ -488,7 +488,7 @@ Where possible, use the standard interface for changing this line."
|
||||||
(org-agenda-columns)))
|
(org-agenda-columns)))
|
||||||
(t
|
(t
|
||||||
(let ((inhibit-read-only t))
|
(let ((inhibit-read-only t))
|
||||||
(org-unmodified
|
(with-silent-modifications
|
||||||
(remove-text-properties
|
(remove-text-properties
|
||||||
(max (point-min) (1- bol)) eol '(read-only t)))
|
(max (point-min) (1- bol)) eol '(read-only t)))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
|
@ -920,7 +920,7 @@ Don't set this, this is meant for dynamic scoping.")
|
||||||
|
|
||||||
(defun org-columns-compute-all ()
|
(defun org-columns-compute-all ()
|
||||||
"Compute all columns that have operators defined."
|
"Compute all columns that have operators defined."
|
||||||
(org-unmodified
|
(with-silent-modifications
|
||||||
(remove-text-properties (point-min) (point-max) '(org-summaries t)))
|
(remove-text-properties (point-min) (point-max) '(org-summaries t)))
|
||||||
(let ((columns org-columns-current-fmt-compiled)
|
(let ((columns org-columns-current-fmt-compiled)
|
||||||
(org-columns-time (time-to-number-of-days (current-time)))
|
(org-columns-time (time-to-number-of-days (current-time)))
|
||||||
|
@ -996,7 +996,7 @@ Don't set this, this is meant for dynamic scoping.")
|
||||||
(if (assoc property sum-alist)
|
(if (assoc property sum-alist)
|
||||||
(setcdr (assoc property sum-alist) useval)
|
(setcdr (assoc property sum-alist) useval)
|
||||||
(push (cons property useval) sum-alist)
|
(push (cons property useval) sum-alist)
|
||||||
(org-unmodified
|
(with-silent-modifications
|
||||||
(add-text-properties sumpos (1+ sumpos)
|
(add-text-properties sumpos (1+ sumpos)
|
||||||
(list 'org-summaries sum-alist))))
|
(list 'org-summaries sum-alist))))
|
||||||
(when (and val (not (equal val (if flag str val))))
|
(when (and val (not (equal val (if flag str val))))
|
||||||
|
@ -1509,9 +1509,8 @@ This will add overlays to the date lines, to show the summary for each day."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(widen)
|
(widen)
|
||||||
(org-unmodified
|
(with-silent-modifications
|
||||||
(remove-text-properties (point-min) (point-max)
|
(remove-text-properties (point-min) (point-max) '(org-summaries t)))
|
||||||
'(org-summaries t)))
|
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(org-columns-get-format-and-top-level)
|
(org-columns-get-format-and-top-level)
|
||||||
(while (setq fm (pop fmt))
|
(while (setq fm (pop fmt))
|
||||||
|
|
|
@ -117,6 +117,8 @@ Otherwise return nil."
|
||||||
(def-edebug-spec org-preserve-lc (body))
|
(def-edebug-spec org-preserve-lc (body))
|
||||||
|
|
||||||
;; Copied from bookmark.el
|
;; Copied from bookmark.el
|
||||||
|
;; Use `org-unmodified' to ignore real modifications, otherwise
|
||||||
|
;; `with-silent-modifications' is enough to ignore cosmetic ones
|
||||||
(defmacro org-unmodified (&rest body)
|
(defmacro org-unmodified (&rest body)
|
||||||
"Run BODY while preserving the buffer's `buffer-modified-p' state."
|
"Run BODY while preserving the buffer's `buffer-modified-p' state."
|
||||||
(org-with-gensyms (was-modified)
|
(org-with-gensyms (was-modified)
|
||||||
|
|
11
lisp/org.el
11
lisp/org.el
|
@ -8948,7 +8948,7 @@ call CMD."
|
||||||
((symbolp org-category) (symbol-name org-category))
|
((symbolp org-category) (symbol-name org-category))
|
||||||
(t org-category)))
|
(t org-category)))
|
||||||
beg end cat pos optionp)
|
beg end cat pos optionp)
|
||||||
(org-unmodified
|
(with-silent-modifications
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(widen)
|
(widen)
|
||||||
|
@ -8973,7 +8973,7 @@ DPROP is the drawer property and TPROP is the corresponding text
|
||||||
property to set."
|
property to set."
|
||||||
(let ((case-fold-search t)
|
(let ((case-fold-search t)
|
||||||
(inhibit-read-only t) p)
|
(inhibit-read-only t) p)
|
||||||
(org-unmodified
|
(with-silent-modifications
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(widen)
|
(widen)
|
||||||
|
@ -12159,11 +12159,10 @@ changes because there are unchecked boxes in this entry."
|
||||||
|
|
||||||
(defun org-entry-blocked-p ()
|
(defun org-entry-blocked-p ()
|
||||||
"Is the current entry blocked?"
|
"Is the current entry blocked?"
|
||||||
(org-unmodified
|
(with-silent-modifications
|
||||||
(if (org-entry-get nil "NOBLOCKING")
|
(if (org-entry-get nil "NOBLOCKING")
|
||||||
nil ;; Never block this entry
|
nil ;; Never block this entry
|
||||||
(not
|
(not (run-hook-with-args-until-failure
|
||||||
(run-hook-with-args-until-failure
|
|
||||||
'org-blocker-hook
|
'org-blocker-hook
|
||||||
(list :type 'todo-state-change
|
(list :type 'todo-state-change
|
||||||
:position (point)
|
:position (point)
|
||||||
|
@ -17601,7 +17600,7 @@ When a buffer is unmodified, it is just killed. When modified, it is saved
|
||||||
(org-check-agenda-file file)
|
(org-check-agenda-file file)
|
||||||
(set-buffer (org-get-agenda-file-buffer file)))
|
(set-buffer (org-get-agenda-file-buffer file)))
|
||||||
(widen)
|
(widen)
|
||||||
(org-unmodified
|
(with-silent-modifications
|
||||||
(org-refresh-category-properties)
|
(org-refresh-category-properties)
|
||||||
(org-refresh-properties org-effort-property 'org-effort)
|
(org-refresh-properties org-effort-property 'org-effort)
|
||||||
(org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime)
|
(org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime)
|
||||||
|
|
Loading…
Reference in New Issue