That's spiffy.

WRT Johns next comment on mark-defun, I did an apropos on -defun$.
The functions beginning-of-defun and end-of-defun exist (as you
already got those) plus mark-defun (as John pointed out), plus also
narrow-to-defun, not yet discussed.  These are all functions that
could suddenly become useful in Java with a little help.

As a side note, I also discovered `beginning-of-defun-function' and
`end-of-defun-function', which are documented like this:

---------
beginning-of-defun-function's value is 
nil

Documentation:
If non-nil, function for `beginning-of-defun-raw' to call.
This is used to find the beginning of the defun instead of using the
normal recipe (see `beginning-of-defun').  Major modes can define this
if defining `defun-prompt-regexp' is not sufficient to handle the mode's
needs.

The function should go to the line on which the current defun starts,
and return non-nil, or should return nil if it can't find the beginning.
--------

I didn't know these existed till I started searching for other
functions, and might be better than using advice since all other
defun type functions will work with these.

Enjoy
Eric

>>> "David Ponce" <[EMAIL PROTECTED]> seems to think that:
>This is a Multipart MIME message
>--delim.3e6d
>Content-Type: text/plain; charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
>Hello Eric,
>
>Thank you for your help :-)
>
>Attached is a new version of senator with a minor change to
>`senator-next-token' and `senator-previous-token' to return the token at
> point.  Useful when calling these commands non-interactively.
>
>The following advices `beginning-of-defun' and `end-of-defun' to use the
> SEmantic NAvigaTOR if semantic tokens are available and called 
>interactively.
>
>(defadvice beginning-of-defun (around senator activate)
>  "If semantic tokens are available, use them to navigate."
>  (if (and (interactive-p)
>           (featurep 'semantic)
>           semantic-toplevel-bovine-cache)
>      (let ((senator-step-at-start-end-token-ids nil)
>            (senator-step-at-token-ids '(function)))
>        (senator-previous-token))
>    ad-do-it))
>
>(defadvice end-of-defun (around senator activate)
>  "If semantic tokens are available, use them to navigate."
>  (if (and (interactive-p)
>           (featurep 'semantic)
>           semantic-toplevel-bovine-cache)
>      (let* ((senator-step-at-start-end-token-ids '(function))
>             (senator-step-at-token-ids '(function))
>             (token (senator-next-token)))
>        (when (and token
>                   (= (point) (semantic-token-start token)))
>          (goto-char (semantic-token-end token))
>          (senator-message "%S: %s (end)"
>                           (semantic-token-token token)
>                           (semantic-token-name  token))))
>    ad-do-it))
>
>Sincerely,
>David
>
>>>>> John Cooper <[EMAIL PROTECTED]> seems to think that:
>>>"David Ponce" <[EMAIL PROTECTED]> writes:
>>>
>>> > Here is a new version of SEmantic NAvigaTOR with improved 
>navigation in
>>> > semantic token where to step at start and end.
>>> > 
>>> > - `senator-next-token' move the point to the end of token if it was
> at
>>> >   beginning or in the middle of the token.
>>> > 
>>> > - `senator-previous-token' move the point to the beginning of token
> if
>>> >   it was at end or in the middle of the token.
>>>
>>>Thanks, that's definitely better.
>>>
>>>Now, would it be possible to have senator-next-token never take me to 
>the
>>>beginning of a function and have senator-previous-token never take me 
>to the
>>>end of a function?  Then it would work just like {beginning,end}-of-
>defun in C
>>>and Elisp buffers.
>>  [ ... ]
>>
>>Dave & John,
>>
>>  You might be able to do something like this which would make
>>beginning,end defun work with semantic tokens when available.
>>
>>  Note: I didn't test this code, just typed it in here:
>>
>>(defadvice beginning-of-defun (around senator activate)
>>  "If semantic tokens are available, use them to navigate."
>>  (if (and (featurep 'semantic) semantic-toplevel-bovine-cache)
>>     (senator-previous-token)
>>    ad-do-it))
>>
>>This would magically make the traditional keys work properly for
>>non-traditional uses (like java).
  [ ... ]

Reply via email to