From: Juri Linkov <juri@jurta.org>
To: Dan Nicolaescu <dann@ics.uci.edu>
Cc: emacs-devel@gnu.org
Subject: Re: TAB when the region is active
Date: Mon, 24 Sep 2007 03:07:57 +0300 [thread overview]
Message-ID: <871wcokiuq.fsf@jurta.org> (raw)
In-Reply-To: <200709220100.l8M10Ub3008452@oogie-boogie.ics.uci.edu> (Dan Nicolaescu's message of "Fri\, 21 Sep 2007 18\:00\:30 -0700")
> I have committed the patch.
>
> cc-mode would need to be updated to do the same thing. I emailed the
> maintainer.
>
> Other major modes might need updates too. We can do them as soon as we
> find out they need changes.
Thanks! It's a pity this very good feature doesn't work yet in c-mode.
I also tried it in some other modes (fundamental-mode, text-mode)
and it doesn't do something useful here. It inserts a single TAB whereas
C-M-\ (`indent-region') tries to indent the region. However, what C-M-\
does in text modes is not useful too because it shifts each consequent
line relative to the previous line in a staircase-like style.
So perhaps there is nothing useful it can do in text modes.
What would be useful to do in text modes is to make a similar change for
M-q (`fill-paragraph'). When the region is active in transient-mark-mode,
then M-q would call `fill-region' instead of `fill-paragraph'.
Please note that there was a keybinding for `fill-region' in bindings.el
but currently it is commented out because there are no free keybindings
for it. Using M-q to fill the active region would be convenient for users
of transient-mark-mode.
Below is a patch that implement the new command `fill-paragraph-or-region':
Index: lisp/bindings.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/bindings.el,v
retrieving revision 1.184
diff -c -r1.184 bindings.el
*** lisp/bindings.el 20 Sep 2007 21:49:18 -0000 1.184
--- lisp/bindings.el 24 Sep 2007 00:04:22 -0000
***************
*** 1041,1048 ****
(define-key ctl-x-map "rw" 'window-configuration-to-register)
(define-key ctl-x-map "rf" 'frame-configuration-to-register)
! (define-key esc-map "q" 'fill-paragraph)
! ;; (define-key esc-map "g" 'fill-region)
(define-key ctl-x-map "." 'set-fill-prefix)
\f
(define-key esc-map "{" 'backward-paragraph)
--- 1041,1047 ----
(define-key ctl-x-map "rw" 'window-configuration-to-register)
(define-key ctl-x-map "rf" 'frame-configuration-to-register)
! (define-key esc-map "q" 'fill-paragraph-or-region)
(define-key ctl-x-map "." 'set-fill-prefix)
\f
(define-key esc-map "{" 'backward-paragraph)
Index: lisp/textmodes/fill.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/textmodes/fill.el,v
retrieving revision 1.205
diff -c -r1.205 fill.el
*** lisp/textmodes/fill.el 26 Jul 2007 05:27:32 -0000 1.205
--- lisp/textmodes/fill.el 24 Sep 2007 00:04:56 -0000
***************
*** 1007,1012 ****
--- 1007,1022 ----
(goto-char end))))
fill-pfx))
+ (defun fill-paragraph-or-region (arg)
+ "Fill the active region or paragraph."
+ (interactive (progn
+ (barf-if-buffer-read-only)
+ (list (if current-prefix-arg 'full))))
+ (if (and transient-mark-mode mark-active
+ (not (eq (region-beginning) (region-end))))
+ (fill-region (region-beginning) (region-end) arg)
+ (fill-paragraph arg)))
+
\f
(defcustom default-justification 'left
"*Method of justifying text not otherwise specified.
--
Juri Linkov
http://www.jurta.org/emacs/
next prev parent reply other threads:[~2007-09-24 0:07 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-14 21:59 TAB when the region is active Dan Nicolaescu
2007-09-16 5:35 ` Richard Stallman
2007-09-17 4:09 ` Dan Nicolaescu
2007-09-17 22:24 ` Richard Stallman
2007-09-17 22:40 ` Lennart Borgman (gmail)
2007-09-17 22:47 ` Drew Adams
2007-09-17 23:28 ` Dan Nicolaescu
2007-09-19 3:42 ` Dan Nicolaescu
2007-09-19 5:11 ` Drew Adams
2007-09-19 13:45 ` Stefan Monnier
2007-09-19 14:34 ` Drew Adams
2007-09-19 13:45 ` Stefan Monnier
2007-09-20 1:54 ` Dan Nicolaescu
2007-09-20 13:52 ` Stefan Monnier
2007-09-22 1:00 ` Dan Nicolaescu
2007-09-24 0:07 ` Juri Linkov [this message]
2007-09-24 1:09 ` Drew Adams
2007-09-24 1:15 ` Juri Linkov
2007-09-24 3:50 ` Stefan Monnier
2007-09-29 23:18 ` M-q when the region is active (Re: TAB when the region is active) Juri Linkov
2007-09-30 12:54 ` Richard Stallman
2007-10-06 22:43 ` M-$ when the region is active (Re: M-q " Juri Linkov
2007-09-24 18:20 ` TAB when the region is active Richard Stallman
2007-09-24 2:37 ` Dan Nicolaescu
2007-09-24 18:20 ` Richard Stallman
2007-09-17 23:13 ` Dan Nicolaescu
2007-09-16 18:48 ` Lennart Borgman
2007-09-16 19:17 ` Paul Pogonyshev
2007-09-16 20:32 ` Drew Adams
2007-09-17 3:59 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871wcokiuq.fsf@jurta.org \
--to=juri@jurta.org \
--cc=dann@ics.uci.edu \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.