On 07/24/2011 10:15 PM, Richard Kim wrote:
> "Eric M. Ludlam"<ericludlam@...> writes:
>
> [...] snip
>
>> For Richard's problem (Possible bug in semantic-tag-buffer), I see a
>> bigger bugaboo which was that the mode fetching was written when I was
>> attempting to get multi-mode semantic working, so it is moving to a
>> tag location, and asking what the mode is RiGHT THERE, which is a
>> waste of time in current CEDET which doesn't support multi-mode.
>
> The only "multiple major mode" implementation that I am aware of is
> mmm-mode<https://sourceforge.net/projects/mmm-mode/> which I have used
> for several years. Are there other multiple major mode implementations
> perhaps even built into emacs?
>
> To support multiple major modes I would think that semantic would need
> to be able to detect the proper major mode at each point and generate
> tags appropriate for that major mode. Does semantic currently have code
> to do such things?
The support for multiple major modes was never completed. At some point
I stopped writing javascript toys, and stopped caring so much.
You are right about the technique that would be needed. I think it is a
tricky problem that is probably not really needed.
>> === modified file 'semantic/semantic-tag.el'
>> *** semantic/semantic-tag.el 2011-02-28 03:23:22 +0000
>> --- semantic/semantic-tag.el 2011-07-22 00:20:40 +0000
>> ***************
>> *** 211,224 ****
>> (let ((buffer (semantic-tag-buffer tag))
>> (start (semantic-tag-start tag))
>> (end (semantic-tag-end tag)))
>> ! (save-excursion
>> (and buffer (set-buffer buffer))
>> ! ;; Unless point is inside TAG bounds, move it to the
>> ! ;; beginning of TAG.
>> ! (or (and (>= (point) start) (< (point) end))
>> ! (goto-char start))
>> ! (require 'semantic-ctxt)
>> ! (semantic-ctxt-current-mode)))))
>>
>> (defsubst semantic--tag-attributes-cdr (tag)
>> "Return the cons cell whose car is the ATTRIBUTES part of TAG.
>> --- 211,225 ----
>> (let ((buffer (semantic-tag-buffer tag))
>> (start (semantic-tag-start tag))
>> (end (semantic-tag-end tag)))
>> ! (save-current-buffer
>> (and buffer (set-buffer buffer))
>> ! (save-excursion
>> ! ;; Unless point is inside TAG bounds, move it to the
>> ! ;; beginning of TAG.
>> ! (or (and (>= (point) start) (< (point) end))
>> ! (goto-char start))
>> ! (require 'semantic-ctxt)
>> ! (semantic-ctxt-current-mode))))))
>>
>> (defsubst semantic--tag-attributes-cdr (tag)
>> "Return the cons cell whose car is the ATTRIBUTES part of TAG.
>
> How about changing
>
> (and buffer (set-buffer buffer))
>
> to
>
> (and buffer (buffer-live-p buffer) (set-buffer buffer))
>
> to make sure that the buffer is still valid?
> I don't have any empirical evidence that this is needed, but I know that
> passing a killed buffer to set-buffer results in an error, and I'm not
> sure that that will not happen. Perhaps I'm being overly concerned.
What I hadn't figured out is the source of the problem you found. While
what you suggest is probably a fine solution, there is some other thing
that causes the tag to not get detached from a buffer properly, causing
this bug. That is the real mystery, and also the thing that will cause
additional problems, even if we fix this case.
Eric
|