From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: Emacs standards with regions Date: Mon, 24 Nov 2008 08:46:17 -0800 (PST) Organization: http://groups.google.com Message-ID: <6efed95f-a075-45b4-b990-c7d00e34adb4@k24g2000pri.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1227558052 18576 80.91.229.12 (24 Nov 2008 20:20:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 24 Nov 2008 20:20:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 24 21:21:46 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 1L4hw5-0008Rs-EC for geh-help-gnu-emacs@m.gmane.org; Mon, 24 Nov 2008 21:21:34 +0100 Original-Received: from localhost ([127.0.0.1]:54457 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L4huw-0006Vk-9k for geh-help-gnu-emacs@m.gmane.org; Mon, 24 Nov 2008 15:20:22 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!k24g2000pri.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 225 Original-NNTP-Posting-Host: 24.6.185.159 Original-X-Trace: posting.google.com 1227545178 15209 127.0.0.1 (24 Nov 2008 16:46:18 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 24 Nov 2008 16:46:18 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k24g2000pri.googlegroups.com; posting-host=24.6.185.159; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.26.2 (KHTML, like Gecko) Version/3.2 Safari/525.26.12, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:164732 X-Mailman-Approved-At: Mon, 24 Nov 2008 15:05:59 -0500 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:60065 Archived-At: On Nov 24, 7:03 am, Richard Riley wrote: > One of the biggest UI improvements (for me) would > be for interactive commands to default to the marked region. i feel exactly the same way. If emacs commands use active region as a way for alternative behavior (similiar to many commands using Ctrl+u to change behavior), i think that's a improvement. almost all my own commands, will consider active region if there is one, and act on that. There are about 30 of them. My examples includes: =E2=80=A2 lookup-google, lookup-php-ref, lookup-wikipedia, lookup-word-def, lookup-word-definition =E2=80=A2 amazon-linkify, blog-url-linkify, curve-linkify, elisp-ref-linkif= y, emacs-ref-linkify, full-size-img-linkify, google-search-linkify, image- linkify, java-ref-linkify, local-linkify, mathematica-ref-linkify, nks- linkify, perldoc-ref-linkify, php-ref-linkify, povray-ref-linkify, python-ref-linkify, source-linkify, wikipedia-linkify, youporn-search- linkify, youtube-linkify, youtube-search-linkify =E2=80=A2 make-backup, make-html-table, make-word-entry, make-wiki-entry, m= ake- time-mag-src a very good example of this is a command that deal with letter cases. Recently i wrote about it here: =E2=80=A2 Usability Problems With Emacs's Letter-Case Commands http://xahlee.org/emacs/modernization_upcase-word.html --------------------------------- =C2=ABIs there some reason that most emacs commands do not consider active region when invoked?=C2=BB I think the reason is that, transient-mark-mode, and thus the concept of active-region (i.e. known as Text Selection in modern terminology), is a later add on. I'm guessing it is added in late 1990s or perhaps after 2000. It is a add-on as some kinda compatibility with modern UI, and probably is not considered as the emacs's way by most emacs developers. does anyone know when did transient-mark-mode come to emacs? Even today, Richard Stallman is still rather anti transient-mark-mode. (if you read emacs dev, he doesn't use it) For example, recently i filed a bug report about delete-selection-mode, here: Subject: bug#1120: issues on (put 'insert-date 'delete-selection t) http://groups.google.com/group/gnu.emacs.bug/browse_frm/thread/ba8ab4a52235= 91b7 In the discussion, i wrote: =C2=AB For elisp programers who wish to write extentions where the command's behaviors change depending on whether user has delete-selection-mode on, what should they do? Check for mark-active and delete-selection- mode before any call to the insert function? also, the current behavior seems to introduce a complexity, where command behaves differently depending on whether it is invoked by a keybinding or by M-x. =C2=BB and Richard Stallman wrote: =C2=ABIf you really want to make behavior depend on those variables, you need to check them. Whether you check them before or after calling `insert' is up to you. But that seems like a strange thing to do.=C2=BB The thread where this is discussed is here: Subject: (insert ...) won't respect delete-selection-mode Date: 2008-10-07 http://groups.google.com/group/gnu.emacs.help/browse_frm/thread/8cc49311d17= b2a71 ----------------- I have put a lot thought in this issue, which of the 2 behaviors on the region is superior in some technical sense (while disregard all issues about =E2=80=9CModern UI=E2=80=9D or =E2=80=9CStandard practice=E2= =80=9D). Supeior here means aspects of user operative efficiency, and power/flexibilty of commands using one or the other paradigm. To be precise, here's 2 behavior considered: (1) The emacs traditional way. Namely, there is always a region, and commands that might be useful to work on region, will have few choices of interface: (A) have multiple versions of the command, one ending in =E2=80=9C-region=E2=80=9D. (B) using universal argument mechanism (Ctrl+u) = to specify whether the command acts on region. (note: a region in emacs is from last mark to current cursor position, and there is always a region as soon as user did a mark once in a buffer) (2) The modern UI practice, meaning, a region in emacs can be active or inactive. For commands that might be useful to consider applying to the region, it has these choices: (A) same as above. (B) same as above. (C) Act on region if there is a active region (aka text selection). Now, notice, that majority of emacs's commands use paradigm (1). However, some of emacs's commands, do use paradim (2) and (C). For example, comment-dwim is a good example. I haven't studied this extensively, but basically, i think (C) behavior is the superior one, that is: it is faster to invoke (less keystrokes, regardless what easy key shortcuts you may have setup), more intuitive to vast majority of computer users today, involves less thinking. Also note, for paradigm (2), it means that you must have transient- mark-mode or cua-mode on. In other words, if you never use or want region highlighting, you'll not find any possibly extra benefit of commands that uses paradigm (2). As noted before, transient-mark-mode and cua-mode are not on by default, and they both are added to emacs as some compatibility mode, and it is reasonable to assume that most emacs developers don't consider them genuine =E2=80=9Cemacs way=E2=80=9D, thus i think that's the = reason paradigm (2) is not much used in emacs even for newer packages. i heard that in the current dev version of emacs, cua-mode is on by default. I think that might usher more emacs commands to use paradigm (2)... ----------------------------- Note that the main purpose of transient-mark-mode is to have region highlight, and in emacs, this cannot be possible without introducing the concept of active region. But now, with the concept of active region, it necessarily divide command UI paradigm into 2 groups, one that is the emacs's traditional way of always having a region, as the above paradigm (1), vs one that consider region as active/inactive as above (2). In short, in order to maintain emacs's traditional concept of region, and in order to have region highlighting, spawned the 2 UI paradigms that are not necessarily consistant with each other. If you want the feature of region highlighting yet not obsolete the traditional concept of emacs region and with it htousands of existing commands, then these 2 not-necessarily consistent UI paradigms are inevitable. In a ideal world, i would say it'd be better to exam and change the few thousand of emac's commands so that they all consider active region, and as a consequence possibly reducing tens of them. But this is not realistic. On the other hand, i do not think it would introduce any practical UI inconsistency if more commands starts to consider active region. ----------------------------- one thing i personally want is to have isearch automatically use the current text selection for search. (this is a frequently asked question) I tried to write my own custome function to do this but it turns out not easy ... as long as transient-mark-mode is not on by default, much of the above thoughts won't even be possible. With cua-mode on by default in the next version of emacs, i think that's a giant step forward. ------------------------------ =C2=ABimportant and urgent problems of the technology of today are no longer the satisfactions of the primary needs or of archetypal wishes, but the reparation of the evils and damages by the technology of yesterday. ~Dennis Gabor, Innovations: Scientific, Technological and Social, 1970=C2=BB Great words! ... looking up Wikipedia, here's the url: http://en.wikipedia.org/wiki/Dennis_Gabor ... bah, spent too much time writing this post... Sorry for the wordiness. Xah =E2=88=91 http://xahlee.org/ =E2=98=84 On Nov 24, 7:03 am, 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 phr= ase (%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? > > -- > important and urgent problems of the technology of today are no longer t= he satisfactions of the primary needs or of archetypal wishes, but the repa= ration of the evils and damages by the technology of yesterday. ~Dennis Ga= bor, Innovations: Scientific, Technological and Social, 1970