all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Andreas Röhler" <andreas.roehler@online.de>
To: emacs-devel@gnu.org
Cc: "Stephen J. Turnbull" <stephen@xemacs.org>,
	Andreas Schwab <schwab@linux-m68k.org>
Subject: Re: forward-paragraph return value
Date: Tue, 24 Aug 2010 19:10:59 +0200	[thread overview]
Message-ID: <4C73FD23.8020302@online.de> (raw)
In-Reply-To: <87sk245i5v.fsf@uwakimon.sk.tsukuba.ac.jp>

Am 24.08.2010 14:06, schrieb Stephen J. Turnbull:
> Andreas Röhler writes:
>   >  Am 24.08.2010 10:27, schrieb Stephen J. Turnbull:
>   >  >  Andreas Röhler writes:
>   >  >
>   >  >    >   Then people may write functions taking already the return
>   >  >    >   value.
>   >  >  Sure.  But will they?  Show us examples of existing functions
>   >  >  (preferably already in Emacs) that would benefit from this
>   >  >  change.
>   >  >
>   >
>   >  Didn't I point to?
>   >
>   >  If a look in forward-paragraph doesn't speak to you,
>
> Of course that doesn't speak to me; that's the function you propose to
> change.
>
>   >  maybe have a look into
>   >
>   >  bounds-of-thing-at-point .
>
> `forward-paragraph' is a command.  `bounds-of-thing-at-point' is not.
> There's a big difference.
>
>   >  Forms like
>   >           (let
>   >             (beg
>   >               (progn
>   >                (funcall
>   >                 (or (get thing 'beginning-op)
>   >                                 (lambda () (forward-thing thing -1))))
>   >                (point))))
>
> I doubt that form appears anywhere in Emacs.  The style is nauseating,
> not to mention that `progn' is a very unusual choice for a variable
> you are let-binding. ;-)  Please give *real* examples,

it is, just the var is called real-beg, which make things still more 
confusion and has been
let aside here as an example was the concern

                       (real-beg
                (progn
              (funcall
               (or (get thing 'beginning-op)
                               (lambda () (forward-thing thing -1))))
              (point))))

Also you may see

           ;; If that brings us all the way back to ORIG,
           ;; it worked.  But END may not be the real end.
           ;; So find the real end that corresponds to BEG.
           (let ((real-end
              (progn
                (funcall
                 (or (get thing 'end-op)
                                 (lambda () (forward-thing thing 1))))
                (point))))

> or if you're
> going to simplify real code to make your point, say that's what you're
> doing.

Please stop insinuations.

>    And do it correctly, even for a fragment like this.
>
>   >  Thats bug-sourcing BTW, as it returns point in any case, even if
>   >  move failed.  Why not make implementation of return value from
>   >
>   >  search-forward
>   >
>   >  canonical instead, returning the position if succesful, nil
>   >  otherwise.
>
> Er, because otherwise `search-forward' does not return nil, but rather
> signals an error?  You need to specify additional arguments to get it
> to return nil.  There's a reason for this interface, related to the
> fact that `search-forward' is a command, as is `forward-paragraph'.
>
>   >  The gain will be for newly written code.  For writers first, who
>   >  must not learn function by function the return value.
>
> A common convention might be a good idea.  It's a better idea for
> non-commands than it is for commands, though.
>
>   >  In the example above we could write
>   >
>   >  (let
>   >       (beg
>   >        (funcall
>   >         (or (get thing 'beginning-op)
>   >             (lambda () (forward-thing thing -1))))))
>   >
>   >  Its clean and much more reliable, as beg will be nil, if nothing
>   >  was found.
>
> Maybe.  But in fact, this is a (broken) copy of (part of) the
> implementation of `bounds-of-thing-at-point'.  At least in XEmacs,
> that function has *much* bigger problems than the return value of
> forward-thing.

Same in Emacs. But for the reasons just started to discuss. It's simply 
not written to the end, not
thought through. Or it's author had to leave in the middle of his work.

I wonder what happened, as it's a great set-out, a fine idea.
For me one of the most interesting stuff in Emacs.
Thanks BTW.

Andreas




>   Also, since the return value of `forward-thing' is
> undocumented (and probably rather unreliable), you could change that,
> or define an internal function for the use of functions defun'ed in
> thingatpt.el.
>
> The issue with forward-paragraph is quite different, because it is
> documented and it is a command.
>
>
>    




      reply	other threads:[~2010-08-24 17:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-23 18:25 forward-paragraph return value Andreas Röhler
2010-08-23 20:59 ` Andreas Schwab
2010-08-24  5:43   ` Andreas Röhler
2010-08-24  8:27     ` Stephen J. Turnbull
2010-08-24  9:14       ` Andreas Röhler
2010-08-24 11:30         ` Davis Herring
2010-08-24 16:57           ` Andreas Röhler
2010-08-24 12:06         ` Stephen J. Turnbull
2010-08-24 17:10           ` Andreas Röhler [this message]

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=4C73FD23.8020302@online.de \
    --to=andreas.roehler@online.de \
    --cc=emacs-devel@gnu.org \
    --cc=schwab@linux-m68k.org \
    --cc=stephen@xemacs.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.