emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* navi-search-and-switch fails
@ 2014-08-31 15:26 Alan Schmitt
  2014-08-31 15:44 ` Thorsten Jolitz
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Schmitt @ 2014-08-31 15:26 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1342 bytes --]

(Thorsten asked me to repost this from github.)

When calling navi-search-and-switch interactively, I get the following
backtrace:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  navi-rename-buffer()
  navi-search-and-switch()
  call-interactively(navi-search-and-switch record nil)
  command-execute(navi-search-and-switch record)

The problem seems to be with this code in navi-rename-buffer

#+begin_src emacs-lisp
(with-current-buffer
    (if (eq major-mode 'occur-mode) (current-buffer) (get-buffer "*Occur*"))
#+end_src


As there is no "*Occur*" buffer, and the current buffer is in
emacs-lisp-mode, =(if (eq major-mode 'occur-mode) (current-buffer)
(get-buffer "*Occur*"))= returns nil and with-current-buffer fails.

> Is the source-file an outshine-file?
> Did you call outline-minor-mode on it, with outshine activated
> (i.e. with outshine-hook-function added to outline-minor-mode-hook)?

I think it is. Here is my current configuration:

#+begin_src emacs-lisp
(add-hook 'message-mode-hook 'outline-minor-mode)
(add-hook 'emacs-lisp-mode-hook 'outline-minor-mode)
(require 'outshine)
(add-hook 'outline-minor-mode-hook 'outshine-hook-function)
(require 'navi-mode)
#+end_src

and I see "Outl" in the list of minor modes.

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

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

* Re: navi-search-and-switch fails
  2014-08-31 15:26 navi-search-and-switch fails Alan Schmitt
@ 2014-08-31 15:44 ` Thorsten Jolitz
  2014-09-01 16:50   ` Alan Schmitt
  0 siblings, 1 reply; 7+ messages in thread
From: Thorsten Jolitz @ 2014-08-31 15:44 UTC (permalink / raw)
  To: emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> (Thorsten asked me to repost this from github.)
>
> When calling navi-search-and-switch interactively, I get the following
> backtrace:

But when 'navi-search-and-switch' would have a bug, one could not use
navi-mode at all ... and I use it all the time.

> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>   navi-rename-buffer()
>   navi-search-and-switch()
>   call-interactively(navi-search-and-switch record nil)
>   command-execute(navi-search-and-switch record)
>
> The problem seems to be with this code in navi-rename-buffer
>
> #+begin_src emacs-lisp
> (with-current-buffer
>     (if (eq major-mode 'occur-mode) (current-buffer) (get-buffer "*Occur*"))
> #+end_src
>
>
> As there is no "*Occur*" buffer, and the current buffer is in
> emacs-lisp-mode, =(if (eq major-mode 'occur-mode) (current-buffer)
> (get-buffer "*Occur*"))= returns nil and with-current-buffer fails.
>
>> Is the source-file an outshine-file?
>> Did you call outline-minor-mode on it, with outshine activated
>> (i.e. with outshine-hook-function added to outline-minor-mode-hook)?
>
> I think it is. Here is my current configuration:
>
> #+begin_src emacs-lisp
> (add-hook 'message-mode-hook 'outline-minor-mode)
> (add-hook 'emacs-lisp-mode-hook 'outline-minor-mode)
> (require 'outshine)
> (add-hook 'outline-minor-mode-hook 'outshine-hook-function)
> (require 'navi-mode)
> #+end_src
>
> and I see "Outl" in the list of minor modes.

looks good so far.

1. Can you try 'navi-search-and-switch' on an org-mode buffer, with ->
(eq major-mode 'org-mode), e.g.

,----
| * ORG SCRATCH
| ** 2nd Level
| #+BEGIN_SRC emacs-lisp :cache no
|  (+ 2 2)
| #+END_SRC
`----

*Navi* buffer should pop-up, typing 2 should show both headlines.

2. Is there anything special about the outshine file you used? Is it
structured with outshine headers? is it emacs-lisp-mode? old-school or
org-style headers?

-- 
cheers,
Thorsten

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

* Re: navi-search-and-switch fails
  2014-08-31 15:44 ` Thorsten Jolitz
@ 2014-09-01 16:50   ` Alan Schmitt
  2014-09-01 17:18     ` Thorsten Jolitz
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Schmitt @ 2014-09-01 16:50 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1931 bytes --]

On 2014-08-31 17:44, Thorsten Jolitz <tjolitz@gmail.com> writes:

> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> (Thorsten asked me to repost this from github.)
>>
>> When calling navi-search-and-switch interactively, I get the following
>> backtrace:
>
> But when 'navi-search-and-switch' would have a bug, one could not use
> navi-mode at all ... and I use it all the time.

Yes, I imagine the problem comes from an interaction with something
else, but the code below does not seem to deal with the case where there
is no occur buffer.

>> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>>   navi-rename-buffer()
>>   navi-search-and-switch()
>>   call-interactively(navi-search-and-switch record nil)
>>   command-execute(navi-search-and-switch record)
>>
>> The problem seems to be with this code in navi-rename-buffer
>>
>> #+begin_src emacs-lisp
>> (with-current-buffer
>>     (if (eq major-mode 'occur-mode) (current-buffer) (get-buffer "*Occur*"))
>> #+end_src
>>
>>
>> As there is no "*Occur*" buffer, and the current buffer is in
>> emacs-lisp-mode, =(if (eq major-mode 'occur-mode) (current-buffer)
>> (get-buffer "*Occur*"))= returns nil and with-current-buffer fails.

> 1. Can you try 'navi-search-and-switch' on an org-mode buffer, with ->
> (eq major-mode 'org-mode), e.g.
>
> ,----
> | * ORG SCRATCH
> | ** 2nd Level
> | #+BEGIN_SRC emacs-lisp :cache no
> |  (+ 2 2)
> | #+END_SRC
> `----
>
> *Navi* buffer should pop-up, typing 2 should show both headlines.

Yes, it works with an org file.

> 2. Is there anything special about the outshine file you used?

It's an emacs-lisp file.

> Is it structured with outshine headers? is it emacs-lisp-mode?
> old-school or org-style headers?

Here is a simple example that fails for me:

;; * ORG SCRATCH
;; ** 2nd Level
(+ 2 2)

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

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

* Re: navi-search-and-switch fails
  2014-09-01 16:50   ` Alan Schmitt
@ 2014-09-01 17:18     ` Thorsten Jolitz
  2014-09-01 17:41       ` Alan Schmitt
  0 siblings, 1 reply; 7+ messages in thread
From: Thorsten Jolitz @ 2014-09-01 17:18 UTC (permalink / raw)
  To: emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

>> 1. Can you try 'navi-search-and-switch' on an org-mode buffer, with ->
>> (eq major-mode 'org-mode), e.g.
>>
>> ,----
>> | * ORG SCRATCH
>> | ** 2nd Level
>> | #+BEGIN_SRC emacs-lisp :cache no
>> |  (+ 2 2)
>> | #+END_SRC
>> `----
>>
>> *Navi* buffer should pop-up, typing 2 should show both headlines.
>
> Yes, it works with an org file.

ok, so navi-mode works

>> 2. Is there anything special about the outshine file you used?
>
> It's an emacs-lisp file.
>
>> Is it structured with outshine headers? is it emacs-lisp-mode?
>> old-school or org-style headers?
>
> Here is a simple example that fails for me:
>
> ;; * ORG SCRATCH
> ;; ** 2nd Level
> (+ 2 2)

There is nothing special about this example, it should just work.

Does outshine work with that buffer (without navi-mode)? Are the
headlines fontified like Org headlines? Can you cycle visibility? Can
you call 'M-x outorg-edit-as-org' on a subtree?

What does C-h v outline-regexp return?

I suspect the problem is in your outshine installation. Does it work
otherwise for you?

What happens if you call M-x outline-minor-mode again in that example
buffer?

-- 
cheers,
Thorsten

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

* Re: navi-search-and-switch fails
  2014-09-01 17:18     ` Thorsten Jolitz
@ 2014-09-01 17:41       ` Alan Schmitt
  2014-09-01 18:13         ` Thorsten Jolitz
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Schmitt @ 2014-09-01 17:41 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1492 bytes --]

On 2014-09-01 19:18, Thorsten Jolitz <tjolitz@gmail.com> writes:

> Does outshine work with that buffer (without navi-mode)?

I guess not … How can I test it?

> Are the headlines fontified like Org headlines?

No.

> Can you cycle visibility?

Using TAB does nothing.

> Can you call 'M-x outorg-edit-as-org' on a subtree?

No, I get a backtrace:

Debugger entered--Lisp error: (error "before first heading")
  signal(error ("before first heading"))
  error("before first heading")
  outline-back-to-heading(INVISIBLE-OK)
  outorg-copy-and-convert()
  outorg-edit-as-org(nil)
  call-interactively(outorg-edit-as-org record nil)


> What does C-h v outline-regexp return?

outline-regexp is a variable defined in `outline.el'.
Its value is ";;[;]\\{1,8\\} "
Original value was "[*\f]+"
Local in buffer untitled; global value is "[*\f]+"

> I suspect the problem is in your outshine installation. Does it work
> otherwise for you?

I don't use it otherwise, so I don't know. I tried 'M-x
outorg-edit-as-org' on this message and it works.

> What happens if you call M-x outline-minor-mode again in that example
> buffer?

It works! I have to call it twice (once to disable it, and once to
enable it again), but then TAB and navi work as expected (no
fontification, though).

So for some reason emacs-lisp-mode sets up outline-mode, but the later
does not seem to load outshine automatically.

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

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

* Re: navi-search-and-switch fails
  2014-09-01 17:41       ` Alan Schmitt
@ 2014-09-01 18:13         ` Thorsten Jolitz
  2014-09-02  9:10           ` Alan Schmitt
  0 siblings, 1 reply; 7+ messages in thread
From: Thorsten Jolitz @ 2014-09-01 18:13 UTC (permalink / raw)
  To: emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> On 2014-09-01 19:18, Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> Does outshine work with that buffer (without navi-mode)?
>
> I guess not … How can I test it?
>
>> Are the headlines fontified like Org headlines?
>
> No.
>
>> Can you cycle visibility?
>
> Using TAB does nothing.
>
>> Can you call 'M-x outorg-edit-as-org' on a subtree?
>
> No, I get a backtrace:
>
> Debugger entered--Lisp error: (error "before first heading")
>   signal(error ("before first heading"))
>   error("before first heading")
>   outline-back-to-heading(INVISIBLE-OK)
>   outorg-copy-and-convert()
>   outorg-edit-as-org(nil)
>   call-interactively(outorg-edit-as-org record nil)
>
>> What does C-h v outline-regexp return?
>
> outline-regexp is a variable defined in `outline.el'.
> Its value is ";;[;]\\{1,8\\} "
> Original value was "[*\f]+"
> Local in buffer untitled; global value is "[*\f]+"

Wrong regexp for the example file, these are old-school headers, the
example file has outshine (=org-style headers). So the
outshine-hook-function wasn't really called on that buffer (again) to
find out it has outshine headers. 

>> I suspect the problem is in your outshine installation. Does it work
>> otherwise for you?
>
> I don't use it otherwise, so I don't know. I tried 'M-x
> outorg-edit-as-org' on this message and it works.
>
>> What happens if you call M-x outline-minor-mode again in that example
>> buffer?
>
> It works! I have to call it twice (once to disable it, and once to
> enable it again), but then TAB and navi work as expected (no
> fontification, though).

Good!

This whole thing is related to loading libraries and calling hooks, and
its quite hard to tell whats going on there inside emacs sometimes. 

When I have all the hooks set in my init file, so that opening an elisp
file calls outline-minor-mode-hook, and loading outline-minor-mode calls
outshine-hook-function, then things just work. 

But putting an active fundamental-mode tmp-buffer with elisp code in
emacs-lisp-mode sometimes doesn't activate outshine right away, and I
have to call M-x emacs-lisp-mode again.

Calling M-x nuke-and-eval on an outshine buffer is not a good idea
either, probably because of the buffer-local-vars set.

And currently I'm working with latex/auctex again and added a few
(actually really nice) convenience functions to tj-outshine and tj-navi
branches to make outshine work with latex-mode too, and it works well,
only that latex-mode seems to re-fontify the buffer frequently so the
outshine fontification is lost and I have to call M-x latex-mode again
to make it reappear, whats a bit annoying ...

> So for some reason emacs-lisp-mode sets up outline-mode, but the later
> does not seem to load outshine automatically.

I think thats really an internal emacs thing, because 

,----
| C-h v outline-minor-mode-hook
`----

will probably show you this:

,----
| outline-minor-mode-hook's value is (outshine-hook-function)
`----

-- 
cheers,
Thorsten

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

* Re: navi-search-and-switch fails
  2014-09-01 18:13         ` Thorsten Jolitz
@ 2014-09-02  9:10           ` Alan Schmitt
  0 siblings, 0 replies; 7+ messages in thread
From: Alan Schmitt @ 2014-09-02  9:10 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]

On 2014-09-01 20:13, Thorsten Jolitz <tjolitz@gmail.com> writes:

> This whole thing is related to loading libraries and calling hooks, and
> its quite hard to tell whats going on there inside emacs sometimes. 

I guess I was unlucky since this hook issue has not happened again. I'll
keep my eyes opened to see if I find a cause for it.

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

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

end of thread, other threads:[~2014-09-02  9:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-31 15:26 navi-search-and-switch fails Alan Schmitt
2014-08-31 15:44 ` Thorsten Jolitz
2014-09-01 16:50   ` Alan Schmitt
2014-09-01 17:18     ` Thorsten Jolitz
2014-09-01 17:41       ` Alan Schmitt
2014-09-01 18:13         ` Thorsten Jolitz
2014-09-02  9:10           ` Alan Schmitt

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).