Re[1]: semantic-tag-folding.el

2005-02-20 Thread Eric M. Ludlam
Hi,

  That is quite nifty.  I wrote one also which is in CEDET CVS only
right now, but yours is much niftier.  I like the highlight that is
the line down the side.  That is a nice effect.  The pre-existing
function `semantic-momentary-unhighlight-tag' could do well to emulate
it.

  In CEDET cvs, you will find new utility functions to make folding
easier, including `semantic-set-tag-folded' which works well with
isearch.  That is in CVS in semantic-decorate.el.

  I my version, if I click on the little + or - in the fringe too
much, my Emacs would crash, so I didn't persue it very far as I still
need to produce a good bug report.

 Suraj Acharya [EMAIL PROTECTED] seems to think that:
I've been working on a semantic-decoration style which allows tags to
be folded and unfolded, and uses fringe bitmaps to indicate where the
tags are.

http://www.emacswiki.org/elisp/semantic-tag-folding.el

From the commentary :

  [ ... ]

Eric,  I have a couple of questions about semantic-decorate-mode:

1)  The definition of semantic-decoration-styles seems to be missing a
:require attribute for semantic-decorate-mode. Currently, if I try to
customize its value, after starting up emacs I end with each style
listed twice in semantic-decoration-styles.

That variable maintains itself.  To fix that I probably need a second
variable that is customized, that the first references as new items
are auto-added.  I'll have to look into that.

2) I need to add a keybinding for clicking on the fringe for this
mode, it would be nice if there was key map for
semantic-decoration-mode.

If you look at semantic-fold.el from CVS, you will see how I
accomplished that task with a semantic-folding-mode of its own.  I
tend to create lots of modes for all the features to make them easy to
turn on and off without tromping other obscure features.

3) What is a good way to enable semantic-decoration-mode by default ? I tried
(add-hook 'jde-mode-hook 'semantic-decoration-mode) but it complains
Buffer Foo.java was not set up for parsing.

If you look in the INSTALL, you will see there are several startup
functions, and one is `(semantic-load-enable-code-helpers)' which
happens to have decoration mode enabled by default.

For any semantic mode, there is a `global-' version.  If you use that,
it will auto-add itself to any semantic enabled mode.

Semantic modes need to be added to `semantic-init-hooks'.  This hook
is run after the major-mode hook, which is why the buffer is not yet
setup for parsing.

4) Once semantic-decoration-mode is up and running and all the tags
have been decorated, if I make any edits in a tag it looks like all
the decorations for the tag are deleted and it is sent to the
highlight-default function again. Is there any way for the function to
be called with the old decorations intact so it can remove them only
if it wants to ?
  [ ... ]

I'm not quite sure what you mean.  Are you trying to prevent a folded
tag from being decorated by other decoration modes?  That could be
tricky as you probably want to keep some, but disable others.

Some decoration modes purposely do not decorate short functions, such
as boundary mode.  Perhaps they should just be made savvy toward tags
that are artificially shortened.  The detection of this in a generic
way may be challenging.

Lastly, you might want to run `M-x checkdoc' on your code to make your
doc-strings RMS compatible.

Your code is nifty!  Thanks.
Eric

-- 
  Eric Ludlam: [EMAIL PROTECTED], [EMAIL PROTECTED]
   Home: http://www.ludlam.netSiege: www.siege-engine.com
Emacs: http://cedet.sourceforge.net   GNU: www.gnu.org


Re[1]: [CEDET-devel] semantic-tag-folding.el

2005-02-20 Thread Eric M. Ludlam
 Suraj Acharya [EMAIL PROTECTED] seems to think that:
Hi Eric, 

Thanks for your answers.

I've just checked out the code from CVS and it is neat. If you'd like
I could take a shot at adding the addtional features from my code and
creating a patch for semantic-fold.el.

I have not spent enough time to decide which is the better
implementation to start from... other than that mine crashes Emacs. ;)

If you think the baseline in semantic-cvs is better, feel free to
upgrade it.
 
On Fri, 18 Feb 2005 22:27:23 -0500, Eric M. Ludlam
[EMAIL PROTECTED] wrote:
 Hi,
 
   That is quite nifty.  I wrote one also which is in CEDET CVS only
 right now, but yours is much niftier.  I like the highlight that is
 the line down the side.  That is a nice effect.  The pre-existing
 function `semantic-momentary-unhighlight-tag' could do well to emulate
 it.
 
   In CEDET cvs, you will find new utility functions to make folding
 easier, including `semantic-set-tag-folded' which works well with
 isearch.  That is in CVS in semantic-decorate.el.

I'll take a look. Btw, if you set the  'reveal-toggle-invisible
property on 'semantic-fold you can make the fringe bitmaps when if the
tag is opened by reveal-mode.

I'm not that familiar with that mode, but the doc makes it sound
useful.
 
   I my version, if I click on the little + or - in the fringe too
 much, my Emacs would crash, so I didn't persue it very far as I still
 need to produce a good bug report.
 
[...]
 4) Once semantic-decoration-mode is up and running and all the tags
 have been decorated, if I make any edits in a tag it looks like all
 the decorations for the tag are deleted and it is sent to the
 highlight-default function again. Is there any way for the function to
 be called with the old decorations intact so it can remove them only
 if it wants to ?
   [ ... ]
 
 I'm not quite sure what you mean.  Are you trying to prevent a folded
 tag from being decorated by other decoration modes?  That could be
 tricky as you probably want to keep some, but disable others.

What I'm trying to do is quite simple. Currently, if I unfold a tag,
make some edits inside and then move outside it, then the next time
the idle-timer kicks in and the tag is reparsed, it gets folded again.
What I'd like is that it remember the fact that I unfolded the tag and
not fold it. The simplest way to do this would be to somehow not clear
the decorations on the tag at all, since any edits would not require
them to be changed. Perhaps the decoration-style-highlight-default
function could get called only for new tags, while something like
decoration-style-update-after-edits could get called when the tag is
updated.

But I don't know much about semantic internals, so this might not make
sense. In that case  I just can store the fold state as an attribute
on the tag overlay or somewhere else.
  [ ... ]

Ah, I see.  I used decoration mode to put the markers in the file, but
not to actually fold the tags.  Having tag folded or not is a separate
attribute which I placed on the tags using the new function
`semantic-set-tag-folded'.  The option of folding all the tags (or
not) is then part of the major mode initialization.

As my version doesn't start stuff out folded, doing so would have
conflicting goals.  I've tried to set things up so files are not
parsed until after the buffer is shown, with the exception of tags
loaded in from a database.  This conflicts with the goal of forcing
the tags to be folded when the minor-mode starts up.

Loading a file might look like this:

 - find-file
 - foo-mode
   - foo-mode-hook
   - semantic-setup-foo-mode
 - semantic-init
   - semantic-init-hook
   - semanticdb-semantic-init-hook-fcn
   - semantic-tag-folding-mode
 * If no tags from DB, setup a reparse hook
   otherwise fold everything.
 * file is displayed
 - semantic-idle-scheduler
   - semantic-fetch-tags
   - semantic-after-toplevel-cache-change-hook
 - semantic-folding-tag-mode-after-first-reparse-hook
   * Decide if you want to fold all your new tags.
   * remove hook from list.

Does that make sense?

One other thing I noticed:

Here are a couple other comments I have about your code:

  Returns non-nil if TAG is to be considered for folding.  TAG
  has to have valid start and end locations in the
  buffer. Customize `semantic-tag-folding-allow-folding-of' to
  influence the output of this
  function.  
  (let ((c (semantic-tag-class tag)))
(and
 (semantic-tag-end tag)
 (semantic-tag-start tag)

You can use `semantic-tag-with-position-p' to find out if the tag has
a position.


Eric

-- 
  Eric Ludlam: [EMAIL PROTECTED], [EMAIL PROTECTED]
   Home: http://www.ludlam.netSiege: www.siege-engine.com
Emacs: http://cedet.sourceforge.net   GNU: www.gnu.org