RE: Re[1]: Disabling LALR parsing / semantic via buffer local variable
<klaus.berndl <at> sdm.de>
2006-03-07 09:31:51 GMT
Hi Eric,
Yes, i see. But some aspects more:
1.
IMHO it would be very helpful to have a way to restirct only the size of buffers
of certain modes - e.g. parsing elisp-buffers will always be fast regardless of their
size - the OP mentioned the LALR-parser...
But maybe this could also being solved via buffer-local (mode-local?)
versions of `semantic-idle-scheduler-max-buffer-size'?
Therefore i have added the following code to ECB:
(defcustom ecb-disable-semantic-threshold-alist nil
"*Threshold for disabling semantic-parsing
Define a threshold fpr buffer-size. Exceeding this threshold disables parsing
current buffer by semantic.
This functionality is set on a major-mode base, i.e. for every major-mode a
different setting can be used. The value of this option is a list of
cons-cells:
- The car is either a major-mode symbol or the special symbol 'default which
means if no setting for a certain major-mode is defined then the cdr of
the 'default cons-cell is used.
- The cdr is an integer which defines the threshold for the buffer-size for
this major-mode.
Example:
\(\(default . 1000000)
\(c-mode . 200000))
This example whould not parse c-mode buffers exceeding a buffer-size of
200000. And buffers of all other modes would be only parsed if smaller than
1000000.
A setting of \(\(c-mode . 200000)) would only restrict c-mode buffers to a
size of 200000 but would parse all other buffer regardless their size."
:group 'ecb-methods
:type '(repeat (cons (symbol :tag "Major-Mode")
(integer :tag "Buffer-size"))))
(defun ecb-get-max-buffer-size-for-parsing ()
"Threshold set in `ecb-disable-semantic-threshold-alist' for
current major-mode"
(let ((mode-threshold (cdr (assoc major-mode ecb-disable-semantic-threshold-alist)))
(default-threshold (cdr (assoc 'default ecb-disable-semantic-threshold-alist))))
(or mode-threshold default-threshold)))
(defun ecb-prevent-from-parsing-if-exceeding-threshold ()
"Prevents from parsing current buffer if exceeding the threshold
defined in `ecb-disable-semantic-threshold-alist'."
(if (and (boundp 'ecb-minor-mode)
ecb-minor-mode
(ecb--semantic-active-p))
(let ((threshold (ecb-get-max-buffer-size-for-parsing)))
(not (and threshold (> (buffer-size) threshold))))
t))
`ecb-prevent-from-parsing-if-exceeding-threshold' is added to
`semantic--before-fetch-tags-hook' when ECB is active.
2.
You are right - your mentioned idle-option reflects only the idle-
part of parsing a buffer - there are also situations like
opening a new file, switching buffers etc.. Where tools like ECB
must manually call semantic-fetch-tags (which then mostly just
returns the cache - at least when only switching buffers).
Nevertheless in these situations your idle-solutions does not
work.... Therefore also the added code of ECB...
But at all i have the feeling that my ECB-solution is somehow suboptimal
What do you suggest?
Ciao,
klaus
Eric M. Ludlam wrote:
>>>> ecb-list-request <at> lists.sourceforge.net seems to think that:
> [ ... ]
>> Message: 1
>> To: <ecb-list <at> lists.sourceforge.net>
>> From: =?iso-8859-15?Q?_Berthold_H=F6llmann?=
>> <berthold.hoellmann <at> gl-group.com>
>> Organization: Germanischer Lloyd AG <http://www.gl-group.com>
>> Date: Mon, 06 Mar 2006 10:20:43 +0100
>> Subject: [ECB-list] Disabling LALR parsing / semantic via buffer
>> local variable
>>
>> I have a quite large source file, where LALR parsing takes minutes.
>> To be able to work on this file I would like to disable semanitic
>> for this files. Is there a way to accomplish this?
>>
> [ ... ]
>
> Hi,
>
> There is a variable `semantic-idle-scheduler-max-buffer-size' which
> disables idle parsing for buffers of a particular size in characters.
>
> Since semantic does not parse a file unless asked, the idle
> schedules is the only part of semantic that will cause a buffer to be
> parsed unsolicited. Thus, this variable can prevent unintended
> parsing of large files.
>
> There are many other modes (such as ECB) which will ask for tag
> lists. Perhaps the above variable should be moved to a different
> more generic name so different tools can use it to make their own
> determination as to the importance of parsing some buffer.
>
> There may be some semantic tools that force the buffer to be parsed
> before the idle timer. We had done work to prevent this, but they
> can sneak back in.
>
> Eric
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642