unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stephen J. Turnbull" <turnbull@sk.tsukuba.ac.jp>
To: "Andreas Röhler" <andreas.roehler@online.de>
Cc: Antoine Levitt <antoine.levitt@gmail.com>,
	Lennart Borgman <lennart.borgman@gmail.com>,
	Stefan Monnier <monnier@IRO.UMontreal.CA>,
	emacs-devel@gnu.org
Subject: Re: Errors in interactive commands
Date: Thu, 04 Aug 2011 11:15:16 +0900	[thread overview]
Message-ID: <87vcudhqh7.fsf@uwakimon.sk.tsukuba.ac.jp> (raw)
In-Reply-To: <4E392365.2080401@online.de>

Andreas Röhler writes:

 > > and you need to define it and show that there is a unified
 > > definition powerful enough to make it worthwhile to introduce a
 > > backward-incompatible change.

[...]

 > for example the implemented form forward-word already sends nil,
 > not error, when buffer-end is reached. Remains still to get it
 > messaged.
 > 
 > Thus implemented forward-word would allow a similar writing as
 > below.

Sure.  You said that already, you should assume we understand that.
(Especially since XEmacs already specifies `forward-word' to fail with
nil rather than an error at buffer boundaries, you should assume that
I know that.  Even though Emacs rarely worries more than a plugged
nickel about XEmacs compatibility, I think in this case it's actually
the strongest argument you have.  Ie, the backward compatibility
problem is probably hardly important.  Search for `(featurep 'xemacs)'
near `forward-word' to verify.)

Now we have two use cases, one of which needs the error, and one of
which prefers a null return.  That fails the "unified" test (see my
partial quote reproduced above).

If you want to use this idiom, it is easy, though somewhat inefficent,
to get your desired behavior via

(defun my-forward-word (&optional COUNT BUFFER)
  "exercise for the the reader"
  (condition-case nil
      (forward-word)
    ((beginning-of-buffer end-of-buffer) nil)

If you do this a lot, it's trivial to implement a macro.

I really don't think it's worth your while to fight this.

 > (defun my-collects ()
 >   "Report and return all word boundaries in current buffer, a list. "
 >    (interactive)
 >    (goto-char (point-min))
 >    (let ((positions-reached nil)
 >          (word-bounderies nil)
 >          erg bnds)
 >      (while (setq erg (ar-forward-word-atpt))
 >        (add-to-list 'positions-reached erg)
 >        (setq bnds (ar-bounds-of-word-atpt))
 >        (add-to-list 'word-bounderies bnds))
 >      (when (interactive-p) (message "positions-reached: %s" 
 > positions-reached))
 >      (when (interactive-p) (message "word-bounderies: %s" word-bounderies))
 > ;;    positions-reached
 >      word-bounderies
 >      ))
 > 
 > Just try to write that with means commonly available.

It's trivial, of course.  For the single line containing "while",
substitute

(while (and (save-excursion (skip-syntax-forward "^w") (not (eobp)))
            (setq erg (ar-forward-word-atpt)))

Of course it's prettier with `forward-word' specified your way, but
similarly the case I have in mind where partial failure of multiple
unit movement is an invalid state, not a termination condition, is
prettier with the current definition.




  reply	other threads:[~2011-08-04  2:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-02 17:46 Errors in interactive commands Antoine Levitt
2011-08-02 19:04 ` Andreas Röhler
2011-08-02 19:15 ` Lennart Borgman
2011-08-02 19:18   ` Lars Magne Ingebrigtsen
2011-08-03  7:13   ` Stephen J. Turnbull
2011-08-03  9:28     ` Lennart Borgman
2011-08-02 19:25 ` Stefan Monnier
2011-08-02 19:36   ` Lennart Borgman
2011-08-03  6:13     ` Andreas Röhler
2011-08-03  7:28       ` Stephen J. Turnbull
2011-08-03  7:46         ` Andreas Röhler
2011-08-03  8:08           ` David Kastrup
2011-08-03  8:34             ` Andreas Röhler
2011-08-03  9:09           ` Stephen J. Turnbull
2011-08-03 10:31             ` Andreas Röhler
2011-08-04  2:15               ` Stephen J. Turnbull [this message]
2011-08-03  9:37         ` Lennart Borgman
2011-08-03  9:45           ` Andreas Schwab
2011-08-03 14:41             ` Stefan Monnier
2011-08-03 15:01               ` Lennart Borgman

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vcudhqh7.fsf@uwakimon.sk.tsukuba.ac.jp \
    --to=turnbull@sk.tsukuba.ac.jp \
    --cc=andreas.roehler@online.de \
    --cc=antoine.levitt@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=lennart.borgman@gmail.com \
    --cc=monnier@IRO.UMontreal.CA \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).