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).
>
>Enjoy
>Eric
>
>--
>|\/\/\___/\/\/|  Eric Ludlam                 [EMAIL PROTECTED];
[EMAIL PROTECTED]
>\____ o o ____/  Homepage:                      http://www.ultranet.com
/~zappo
>     )   (       Trebuchets:    http://www.ultranet.com/~zappo/
trebuchet.shtml
>    ( * * )      GNU:                                      http://www.gnu.org
>     \___/       Trevor Shea Ludlam:            Oct 16th, 1999, 5lbs
11oz 18in
>
>
>

senator.el

Reply via email to