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:
Bastien Guerry 2013-02-23 14:57:51 +01:00
parent 64aae2fd29
commit 43c8aa02cc
4 changed files with 176 additions and 176 deletions

View File

@ -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.
PROPNAME lets you set a custom text property instead of :org-clock-minutes."
(interactive)
(org-unmodified
(with-silent-modifications
(let* ((re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*"
org-clock-string
"[ \t]*\\(?:\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)\\|=>[ \t]+\\([0-9]+\\):\\([0-9]+\\)\\)"))

View File

@ -223,7 +223,7 @@ This is the compiled version of the format.")
(setq s2 (org-columns-add-ellipses (or modval val) width))
(setq string (format f s2))
;; Create the overlay
(org-unmodified
(with-silent-modifications
(setq ov (org-columns-new-overlay
beg (setq beg (1+ beg)) string (if dateline face1 face)))
(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))
(move-marker org-columns-begin-marker nil)
(move-marker org-columns-top-level-marker nil)
(org-unmodified
(with-silent-modifications
(mapc 'delete-overlay org-columns-overlays)
(setq org-columns-overlays nil)
(let ((inhibit-read-only t))
@ -384,7 +384,7 @@ CPHR is the complex heading regexp to use for parsing ITEM."
(defun org-columns-quit ()
"Remove the column overlays and in this way exit column editing."
(interactive)
(org-unmodified
(with-silent-modifications
(org-columns-remove-overlays)
(let ((inhibit-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)))
(t
(let ((inhibit-read-only t))
(org-unmodified
(with-silent-modifications
(remove-text-properties
(max (point-min) (1- bol)) eol '(read-only t)))
(unwind-protect
@ -920,7 +920,7 @@ Don't set this, this is meant for dynamic scoping.")
(defun org-columns-compute-all ()
"Compute all columns that have operators defined."
(org-unmodified
(with-silent-modifications
(remove-text-properties (point-min) (point-max) '(org-summaries t)))
(let ((columns org-columns-current-fmt-compiled)
(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)
(setcdr (assoc property sum-alist) useval)
(push (cons property useval) sum-alist)
(org-unmodified
(with-silent-modifications
(add-text-properties sumpos (1+ sumpos)
(list 'org-summaries sum-alist))))
(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-restriction
(widen)
(org-unmodified
(remove-text-properties (point-min) (point-max)
'(org-summaries t)))
(with-silent-modifications
(remove-text-properties (point-min) (point-max) '(org-summaries t)))
(goto-char (point-min))
(org-columns-get-format-and-top-level)
(while (setq fm (pop fmt))

View File

@ -117,6 +117,8 @@ Otherwise return nil."
(def-edebug-spec org-preserve-lc (body))
;; 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)
"Run BODY while preserving the buffer's `buffer-modified-p' state."
(org-with-gensyms (was-modified)

View File

@ -8948,7 +8948,7 @@ call CMD."
((symbolp org-category) (symbol-name org-category))
(t org-category)))
beg end cat pos optionp)
(org-unmodified
(with-silent-modifications
(save-excursion
(save-restriction
(widen)
@ -8973,7 +8973,7 @@ DPROP is the drawer property and TPROP is the corresponding text
property to set."
(let ((case-fold-search t)
(inhibit-read-only t) p)
(org-unmodified
(with-silent-modifications
(save-excursion
(save-restriction
(widen)
@ -12159,11 +12159,10 @@ changes because there are unchecked boxes in this entry."
(defun org-entry-blocked-p ()
"Is the current entry blocked?"
(org-unmodified
(with-silent-modifications
(if (org-entry-get nil "NOBLOCKING")
nil ;; Never block this entry
(not
(run-hook-with-args-until-failure
(not (run-hook-with-args-until-failure
'org-blocker-hook
(list :type 'todo-state-change
: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)
(set-buffer (org-get-agenda-file-buffer file)))
(widen)
(org-unmodified
(with-silent-modifications
(org-refresh-category-properties)
(org-refresh-properties org-effort-property 'org-effort)
(org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime)