Re: emacs / distel problem with dynamic tags

"Bill Clementson" <[email protected]> Wed, 4 Jul 2007 16:51:31 -0700
Newsgroups gmane.comp.lang.erlang.distel.devel
Message-ID <[email protected]>
Hi Matthias,

On 7/4/07, [email protected] <[email protected]> wrote:
> "Bill Clementson" <[email protected]> writes:
>
> > On 7/4/07, Matthias Radestock <[email protected]> wrote:
> >>
> >> I cannot think of any reason why one would regularly use the prefix arg
> >> for erl-find-source-under-point. All it does is prompt for the function
> >> to look up. erl-find-mod does the same thing, and without requiring a
> >> prefix arg, and hence wouldn't suffer from the reported problem.
> >
> > Both erl-find-mod and erl-find-source-under-point call erl-find-source
>
> Correct.
>
> > (which had the call to erl-target-node in it that was causing the
> > problem).
>
> Not quite. The problem only occurs when one supplies a prefix arg.
> erl-find-mod doesn't ordinarily take a prefix arg, so there is no reason
> to call it with one.
>
> In other words, the old behaviour of "C-u M-x
> erl-find-source-under-point" is identical to the (old and new) behaviour
> of "M-x erl-find-mod".
>
> Actually, that's not quite true. C-u M-x erl-find-source-under-point
> defaults the selection to the module/function under the point, whereas
> erl-find-mod does not. Also, erl-find-mod is not bound to a convenient
> key sequence.

Yes, in fact I didn't realize it even existed before you commented on
it. It's not mentioned in the distel.texi documentation and (since it
isn't bound to any key binding) it doesn't show up when you do a "C-h
m" or a "C-c C-d h" (which most emacs users frequently use when
learning commands for a mode). I'm not sure what the history is of
erl-find-mod (it's not mentioned in the Changelog), though I had the
feeling that there might be "legacy code" reasons for it being in
distel as its functionality seems to have been subsumed by
erl-find-source-under-point.

> So back to the drawing board ...
>
> The trouble here is that we need to cater for all of the following uses:
>
> 1) "find a specified module/function, using the current node"
>
> 2) "find a specified module/function, using a specified node"
>
> 3) "find the module/function under point, using the current node"
>
> 4) "find the module/function under point, using a specified node"
>
> 5) "find a specified module/function, but use the module/function under
> point as first guess that can be refined, using the current node"
>
> 6) "find a specified module/function, but use the module/function under
> point as first guess that can be refined, using a specified node".
>
> Before my change (and after yours) the shortest sequences to accomplish
> the above were/are as follows:
>
> 1) M-x erl-find-mod (enter m/f)

or I would use: C-u M-. (enter m/f)

> 2) C-c C-d C-n (enter node name) M-x erl-find-mod
> 3) M-.
> 4) C-c C-d C-n (enter node name) M-.
> 5) C-u M-. (confirm or enter m/f)
> 6) C-c C-d C-n (enter node name) C-u M-. (confirm or enter m/f)
>
> After my change the sequences were:
>
> 1) M-x erl-find-mod (enter m/f)

now, my previous: C-u M-. (enter m/f)
is replaced by: C-u M-. (enter node name) (enter m/f)

> 2) C-u M-x erl-find-mod (enter node name)
> 3) M-.
> 4) C-u M-. (enter node name) (confirm m/f)
> 5) C-u M-. (enter node name) (confirm or enter m/f)
> 6) C-u M-. (enter node name) (confirm or enter m/f)
>
> I reckon the additional keystroke in 4) is ok. What isn't so great is
> the requirement to enter the node name on 5). We could
>
> a) revert to the old behaviour, as you did.
>
> b) go with the new behaviour, unmodified. I am struggling to think of a
> reason why one would want to perform 5) on a regular basis. So the
> inconvenience should be minimal, certainly compared to the gain of
> having a convenient and *consistent* mechanism of getting prompted for a
> node name. To be sure we could try to find out from the OP what exactly
> they are trying to accomplish.

Actually, the default that is displayed when you do "C-u M-." is m:f/a
(where the "a" is the arity). Since I'm still a newbie at erlang, I
frequently press "C-u M-." on a function and specify a different "a"
value. I don't know if this is common or not; however, I seem to do it
on a regular basis.

> c) add node name defaulting + history to the node name selection. This
> would reduce the sequence to
>  C-u M-. (confirm node name) (confirm or enter m/f)
> i.e. a single keystroke more than before. It's also a nice feature in
> general.
>
> d) make erl-find-mod default the m/f selection to the m/f under point
> and bind the command to a key sequence. This makes it almost identical
> to erl-find-source-under-point, the only difference being that it
> *always* prompts for the m/f selection. There is then no point having a
> prefix-triggered m/f prompt on erl-find-source-under-point, so we should
> ditch that feature.
>
> Any other ideas? My personal preference is the combination of
> c)+d). Unfortunately that also takes the longest time to
> implement. Having said that, it probably took me longer to write this
> email ;)

My preference would be either a) or c).

My personal preference (at the moment), would be a) as I would almost
always have switched to the node that I would be doing the "C-u M-."
lookup on prior to my doing the command. However, this is probably due
to my erlang newbie status and I would probably find that I do want to
do source lookups on other nodes in the future. However (when I
consider how I usually use "M-."), I might be quite happy with a) even
once I'm more accomplished with erlang since the need to press ENTER
on the node for c) is compounded when you're doing multiple m:f/a
lookups. For example, I will often do multiple source lookups on
functions with different arities as I drill down into functions that
are called by the function that I initially go to. And, once I've
changed the node, I no longer have to specify the node again on
subsequent searches whereas with c) I would have to press ENTER at the
node prompt each time.

Option b) and d) are probably bad choices as they negatively impact
users who are accustomed to using "C-u M-." as it existed before the
mods. I don't really like the idea of having multiple key bindings
(nor multiple commands) for source lookup. So, I guess that (if I had
to pick only one option) I would select a) and eliminate erl-find-mod
altogether. However, I guess that other people might be using
erl-find-mod as well, so eliminating erl-find-mod probably isn't an
option. For the same reason (e.g. - other people are used to using
"C-u M-." to specify a m/f/a for a source lookup), options b) and d)
probably aren't good options.

However, I like the mod you made to erl-target-node and it is good to
try to keep behaviour consistent (although an argument could be made
that the prefix arg node selection functionality should only apply to
distel functions that have "node" as an argument and erl-find-source
does not have "node" as an argument and it has always done a search on
the current node). So, option c) would be the option that I would most
favour if you feel that it is still a good idea to do prefix arg node
selection with "C-u M-.".

-- 
Bill Clementson

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/