forked from mirrors/org-mode
`org-fill-paragraph' leaves buffer unmodified when doing nothing
* lisp/org.el (org-fill-paragraph): Leave buffer unmodified when nothing was filled. * lisp/org-compat.el: Add forward compatibility with `buffer-hash' function.
This commit is contained in:
parent
0ff4076cb4
commit
0dd2985509
|
@ -81,6 +81,10 @@
|
||||||
(defalias 'org-line-number-display-width 'line-number-display-width)
|
(defalias 'org-line-number-display-width 'line-number-display-width)
|
||||||
(defun org-line-number-display-width (&rest _) 0))
|
(defun org-line-number-display-width (&rest _) 0))
|
||||||
|
|
||||||
|
(if (fboundp 'buffer-hash)
|
||||||
|
(defalias 'org-buffer-hash 'buffer-hash)
|
||||||
|
(defun org-buffer-hash () (md5 (current-buffer))))
|
||||||
|
|
||||||
|
|
||||||
;;; Emacs < 25.1 compatibility
|
;;; Emacs < 25.1 compatibility
|
||||||
|
|
||||||
|
|
35
lisp/org.el
35
lisp/org.el
|
@ -22154,20 +22154,27 @@ filling the current element."
|
||||||
(interactive (progn
|
(interactive (progn
|
||||||
(barf-if-buffer-read-only)
|
(barf-if-buffer-read-only)
|
||||||
(list (when current-prefix-arg 'full) t)))
|
(list (when current-prefix-arg 'full) t)))
|
||||||
(cond
|
(let ((hash (and (not (buffer-modified-p))
|
||||||
((and region transient-mark-mode mark-active
|
(org-buffer-hash))))
|
||||||
(not (eq (region-beginning) (region-end))))
|
(cond
|
||||||
(let ((origin (point-marker))
|
((and region transient-mark-mode mark-active
|
||||||
(start (region-beginning)))
|
(not (eq (region-beginning) (region-end))))
|
||||||
(unwind-protect
|
(let ((origin (point-marker))
|
||||||
(progn
|
(start (region-beginning)))
|
||||||
(goto-char (region-end))
|
(unwind-protect
|
||||||
(while (> (point) start)
|
(progn
|
||||||
(org-backward-paragraph)
|
(goto-char (region-end))
|
||||||
(org-fill-element justify)))
|
(while (> (point) start)
|
||||||
(goto-char origin)
|
(org-backward-paragraph)
|
||||||
(set-marker origin nil))))
|
(org-fill-element justify)))
|
||||||
(t (org-fill-element justify))))
|
(goto-char origin)
|
||||||
|
(set-marker origin nil))))
|
||||||
|
(t (org-fill-element justify)))
|
||||||
|
;; If we didn't change anything in the buffer (and the buffer was
|
||||||
|
;; previously unmodified), then flip the modification status back
|
||||||
|
;; to "unchanged".
|
||||||
|
(when (and hash (equal hash (org-buffer-hash)))
|
||||||
|
(set-buffer-modified-p nil))))
|
||||||
|
|
||||||
(defun org-auto-fill-function ()
|
(defun org-auto-fill-function ()
|
||||||
"Auto-fill function."
|
"Auto-fill function."
|
||||||
|
|
Loading…
Reference in New Issue