* M-: (org-display-outline-path) doesn't work correctly
@ 2014-03-12 14:40 Thorsten Jolitz
2014-03-12 15:08 ` Bastien
0 siblings, 1 reply; 11+ messages in thread
From: Thorsten Jolitz @ 2014-03-12 14:40 UTC (permalink / raw)
To: emacs-orgmode
Hi List,
while
,-----------------------------
| M-x org-display-outline-path
`-----------------------------
works as expected for me, neither
,-------------------------------
| M-: (org-display-outline-path)
`-------------------------------
nor
,---------------------------------------------------
| M-: (call-interactively 'org-display-outline-path)
`---------------------------------------------------
return what they should. Can anybody confirm this?
How is this function supposed to be called from another program? Why
does it have (interactive "P") if the prefix arg is never used? Or do I
simply miss something important here?
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: M-: (org-display-outline-path) doesn't work correctly
2014-03-12 14:40 M-: (org-display-outline-path) doesn't work correctly Thorsten Jolitz
@ 2014-03-12 15:08 ` Bastien
2014-03-12 15:48 ` Thorsten Jolitz
0 siblings, 1 reply; 11+ messages in thread
From: Bastien @ 2014-03-12 15:08 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: emacs-orgmode
Hi Thorsten,
Thorsten Jolitz <tjolitz@gmail.com> writes:
> How is this function supposed to be called from another program? Why
> does it have (interactive "P") if the prefix arg is never used? Or do I
> simply miss something important here?
I think you miss the fact that it displays a path only if the headline
is not a top-level headline.
HTH,
--
Bastien
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: M-: (org-display-outline-path) doesn't work correctly
2014-03-12 15:08 ` Bastien
@ 2014-03-12 15:48 ` Thorsten Jolitz
2014-03-12 16:12 ` Bastien
0 siblings, 1 reply; 11+ messages in thread
From: Thorsten Jolitz @ 2014-03-12 15:48 UTC (permalink / raw)
To: emacs-orgmode
Bastien <bzg@gnu.org> writes:
Hi Bastien,
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> How is this function supposed to be called from another program? Why
>> does it have (interactive "P") if the prefix arg is never used? Or do I
>> simply miss something important here?
>
> I think you miss the fact that it displays a path only if the headline
> is not a top-level headline.
Not really, on the same 2nd level headline calling it with M-x and M-:
give different messages, and only in the first case a useful one.
With point at start of ** 2nd level
#+begin_src org
* 1st level
Hello
** 2nd level
Work
#+end_src
,-----------------------------------------------------
| Eval: (org-display-outline-path)
| Eval: (call-interactively 'org-display-outline-path)
`-----------------------------------------------------
both print this in the message buffer
,--------------------------------------
| byte-code: End of buffer
| #("1st level" 0 9 (face org-level-1))
`--------------------------------------
while using M-x shows the string "1st Level" as expected.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: M-: (org-display-outline-path) doesn't work correctly
2014-03-12 15:48 ` Thorsten Jolitz
@ 2014-03-12 16:12 ` Bastien
2014-03-12 16:53 ` Thorsten Jolitz
0 siblings, 1 reply; 11+ messages in thread
From: Bastien @ 2014-03-12 16:12 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: emacs-orgmode
Thorsten Jolitz <tjolitz@gmail.com> writes:
> both print this in the message buffer
>
> ,--------------------------------------
> | byte-code: End of buffer
> | #("1st level" 0 9 (face org-level-1))
> `--------------------------------------
>
> while using M-x shows the string "1st Level" as expected.
There is no problem here.
#("1st level" 0 9 (face org-level-1))
is just the internal representation of a fontified string.
Or am I missing something?
--
Bastien
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: M-: (org-display-outline-path) doesn't work correctly
2014-03-12 16:12 ` Bastien
@ 2014-03-12 16:53 ` Thorsten Jolitz
2014-03-12 17:44 ` Bastien
0 siblings, 1 reply; 11+ messages in thread
From: Thorsten Jolitz @ 2014-03-12 16:53 UTC (permalink / raw)
To: emacs-orgmode
Bastien <bzg@gnu.org> writes:
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> both print this in the message buffer
>>
>> ,--------------------------------------
>> | byte-code: End of buffer
>> | #("1st level" 0 9 (face org-level-1))
>> `--------------------------------------
>>
>> while using M-x shows the string "1st Level" as expected.
>
> There is no problem here.
>
> #("1st level" 0 9 (face org-level-1))
>
> is just the internal representation of a fontified string.
I know, but...
> Or am I missing something?
can you write a function (not a command) that calls this function, and
you see in the minibuffer what you expect?
#+begin_src emacs-lisp
(defun callOrgDisplay ()
(call-interactively 'org-display-outline-path))
#+end_src
#+results:
: callOrgDisplay
#+begin_src org
* 1st Level
** 2nd Level
#+end_src
,---------------------
| M-: (callOrgDisplay)
`---------------------
with point on the second level headline shows that internal string
representation. Only if I make `callOrgDisplay' itself a command by
adding (interactive) and call it with M-x, the string without properties
is shown.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: M-: (org-display-outline-path) doesn't work correctly
2014-03-12 16:53 ` Thorsten Jolitz
@ 2014-03-12 17:44 ` Bastien
2014-03-12 18:17 ` Thorsten Jolitz
0 siblings, 1 reply; 11+ messages in thread
From: Bastien @ 2014-03-12 17:44 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: emacs-orgmode
Thorsten Jolitz <tjolitz@gmail.com> writes:
> ,---------------------
> | M-: (callOrgDisplay)
> `---------------------
>
> with point on the second level headline shows that internal string
> representation. Only if I make `callOrgDisplay' itself a command by
> adding (interactive) and call it with M-x, the string without properties
> is shown.
... yes, that's on purpose. In a program, the output of the
non-interactive version will be a string: you can safely ignore
text properties of this string if you want to further process it.
--
Bastien
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: M-: (org-display-outline-path) doesn't work correctly
2014-03-12 17:44 ` Bastien
@ 2014-03-12 18:17 ` Thorsten Jolitz
2014-03-13 9:28 ` Nicolas Richard
0 siblings, 1 reply; 11+ messages in thread
From: Thorsten Jolitz @ 2014-03-12 18:17 UTC (permalink / raw)
To: emacs-orgmode
Bastien <bzg@gnu.org> writes:
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> ,---------------------
>> | M-: (callOrgDisplay)
>> `---------------------
>>
>> with point on the second level headline shows that internal string
>> representation. Only if I make `callOrgDisplay' itself a command by
>> adding (interactive) and call it with M-x, the string without properties
>> is shown.
>
> ... yes, that's on purpose. In a program, the output of the
> non-interactive version will be a string: you can safely ignore
> text properties of this string if you want to further process it.
Ok, I see ... that seems to be a common pattern in Org-mode to make
functions behave differently if called (non-)interactively, that
sometimes causes confusion when using M-: instead of M-x.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: M-: (org-display-outline-path) doesn't work correctly
2014-03-12 18:17 ` Thorsten Jolitz
@ 2014-03-13 9:28 ` Nicolas Richard
2014-03-13 11:38 ` Thorsten Jolitz
0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Richard @ 2014-03-13 9:28 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: emacs-orgmode
Thorsten Jolitz <tjolitz@gmail.com> writes:
> Ok, I see ... that seems to be a common pattern in Org-mode to make
> functions behave differently if called (non-)interactively, that
> sometimes causes confusion when using M-: instead of M-x.
Note that using M-: will always hide any (message "foo") might have
been called because M-: outputs the return value of the function.
Usually you can recover those by inspecting the *Messages* buffer, but
in this case org uses org-unlogged-message so you can't see it there
either.
Try this :
M-: (prog1 (org-display-outline-path) (sit-for 2)) RET
It shows the message (for up to 2 seconds), and then it is hidden by the
return value (a string with properties) when the call to M-: terminates.
--
Nico.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: M-: (org-display-outline-path) doesn't work correctly
2014-03-13 9:28 ` Nicolas Richard
@ 2014-03-13 11:38 ` Thorsten Jolitz
2014-03-13 12:10 ` Nicolas Richard
0 siblings, 1 reply; 11+ messages in thread
From: Thorsten Jolitz @ 2014-03-13 11:38 UTC (permalink / raw)
To: emacs-orgmode
Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>> Ok, I see ... that seems to be a common pattern in Org-mode to make
>> functions behave differently if called (non-)interactively, that
>> sometimes causes confusion when using M-: instead of M-x.
>
> Note that using M-: will always hide any (message "foo") might have
> been called because M-: outputs the return value of the function.
> Usually you can recover those by inspecting the *Messages* buffer, but
> in this case org uses org-unlogged-message so you can't see it there
> either.
>
> Try this :
> M-: (prog1 (org-display-outline-path) (sit-for 2)) RET
> It shows the message (for up to 2 seconds), and then it is hidden by the
> return value (a string with properties) when the call to M-: terminates.
Thanks for the hint, this does the job:
#+begin_src emacs-lisp
(" " . (outshine-use-outorg
(lambda ()
(message
"%s" (substring-no-properties
(org-display-outline-path))))
'WHOLE-BUFFER-P))
#+end_src
only that promptly another message is shown (I can't use sit-for in
the program):
,-----------------------------
| Wrote /home/my/tmpdir/myfile
`-----------------------------
I have to get rid of that one ...
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: M-: (org-display-outline-path) doesn't work correctly
2014-03-13 11:38 ` Thorsten Jolitz
@ 2014-03-13 12:10 ` Nicolas Richard
2014-03-14 12:28 ` Thorsten Jolitz
0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Richard @ 2014-03-13 12:10 UTC (permalink / raw)
To: Thorsten Jolitz; +Cc: emacs-orgmode
Thorsten Jolitz <tjolitz@gmail.com> writes:
> only that promptly another message is shown (I can't use sit-for in
> the program):
sit-for was just to demonstrate the problem introduced solely by M-:.
That problem is not present when using interactive commands (i.e. those
a user can actually use), and no sit-for should be necessary in all
pratical situations.
> ,-----------------------------
> | Wrote /home/my/tmpdir/myfile
> `-----------------------------
Obviously you should find out what's writing to that file after your
(message ...) statement. I'm not an outshine/outorg user, I have no idea
what does it.
--
Nico.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: M-: (org-display-outline-path) doesn't work correctly
2014-03-13 12:10 ` Nicolas Richard
@ 2014-03-14 12:28 ` Thorsten Jolitz
0 siblings, 0 replies; 11+ messages in thread
From: Thorsten Jolitz @ 2014-03-14 12:28 UTC (permalink / raw)
To: emacs-orgmode
Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>> only that promptly another message is shown (I can't use sit-for in
>> the program):
>
> sit-for was just to demonstrate the problem introduced solely by M-:.
> That problem is not present when using interactive commands (i.e. those
> a user can actually use), and no sit-for should be necessary in all
> pratical situations.
>
>> ,-----------------------------
>> | Wrote /home/my/tmpdir/myfile
>> `-----------------------------
>
> Obviously you should find out what's writing to that file after your
> (message ...) statement. I'm not an outshine/outorg user, I have no idea
> what does it.
found it:
,---------------------------------------------------------------------
| Command: write-region start end filename &optional append visit
|
| This function writes the region (of the current buffer) delimited by
| start and end into the file specified by filename.
|
| [...]
|
| Normally, write-region displays a message `Wrote file filename' in
| the echo area. If visit is neither t nor nil nor a string, then this
| message is inhibited. This feature is useful for programs that use
| files for internal purposes, files which the user does not need to
| know about.
`---------------------------------------------------------------------
so
,-------------------------------------------
| (write-region nil nil filename nil 'VISIT)
`-------------------------------------------
gets rid of the message.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-03-14 12:30 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-12 14:40 M-: (org-display-outline-path) doesn't work correctly Thorsten Jolitz
2014-03-12 15:08 ` Bastien
2014-03-12 15:48 ` Thorsten Jolitz
2014-03-12 16:12 ` Bastien
2014-03-12 16:53 ` Thorsten Jolitz
2014-03-12 17:44 ` Bastien
2014-03-12 18:17 ` Thorsten Jolitz
2014-03-13 9:28 ` Nicolas Richard
2014-03-13 11:38 ` Thorsten Jolitz
2014-03-13 12:10 ` Nicolas Richard
2014-03-14 12:28 ` Thorsten Jolitz
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).