all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* outline-flag-region: Variable binding depth exceeds max-specpdl-size
@ 2013-05-21 17:00 Thorsten Jolitz
  2013-05-21 21:28 ` Thorsten Jolitz
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Jolitz @ 2013-05-21 17:00 UTC (permalink / raw)
  To: help-gnu-emacs


Hi List, 

I implemented a new (optional and customizable) feature for 'outshine.el':
behind every folded headline, a little 'cookie' can show the number of
hidden lines till the next visible headline. 

E.g., an  Emacs Lisp buffer structured the 'outshine-way' with
outline-minor-mode and outshine.el activated might look like this after
evaluating 'outshine-show-hidden-lines-cookies':

,-------------------------------------------------------------------------------
| ;; * navi-mode.el --- major-mode for easy buffer-navigation [#13]
| ;; ** Commentary [#1]
| ;; *** About navi-mode
| 
| ;; This file implements extensions for occur-mode. You can think of a
| ;; navi-buffer as a kind of 'remote-control' for an (adecuately)
| ;; outline-structured original-buffer. It enables quick navigation and basic
| ;; structure editing in the original-buffer without (necessarily) leaving the
| ;; navi-buffer. When switching to the original-buffer and coming back after
| ;; some modifications, the navi-buffer is always reverted (thus up-to-date).
| 
| ;; Besides the fundamental outline-heading-searches (8 outline-levels) and the
| ;; 5 basic keyword-searches (:FUN, :VAR, :DB, :OBJ and :ALL), all languages
| ;; can have their own set of searches and keybindings (see `navi-key-mappings'
| ;; and `navi-keywords'). Heading-searches and keyword-searches can be
| ;; combined, offering a vast amount of possible 'views' at the
| ;; original-buffer.
| 
| ;; *** Usage [#165]
| ;; *** Installation [#19]
| ;; *** Emacs Version [#5]
| ;; * Requires [#4]
| ;; * Mode Definitions [#30]
`-------------------------------------------------------------------------------

This works alright so far, and when a folded buffer is expanded or the
number of hidden lines change, the cookies are updated correctly. But
obviously its a bit tedious to manually do 

,------------------------------------------
| M-:(outshine-show-hidden-lines-cookies)
`------------------------------------------

each time the status of the buffer changes, so the right thing to do
seems to be:

,-----------------------------------------------
| (add-hook 'outline-view-change-hook
|           'outshine-show-hidden-lines-cookies)
`-----------------------------------------------

This worked shortly, but since then results in the following error:

,---------------------------------------------------------------------
| outline-flag-region: Variable binding depth exceeds max-specpdl-size
`---------------------------------------------------------------------

Whats this error about and what would be a possible fix? There are
several reports about this error for several Emacs modes, but the
background and cure are not really explained. 

-- 
cheers,
Thorsten





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: outline-flag-region: Variable binding depth exceeds max-specpdl-size
  2013-05-21 17:00 outline-flag-region: Variable binding depth exceeds max-specpdl-size Thorsten Jolitz
@ 2013-05-21 21:28 ` Thorsten Jolitz
  0 siblings, 0 replies; 2+ messages in thread
From: Thorsten Jolitz @ 2013-05-21 21:28 UTC (permalink / raw)
  To: help-gnu-emacs

Thorsten Jolitz <tjolitz@gmail.com> writes:

> I implemented a new (optional and customizable) feature for 'outshine.el':
> behind every folded headline, a little 'cookie' can show the number of
> hidden lines till the next visible headline. 

[...snip...] 

> This works alright so far, and when a folded buffer is expanded or the
> number of hidden lines change, the cookies are updated correctly. But
> obviously its a bit tedious to manually do 
>
> ,------------------------------------------
> | M-:(outshine-show-hidden-lines-cookies)
> `------------------------------------------
>
> each time the status of the buffer changes, so the right thing to do
> seems to be:
>
> ,-----------------------------------------------
> | (add-hook 'outline-view-change-hook
> |           'outshine-show-hidden-lines-cookies)
> `-----------------------------------------------
>
> This worked shortly, but since then results in the following error:
>
> ,---------------------------------------------------------------------
> | outline-flag-region: Variable binding depth exceeds max-specpdl-size
> `---------------------------------------------------------------------
>
> Whats this error about and what would be a possible fix? There are
> several reports about this error for several Emacs modes, but the
> background and cure are not really explained. 

Following up to my own post, help and source code of
'outline-flag-region' and 'max-specpdl-size' do give some hints:

,---------------------------------------------------------------------------
| max-specpdl-size is a variable defined in `C source code'.
| Its value is 1340
| Original value was 1300
|
|   This variable can be risky when used as a file-local variable.
|
| Documentation:
| Limit on number of Lisp variable bindings and `unwind-protect's.
| If Lisp code tries to increase the total number past this amount,
| an error is signaled.
| You can safely use a value considerably larger than the default value,
| if that proves inconveniently small.  However, if you increase it too far,
| Emacs could run out of memory trying to make the stack bigger.
|
| You can customize this variable.
`---------------------------------------------------------------------------

so it appears that in a call to 'outline-flag-region' more than 1340
Lisp variable bindings and `unwind-protect's are created.

,--------------------------------------------------------------------------
| outline-flag-region is a compiled Lisp function in `outline.el'.
|
| (outline-flag-region FROM TO FLAG)
|
| Hide or show lines from FROM to TO, according to FLAG.
| If FLAG is nil then text is shown, while if FLAG is t the text is hidden.
`--------------------------------------------------------------------------

But its hard to see where this happens in a (test) file with some 30
outline headlines. 

,-----------------------------------------------------------------------------
| (defun outline-flag-region (from to flag)
|   "Hide or show lines from FROM to TO, according to FLAG.
| If FLAG is nil then text is shown, while if FLAG is t the text is hidden."
|   (remove-overlays from to 'invisible 'outline)
|   (when flag
|     ;; We use `front-advance' here because the invisible text begins at the
|     ;; very end of the heading, before the newline, so text inserted at FROM
|     ;; belongs to the heading rather than to the entry.
|     (let ((o (make-overlay from to nil 'front-advance)))
|       (overlay-put o 'evaporate t)
|       (overlay-put o 'invisible 'outline)
|       (overlay-put o 'isearch-open-invisible
|                    (or outline-isearch-open-invisible-function
|                        'outline-isearch-open-invisible))))
|   ;; Seems only used by lazy-lock.  I.e. obsolete.
|   (run-hooks 'outline-view-change-hook))
`-----------------------------------------------------------------------------

Looking at the code, I can't really see why a function called each time
an outline region is flagged, that jumps to all visible headlines, checks
if the headline is folded and/or if it has a "hidden-lines-cookie", and
only in the first case gets the number of hidden lines before the next
visible headline, would create so many variable bindings and
unwind-protects. 

Any hints?

PS 
And, by the way, if I could solve the problem described in this thread,
'outline-view-change-hook' would be quite useful for outshine.el and
thus not obsolete any more?

-- 
cheers,
Thorsten




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-05-21 21:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-21 17:00 outline-flag-region: Variable binding depth exceeds max-specpdl-size Thorsten Jolitz
2013-05-21 21:28 ` Thorsten Jolitz

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.