Frank Fischer <[email protected]> writes:

> On Sat, Dec 17, 2011 at 06:32:03AM +0000, Jim Green wrote:
>> Hi, Frank and list:
>> 
>> in evil or emacs how to achive the following two commands?
>> :[range]ri[ght] [width]                                 :ri :right
>>                                                         :le :left
>> :[range]le[ft] [indent]
>
> But, of course, if there is some function doing this,
> it's not a real problem to bind them in ex-mode.

Just for the record...

#+begin_src emacs-lisp

(evil-define-operator evil-align-right (beg end type &optional width)
  "Right-align lines in the region at WIDTH columns.
The default for width is the value of `fill-column'."
  :motion evil-line
  :type line
  (interactive "<R><a>")
  (let ((fill-column (if width
                         (string-to-number width)
                       fill-column))
        adaptive-fill-mode fill-prefix)
    (save-restriction
      (narrow-to-region beg end)
      (goto-char (point-min))
      (while (progn
               (justify-current-line 'right nil t)
               (zerop (forward-line)))))))

(evil-ex-define-cmd "right" 'evil-align-right)

#+end_src

The following snippet would work as well, but it would also canonicalize
whitespace.

#+begin_src emacs-lisp

(evil-define-operator evil-align-right (beg end type &optional width)
  ...
  (let ((paragraph-start "")
        (paragraph-separate "$")
        ...)
    (fill-individual-paragraphs beg end 'right)))

#+end_src


Wolfgang

_______________________________________________
implementations-list mailing list
[email protected]
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list

Reply via email to