emacs-devel
[Top][All Lists]
Advanced

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

center-line on region (was: bug#684: 23.0.60; text-mode redefines "\es",


From: Juri Linkov
Subject: center-line on region (was: bug#684: 23.0.60; text-mode redefines "\es", the new search-map prefix)
Date: Mon, 25 Aug 2008 23:52:05 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu)

BTW, I noticed that `center-line' doesn't take into account the active
region like `fill-paragraph' already does.  I propose the following patch
to do exactly the same, i.e. to center each line in the active region
when center-line is called interactively and the region is active:

Index: lisp/textmodes/text-mode.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/textmodes/text-mode.el,v
retrieving revision 1.56
diff -c -w -b -r1.56 text-mode.el
*** lisp/textmodes/text-mode.el 25 Aug 2008 20:31:52 -0000      1.56
--- lisp/textmodes/text-mode.el 25 Aug 2008 20:49:17 -0000
***************
*** 153,164 ****
  
  (define-key facemenu-keymap "\es" 'center-line)
  
! (defun center-line (&optional nlines)
    "Center the line point is on, within the width specified by `fill-column'.
  This means adjusting the indentation so that it equals
  the distance between the end of the text and `fill-column'.
! The argument NLINES says how many lines to center."
!   (interactive "P")
    (if nlines (setq nlines (prefix-numeric-value nlines)))
    (while (not (eq nlines 0))
      (save-excursion
--- 153,171 ----
  
  (define-key facemenu-keymap "\es" 'center-line)
  
! (defun center-line (&optional nlines region)
    "Center the line point is on, within the width specified by `fill-column'.
  This means adjusting the indentation so that it equals
  the distance between the end of the text and `fill-column'.
! The argument NLINES says how many lines to center.
! 
! Interactively (when `region' is non-nil) in Transient Mark mode when
! the mark is active, call `center-region' to center each nonblank line
! in the active region."
!   (interactive (list current-prefix-arg t))
!   ;; Center the region if it is active when called interactively.
!   (if (and region (region-active-p))
!       (center-region (region-beginning) (region-end))
      (if nlines (setq nlines (prefix-numeric-value nlines)))
      (while (not (eq nlines 0))
        (save-excursion
***************
*** 179,185 ****
           (forward-line 1))
          ((< nlines 0)
           (setq nlines (1+ nlines))
!          (forward-line -1)))))
  
  ;; arch-tag: a07ccaad-da13-4d7b-9c61-cd04f5926aab
  ;;; text-mode.el ends here
--- 186,192 ----
             (forward-line 1))
            ((< nlines 0)
             (setq nlines (1+ nlines))
!            (forward-line -1))))))
  
  ;; arch-tag: a07ccaad-da13-4d7b-9c61-cd04f5926aab
  ;;; text-mode.el ends here

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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