From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel 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 Organization: JURTA Message-ID: <87wsi47r7u.fsf_-_@jurta.org> References: <878wuq5rgy.fsf@cyd.mit.edu> <87od3mt7yn.fsf@jurta.org> <87vdxuggfl.fsf@cyd.mit.edu> <87od3hdhit.fsf@jurta.org> <87r68ddpnh.fsf@cyd.mit.edu> <87tzd896nj.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1219697568 18027 80.91.229.12 (25 Aug 2008 20:52:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Aug 2008 20:52:48 +0000 (UTC) Cc: emacs-devel@gnu.org To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 25 22:53:41 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KXj4G-0001mj-TN for ged-emacs-devel@m.gmane.org; Mon, 25 Aug 2008 22:53:41 +0200 Original-Received: from localhost ([127.0.0.1]:60677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KXj3I-0003cJ-OM for ged-emacs-devel@m.gmane.org; Mon, 25 Aug 2008 16:52:40 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KXj3D-0003Y7-2U for emacs-devel@gnu.org; Mon, 25 Aug 2008 16:52:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KXj3C-0003Wx-Fi for emacs-devel@gnu.org; Mon, 25 Aug 2008 16:52:34 -0400 Original-Received: from [199.232.76.173] (port=48319 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KXj3C-0003Wo-CM for emacs-devel@gnu.org; Mon, 25 Aug 2008 16:52:34 -0400 Original-Received: from relay03.kiev.sovam.com ([62.64.120.201]:59017) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KXj3B-0003Wf-GO for emacs-devel@gnu.org; Mon, 25 Aug 2008 16:52:33 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay03.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1KXj39-0000bc-A3; Mon, 25 Aug 2008 23:52:31 +0300 In-Reply-To: <87tzd896nj.fsf@jurta.org> (Juri Linkov's message of "Mon, 25 Aug 2008 23:33:20 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) X-Scanner-Signature: 3b10ce253585130f5293a5b36593fd37 X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Trusted X-SpamTest-Info: Profiles 4900 [Aug 24 2008] X-SpamTest-Info: {received from trusted relay: common white list} X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: white ip list X-SpamTest-Rate: 10 X-SpamTest-Status: Trusted X-SpamTest-Status-Extended: trusted X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0278], KAS30/Release X-detected-kernel: by monty-python.gnu.org: FreeBSD 6.x (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:102967 Archived-At: 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/