all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* when nothing happens, buffer still marked as modified
@ 2018-12-05  2:48 Emanuel Berg
  2018-12-05  6:55 ` Eli Zaretskii
       [not found] ` <mailman.5189.1543993692.1284.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 14+ messages in thread
From: Emanuel Berg @ 2018-12-05  2:48 UTC (permalink / raw)
  To: help-gnu-emacs

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."
  (interactive
   (if (use-region-p)
       (list (region-beginning) (region-end) current-prefix-arg)
     (list (line-beginning-position)
           (save-excursion (forward-paragraph) (point))
           current-prefix-arg)))
  (if (equal justify '(16))  ; C-u C-u        -> unjustify
      (canonically-space-region start end)
    (fill-region
     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)

[1] http://user.it.uu.se/~embe8573/emacs-init/fill-new.el

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-12-06  0:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-05  2:48 when nothing happens, buffer still marked as modified Emanuel Berg
2018-12-05  6:55 ` Eli Zaretskii
     [not found] ` <mailman.5189.1543993692.1284.help-gnu-emacs@gnu.org>
2018-12-05  7:23   ` Emanuel Berg
2018-12-05  8:22     ` Eli Zaretskii
     [not found]     ` <mailman.5196.1543998171.1284.help-gnu-emacs@gnu.org>
2018-12-05 10:09       ` Emanuel Berg
2018-12-05 10:58         ` Eli Zaretskii
2018-12-05 13:39           ` Amin Bandali
2018-12-05 13:57             ` Eli Zaretskii
2018-12-05 15:00           ` Joost Kremers
2018-12-05 17:54             ` Eli Zaretskii
2018-12-05 18:35             ` Michael Heerdegen
     [not found]             ` <mailman.5239.1544035085.1284.help-gnu-emacs@gnu.org>
2018-12-06  0:49               ` Emanuel Berg
2018-12-05 11:58         ` Michael Heerdegen
     [not found]         ` <mailman.5204.1544007548.1284.help-gnu-emacs@gnu.org>
2018-12-06  0:47           ` Emanuel Berg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.