[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

when nothing happens, buffer still marked as modified

From: Emanuel Berg
Subject: when nothing happens, buffer still marked as modified
Date: Wed, 05 Dec 2018 03:48:59 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Here [1] is a function I once wrote. My mind
isn't what it was back then, but testing it
with the different options (the `C-u' combos)
I understand it from a user's perspective and
it seems to do what it says.

Only one thing is missing what I can see, and
that is, when nothing happens (i e the piece of
text is already in the desired shape), the
buffer is still marked as modified (the `**')!

What is the correct way to prevent that?

(defun fill-down (start end &optional justify)
  "Fill the current paragraph from the current line down.\n
With mark active, act upon the region instead.\n
With \\[universal-argument] before invocation, JUSTIFY fully.
With \\[universal-argument] twice, remove full justification. (Or just fill it!)
With \\[universal-argument] thrice, center."
   (if (use-region-p)
       (list (region-beginning) (region-end) current-prefix-arg)
     (list (line-beginning-position)
           (save-excursion (forward-paragraph) (point))
  (if (equal justify '(16))  ; C-u C-u        -> unjustify
      (canonically-space-region start end)
     start end
     (pcase justify
       (`(4)  'full)         ;    C-u         -> justify
       (`(64) 'center) ))))  ;    C-u C-u C-u -> center
                            ;; no C-u         -> none (i e just fill)


underground experts united

reply via email to

[Prev in Thread] Current Thread [Next in Thread]