help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: DWIM region


From: Emanuel Berg
Subject: Re: DWIM region
Date: Sun, 07 Jan 2018 04:25:35 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

OK, I spoke to soon! There were *two* cases
I didn't change. Here is the second one.
The reason I didn't change this is the use of
the prefix argument.

If there is no interactive string, does that
mean one has to check manually in the
interactive form for a/the prefix argument?

PS. Pretty cool code, ey? :)

(defun fill-down (&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 "P")
  (let*((area (if (use-region-p)
                  (list (region-beginning) (region-end))
                (list (line-beginning-position) (save-excursion
                                                  (forward-paragraph)
                                                  (point) ))))
        (start (car  area))
        (end   (cadr area)) )
    ;; C-u C-u -> unjustify
    (if (equal justify '(16))
        (canonically-space-region start end)
      (fill-region start end
       ;; can't use cl-case here as compares with `elq' - bummer!
       (cond ((equal justify  '(0))  nil)     ; fill
             ((equal justify  '(4)) 'full)    ; C-u -> justify
             ((equal justify '(64)) 'center)) ; C-u C-u C-u -> center
       ))))

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


reply via email to

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