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

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

Re: Emacs standards with regions


From: Xah Lee
Subject: Re: Emacs standards with regions
Date: Wed, 26 Nov 2008 06:45:46 -0800 (PST)
User-agent: G2/1.0

On Nov 26, 12:19 am, Andreas Röhler <andreas.roeh...@easy-emacs.de>
wrote:
> Richard Riley wrote:
> > Is there some reason that most emacs commands do not consider active
> > region when invoked? One of the biggest UI improvements (for me) would
> > be for interactive commands to default to the marked region.
>
> > e.g C-s  for isearch-forward
>
> > Hilite "word" and "word" is the default search term. Ditto for % (search
> > and replace). I just modified my py-execute-buffer for example to call
> > py-execute-region with the marked region rather than the entire buffer
> > if the region was active. Why have a seperate "execute-region" command?
>
> > The ignoring of the region in so many key commands makes we wonder if I
> > am missnig a default setting or if there was a decision not to use the
> > region.
>
> > e.g this Google search function I use defaults
>
> > ,----
> > | (defun rgr/google-search-prompt()
> > |   (interactive)
> > |   (let* ((default (region-or-word-at-point))
> > |   (term (read-string (format "Google the web for the following phrase 
> > (%s): "
> > |                                     default))))
> > |     (message "term is %s. Length is %d" term (length term))
> > |     (rgr/google (if (zerop(length term)) default term))
> > |     ))
> > `----
>
> > Can anyone add to this?
>
> AFAIS we have to consider too different cases:
>
> 1) where the region is something like the thing searched for
> 2) the region marks the boundary wherein some action should take place.
>
> You mentioned the first case. Relating to the second,
> default values are not to define in general. Boundaries
> may be every position, even if beginning- or
> end-of-line or paragraph may occur quite often.

hum?

i don't quite understand what you were saying. I don't see what is the
difference of your (1) and (2). I don't quiet see what's (1).

generally, a function need input. If the input is a text, sometimes
that can be just the current word, line, file path, or other semantic
unit, but sometimes it is useful to let the user feed it to the
function.

Checking active region (aka text selection) is a good way to do that.

  Xah
∑ http://xahlee.org/

reply via email to

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