Re: [O] open link in source code block

2019-01-16 Thread Win Treese
[Quoting trimmed for the most relevant context.]

> On Jan 11, 2019, at 7:12 PM, Berry, Charles  wrote:
> 
>> On Jan 5, 2019, at 7:41 AM, Win Treese  wrote:
>> 
>>> On Jan 5, 2019, at 5:25 AM, Eric S Fraga  wrote:
>>> 
>>> On Friday,  4 Jan 2019 at 19:38, Win Treese wrote:
 Suppose I have the following Org file contents:
 
 * test
 
 #+BEGIN_SRC emacs-lisp
 (setq yyy 3)
 ;; See https://www.gnu.org
 #+END_SRC
 
 The URL for gnu.org is highlighted as a clickable link. But if I click
 it, the source block is evaluated. This seems rather unexpected,
 especially since my intention was to open the link.
>>> 
>>> Probably expected albeit maybe not your preferred behaviour; all about
>>> precedence.  In any case, I would suggest that the easy solution would
>>> be to move such links out of the src block. 

>> This seems like a slightly bigger problem, though: clicking on a highlighted
>> link doesn’t just fail to open the link, it executes the source block, which 
>> can
>> have very unintended side effects.
>> 
>> I wonder if the issue is an artifact of implementation rather than 
>> intentional
>> design: org-open-at-mouse sets point to the location of the click and then
>> calls org-open-at-point. The documentation at points says that C-c C-o in 
>> a source block opens the results of evaluation (fair enough, although the
>> docstring does not).
>> 
>> So the problem seems to be about the mouse click behavior, not the basic
>> function of org-open-at-point.
> 
> AFAICS, the issue is with org-open-at-point.
> 
> If you really want to `fix' this, there is a hook that allows customization 
> of the behavior of org-open-at-point.
> 
> This snippet will add a function to that hook that will attempt to follow a 
> link, when you click on a link in a src-block:

[Example code with function added to org-open-at-point-functions elided.]

Chuck,

Thanks for the code. You’re right—the proximate problem is in org-open-at-point.
Unfortunately, org-open-at-point calls org-babel-open-src-block-result first 
thing,
wrapped by unless, before it gets to running the hook.

Plausible changes would be to treat this as a mouse click issue and change 
org-open-at-mouse,
or to change the precedence in org-open-at-point, which Eric suggested is a way 
to look
at the problem.

For the moment, I’m going to use a personal version of org-open-at-mouse, but I 
still
think that running the code in a block when a URL is clicked is an unusual but 
potentially big problem for someone.

Thanks,
Win




Re: [O] org-agenda-log-mode omits some items from LOGBOOK drawers

2019-01-16 Thread Samuel Wales
hi,

On 1/16/19, N. Jackson  wrote:
>
> In Org Agenda, `C-u l', which IIUC is supposed to "show all possible
> log items, not only the ones configured in
> `org-agenda-log-mode-items'" shows clocking of work, closing of
> entries, and other state changes of entries (tagged in the agenda
> with "Clocked", "Closed", and "State" respectively).
>
> That is very useful. However, note entries in the LOGBOOK drawer
> (created with org-add-note) are unfortunately omitted.

notes don't have special status afaik.  therefore, they will not show
unless inactive ts show.  they include inactive ts.

so to show them you show inactive.  more below.

btw inactive ts has a special definition in org:

the closed planning line tagged ts includes an inactive ts, but it is
a planning line ts, so it is not considered an inactive ts in some
contexts.  it is considered a closed ts in those contexts.  for
example, when getting an inactive ts property.  you will not get the
inactive ts in closed ts.

in those contexts, and in most of org, inactive means bare inactive.
which i think is reasonable.

in contrast, state, as pointed out recently on the list, is not really
recognized by org.  except as a log mode item.  which is only partly
recognized.

any inactive ts in it are considered inactive ts, unlike with closed.

thus, if you turn on inactive ts, you will have to remove state from
the log mode items to avoid duplication.  this will look slightly
different in the agenda [you don't get the state indication].  but to
me that's no big deal.

you can keep closed, because that will not duplicate.

>
> Also, all my LOGBOOK drawers contain a CREATED inactive time stamp
> (placed there by my capture templates), but these CREATED entries
> are also omitted.

because they are inactive and inactive do not show [until you do what
i suggest below].

so all possible doesn't really mean all possible.  you have to catch
the tone of voice :].

this possibly dates back to when org didn't really have a concept of
inactive ts.

>
> Am I doing something wrong? Are these other entries from the LOGBOOK
> drawer expected to be included in the Agenda with `C-u l' -- I
> realise that "all possible log items" is not the same as "all log
> items", but it isn't clear why it wouldn't be possible!

inconsistencies in log mode.

you need to turn on inactive.

we sort of have at least 3 levels of log mode: regular/custom, all,
and "no i really mean all so let's include inactive and fix the
inconsistencies caused by doing so".

also there is a quasi-level implied by skip variables [see below].  so
4 levels of log mode.

the ones i find useful are nothing logged at all, or "everything no i
mean really everything" logged.  so for me i only need 2 levels of log
mode.

the command to toggle showing inactive is overloaded with query items.
so i don't really recommend it unless it works for you.

it is not persistent.

i recommend making a command that toggles
org-agenda-include-inactive-timestamps.  this is a defvar.  it works.
it is used by the overloaded command also.

i also have that variable toggled at the same time that log mode gets
toggled, using defadvice.  for health reasons i can't do more than
very very very trivial debugging and coding, so i cannot check if i've
figured it out completely enough.  i think i have, when i wrote it
long ago, modulo the skip if variables issue mentioned above.

in principle it might be better to have inactive timestamps turned on
or off at agenda creation time depending on the value of whatever
variable indicates that log mode is on.  then it will still work with
both values of start with log mode.

[unless somebody wants to fix it so that org does tihs automatically.]

>
>
>
>
>

the skip variables [like sckip-whatever-if-done] will either show
entries both as logged and as done, or as neither.  this means that if
you set them to non-nil so that they do not annoy you in your regular
agenda, they will silently be omitted in log mode.  you might not
notice this omission if they are not a common type of ts for you.

nicolas has indicated that he will not fix this one, but that others
are welcome to.  fixing it will bring us toward a more consistent log
mode.

tldr: toggle that defvar to get what you want, then remove state from
your log mode items list.  and make sure you do not set any of the
skip if variables to non-nil.

there's probably a more involved workaround where there is some
intermediate list of tasks for the agenda that you can winnow
duplicates from, but i am not able to do it.  and i think the above
might owrk for you.  and somebody might fix the inconsistencies
anyway.

hope that helps at least a bit.

-- 
The Kafka Pandemic: 

The disease DOES progress. MANY people have died from it. And ANYBODY
can get it at any time.

"You’ve really gotta quit this and get moving, because this is murder
by neglect." ---

[O] org-agenda-log-mode omits some items from LOGBOOK drawers

2019-01-16 Thread N. Jackson


In Org Agenda, `C-u l', which IIUC is supposed to "show all possible
log items, not only the ones configured in
`org-agenda-log-mode-items'" shows clocking of work, closing of
entries, and other state changes of entries (tagged in the agenda
with "Clocked", "Closed", and "State" respectively).

That is very useful. However, note entries in the LOGBOOK drawer
(created with org-add-note) are unfortunately omitted.

Also, all my LOGBOOK drawers contain a CREATED inactive time stamp
(placed there by my capture templates), but these CREATED entries
are also omitted.

Am I doing something wrong? Are these other entries from the LOGBOOK
drawer expected to be included in the Agenda with `C-u l' -- I
realise that "all possible log items" is not the same as "all log
items", but it isn't clear why it wouldn't be possible!






Re: [O] Bug: regression with :export both :noweb strip-export [9.2 (9.2-elpa @ /home/adl/.emacs.d/elpa/org-20181230/)]

2019-01-16 Thread Alexandre Duret-Lutz
On Tue, Jan 15, 2019 at 11:50 PM Alexandre Duret-Lutz  
wrote:
> Since I updated to org 9.2, the following idiom stopped working.
>
> --
> #+NAME: context
> #+BEGIN_SRC C++ :exports none
> #include 
> int u = 0;
> #+END_SRC
>
> #+BEGIN_SRC C++ :exports both :noweb strip-export :results verbatim
> <>
> int main()
> {
>   std::cout << "bar\n";
>   return u;
> }
> #+END_SRC
> --
>
> Upon export to html I'm expecting to see the second block of code with
> <> stripped away, followed by a block of text containing the
> result (bar).  With Org 9.2 I don't get the latter, because the
> compilation of this small program fails during the export.  Inspection
> of the temporary file passed to the compiler reveals that <>
> has been stripped away from the code passed as input to the compiler,
> not just from the code displayed in html.

FWIW, reverting the change made to org-babel-exp-results in the following
patch seems to fix my issue.


commit 8e54cafeb286ea5eb25565a637b121a2f597c48b
Author: Nicolas Goaziou 
Date:   Sat Jun 23 23:04:45 2018 +0200

Fix noweb expansion during export

* lisp/ob-core.el (org-babel-sha1-hash): Add optional argument to
  specify context.
(org-babel-execute-src-block): Use new argument.
* lisp/ob-exp.el (org-babel-exp-src-block): Use new argument.
(org-babel-exp-results): Fix context.

Reported-by: Ken Mankoff 


-- 
Alexandre Duret-Lutz



Re: [O] Clone tree backwards in time

2019-01-16 Thread Yasushi SHOJI
Hi,

Unfortunately, I don't have write permission to the repo.  So we need
to ask one of the maintainers to merge it.
I can put it in my personal github repo, if that helps.
-- 
 yashi

On Wed, Jan 16, 2019 at 4:05 AM Scott Randby  wrote:
>
> On 1/13/19 8:23 PM, Yasushi SHOJI wrote:
> > On Thu, Jan 10, 2019 at 1:28 PM Scott Randby  wrote:
> >> On occasion, I need to clone a tree backwards in time. I tried using 
> >> something like -2d (instead of the usual +2d) without success. Is there a 
> >> way to clone backwards in time?
> >
> > How about this?
>
> Unfortunately, I don't have the knowledge needed to test your patch, but it 
> seems good to me. Any possibility of testing this and maybe incorporating it 
> into Org?
>
> Scott
>



[O] Better org-indent alignment when using variable-pitch-mode

2019-01-16 Thread Anders Johansson
I suggest a possible change to org-indent--compute-prefixes to 
alleviate the problem.


When using variable-pitch-mode (which I particularly like as I 
write a lot of prose in org-mode), the indent between headlines 
and body text can be off, depending on the difference in the width 
of asterisk and space characters in the variable-pitch font.


A workaround is to customize the org-indent face to a monospace 
font to get it to match somewhat better, but this does not lead to 
perfect results.


The indent of headlines and text is constructed like this:

!!!##* Headline
!!!Body text

This is for a third-level headline where ! denotes invisible 
space, # invisible asterisks (in buffer text, but hidden here 
because org-indent by default enables org-hide-leading-stars), and 
* visible asterisks. This means we can still have misalignment 
since it is only the invisible characters (added as wrap-prefix 
and line-prefix with the org-indent face)  that will (possibly if 
the user intervenes) be set to a monospace font. We can’t assume 
that the last two (I think) invisible (line-prefix) spaces before 
the body text will have the same width as the indent characters.


One solution that seemed to work pretty well for me however was to 
force org-indent to use the same character (*) for all indents and 
let the face org-indent use the variable-pitch face (no 
customization of face org-indent). This results in:


#* Headline
##!Body text

That is, exactly the same characters (#=hidden asterisks, !=hidden 
space) preceding the beginning of the text in the headline and the 
body (the last character before the body text is given by 
org-indent-boundary-char, which is by default set to a space).


So for this use-case we get a much better alignment with the 
prefix characters set to asterisk. That is changing line 155 in 
org-indent, org-indent--compute-prefixes from:

(concat (make-string (+ n indentation) ?\s)
to:
(concat (make-string (+ n indentation) ?*)

If people configure the org-indent face in some other way (with 
visible characters for example, although I don’t know why this 
would be a good idea) this could be a bad idea though.


Could it perhaps be made an option? What do you think?

A case which won’t be completely solved by this however, is if the 
headline faces are customized to be larger than text (some like to 
do that for a more word-processor-like editing experience). Then 
the “* ” in the beginning of the headline will probably be taking 
up more space than any character set for indent with a default 
size.


There may have been other cases I overlooked as well.


An earlier discussion of this was here:
https://lists.gnu.org/archive/html/emacs-orgmode/2014-12/msg00014.html


--
Anders Johansson



[O] Making an agenda that includes scheduled-for-later tasks?

2019-01-16 Thread Leo Gaspard
Hello all!

I am trying to make an agenda view of all tasks that don't have the
:Effort: property set, including tasks that are scheduled for later.

My init.el files includes the following lines (of interest is the "E"
agenda):
```
(setq org-agenda-custom-commands
  '(("U" "Unscheduled tasks"
 todo '("TODO" "WAITING")
 ((org-agenda-overriding-header "Unscheduled tasks")
  (org-agenda-skip-function '(org-agenda-skip-entry-if 'scheduled
("E" "Effortless tasks"
 todo '("TODO" "WAITING")
 ((org-agenda-overriding-header "Effortless tasks")
  (org-agenda-skip-function '(org-agenda-skip-entry-if 'regexp 
":Effort:" 'todo '("APPT")))
```

However, for some reason only tasks that are either not scheduled or
scheduled for some time in the past show up in this agenda. This makes
it useless, as the point is to remember to put in efforts for every
task *before* they are scheduled (and thus started)

Do you have an idea what I could have missed?

Thanking you in advance,
  Leo

PS: Also, I've noticed setting =todo '("TODO" "WAITING")= is apparently
not enough to get it to ignore the APPT-tagged items, so I've added the
filter to =org-agenda-skip-entry-if=. If you have an idea what I'm doing
wrong…



[O] Bug: org-capture with template for a table

2019-01-16 Thread Thomas Holst
Hello,

recently I encountered a bug with capturing table lines. Here is a ECM
to reproduce it:

- org-mode file (testing.org):
#+begin_src org
* Headline
|---+--+|
|   | Name | Amount |
|---+--+|
|---+--+|
|   |  ||
|---+--+|
#+TBLFM: @2$3=vsum(@-II..@-I);%.2f
#+end_src

- settings (init-file)
#+begin_src emacs-lisp
;; path settings for git repo
(add-to-list 'load-path "~/git-emacs/org-mode/contrib/lisp")
(add-to-list 'load-path "~/git-emacs/org-mode/contrib/babel/lisp")
;;; add org-mode/lisp as last
(add-to-list 'load-path "~/git-emacs/org-mode/lisp")

(require 'org)
(require 'org-capture)

(setq org-capture-templates
  '(("t" "testing" table-line (file+headline 
"~/Dropbox/emacs-testing/19-01-16-capture-table-line/testing.org" "Headline")
 "|#| |%^{amount}|" :table-line-pos "III-1" :immediate-finish t)))
#+end_src

I start emacs as follows:

: emacs -Q -l init-file.el --find-file testing.org

When I evaluate capture template I get following result:

#+begin_src org
* Headline
|---+--+|
|   | Name | Amount |
|---+--+|
| # |  |  33.00 |

|---+---+---|
|   |   |   |
|---+---+---|
#+TBLFM: @2$3=vsum(@-II..@-I);%.2f
#+end_src

First there is an empty line which breaks the table in two and secondly
the formula is not updated. This also happens when I delete the empty
line, correct formula and evaluate org-capture again.

With git-bisect I found that

commit c76486d4e431bf0c67d371341eb28445e7de4517
Author: Nicolas Goaziou 
Date:   Tue Oct 23 01:32:55 2018 +0200

org-capture: Fix off-by-one error
  
* lisp/org-capture.el (org-capture-place-table-line): Fix narrowing.

produces the error.

emacs-version:
"GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2018-05-29"

org-version:
Org mode version 9.2 (release_9.2-194-g955044 @
/home/thommy/git-emacs/org-mode/lisp/)

Thank you for looking into this.

-- 
Bis neulich ...
  Thomas