From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: Emacs standards with regions Date: Wed, 26 Nov 2008 09:19:45 +0100 Message-ID: <492D06A1.8080703@easy-emacs.de> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1227687602 15173 80.91.229.12 (26 Nov 2008 08:20:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 26 Nov 2008 08:20:02 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Richard Riley Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 26 09:21:05 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L5Fds-0007aW-Cj for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Nov 2008 09:21:00 +0100 Original-Received: from localhost ([127.0.0.1]:49267 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L5Fci-0001kR-GT for geh-help-gnu-emacs@m.gmane.org; Wed, 26 Nov 2008 03:19:48 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L5FcI-0001h5-46 for help-gnu-emacs@gnu.org; Wed, 26 Nov 2008 03:19:22 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L5FcG-0001ek-0P for help-gnu-emacs@gnu.org; Wed, 26 Nov 2008 03:19:21 -0500 Original-Received: from [199.232.76.173] (port=34127 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L5FcF-0001e8-JT for help-gnu-emacs@gnu.org; Wed, 26 Nov 2008 03:19:19 -0500 Original-Received: from moutng.kundenserver.de ([212.227.126.188]:60019) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L5FcE-0001rA-Se for help-gnu-emacs@gnu.org; Wed, 26 Nov 2008 03:19:19 -0500 Original-Received: from [192.168.178.27] (p54BE9307.dip0.t-ipconnect.de [84.190.147.7]) by mrelayeu.kundenserver.de (node=mrelayeu8) with ESMTP (Nemesis) id 0ML31I-1L5Fc21c7K-0006aH; Wed, 26 Nov 2008 09:19:07 +0100 User-Agent: Thunderbird 2.0.0.6 (X11/20070801) In-Reply-To: X-Provags-ID: V01U2FsdGVkX18ju74oe5yiDOkJheEKLbVTKohorXBwOXOs4CM sW/FeasVpvvhw+o+wAb8/2c2gHfrUKr4oVmgiIQB+1UnG4dX9j M2WgB+02edS0LIZDFkJixzrYcUKVsYNr6JIj2TIDzI= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6? (barebone, rare!) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:60117 Archived-At: 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. For my purposes I use a template, which inserts this in an assumed `let' ((beg (cond (beg beg) ((region-active-p) (region-beginning)) (t (line-beginning-position)))) (end (cond (end (copy-marker end)) ((region-active-p) (copy-marker (region-end))) (t (copy-marker (line-end-position)))))) Afterwards I have to change (line-beginning-position) etc., should it not be the right thing. `region-active-p' is defined as (unless (featurep 'xemacs) (defun region-active-p () (and mark-active transient-mark-mode (not (eq (region-beginning) (region-end)))))) Andreas Röhler