Re: using completion on header name to insert link

2020-08-21 Thread Samuel Wales
thank you.  i think the problem needs specifying better than i specified it.

basically, i use org-refile for refile and goto, and i just want
exactly the same thing for inserting links also.

this is close to that other thread, but i want to emphasize that the
goal is specifically to merely use the org-refile mechanism for
inserting links also.

[i guess the idea is that org-refile is in principle a generic
headline-filtering tool that is currently only used for refiling and
goto.  i want to have it do insert also.  perhaps the headline
filtering can be factored out as a generic tool and used to insert.
not sure.]

[more detail: i have various org-refile variables and a verify
function set to show me headers exactly right.  i use ido-hacks to
make the completion ido-ish, but that's not the relevant part.]

[more detail: org-id is also not the relevant part [except that, as a
bonus feature, inserting a link to a header without an org-id would,
only in this particular case, create an org-id in the target and link
using org-id, regardless of org-id settings].]



Re: [bug] deleting backward char does not do undo-boundary

2020-08-21 Thread Kyle Meyer
Samuel Wales writes:

> ah, so org did the remap and i tried to remap the remap?

Yes, with the standard value for org-mode-map, here's what
describe-variable (C-h v) says:

(remap keymap
  ...
  (delete-backward-char . org-delete-backward-char)




Re: using completion on header name to insert link

2020-08-21 Thread Kyle Meyer
Samuel Wales writes:

> i frequently use refile with ido to refile to and go to entries.
>
> is there a command to use the same completion to insert a link at point?
>
> for example, if i have an entry named pharmacy, and it has an org id,
> i can refile to it or go to it using ido.
>
> but can i be in an entry called whatever, and stay where i am, but
> insert a link to pharmacy using the refile ido mechanism?

I'm not aware of built-in functionality to do this.  There was a recent
thread about this on the list:
https://orgmode.org/list/cal9azktdbz2zd9ygs9uhesjypdbr9e1a6ef03utdrafpjoe...@mail.gmail.com



Re: [bug] deleting backward char does not do undo-boundary

2020-08-21 Thread Samuel Wales
ah, so org did the remap and i tried to remap the remap?

my brain is not working right now, but i think you might be right.  in
either case, your solution works and is straightforward.

thank you.


On 8/21/20, Kyle Meyer  wrote:
> Samuel Wales writes:
>
>> here is my code to try to fix it [note that i fix teh rest of emacs 25
>> also].  but that one command does not accept the undo-boundary that i
>> call.  i do not udnerstand why this is the case.
>
> Without looking at this too closely, I'd guess it's because ...
>
>>   (define-key org-mode-map [remap org-delete-backward-char]
>> #'alpha-org-delete-backward-char)
>>   (define-key org-mode-map [remap org-delete-char]
>> #'alpha-org-delete-char)
>>   (defun alpha-org-delete-char () (interactive)
>> (alpha-wrap-with-undo-boundary 'org-delete-char))
>>   (defun alpha-org-delete-backward-char () (interactive)
>> (alpha-wrap-with-undo-boundary 'org-delete-backward-char))
>
> ... you're trying to remap a command that is itself remapping a command.
>
>   (info "(elisp)remapping commands")
>
> In addition, remapping only works through a single level; in the
> following example,
>
>  (define-key my-mode-map [remap kill-line] 'my-kill-line)
>  (define-key my-mode-map [remap my-kill-line] 'my-other-kill-line)
>
> ‘kill-line’ is _not_ remapped to ‘my-other-kill-line’.  Instead, if
> an ordinary key binding specifies ‘kill-line’, it is remapped to
> ‘my-kill-line’; if an ordinary binding specifies ‘my-kill-line’, it
> is remapped to ‘my-other-kill-line’.
>
> Perhaps just bind it directly?
>
> (define-key org-mode-map (kbd "DEL") #'alpha-org-delete-backward-char)
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html



Re: Bug: Total shown clocked time of inlinetask includes the clocking of the parent task [9.3.7 (release_9.3.7-783-gd307b6 @ /home/yantar92/.emacs.d/straight/build/org/)]

2020-08-21 Thread Kyle Meyer
Ihor Radchenko writes:

> I have noticed that total clocked time shown while clocked-in into
> inlinetask includes the clocked time of its parent task.
>
> Expected behaviour: only the clocking time for the inline task itself
> should be shown.
>
> This can be fixed if org-clock-sum-current-item consider the case when
> point is at inlinetask.  The proposed fix is attached.

Thank you.  Please send the patch with a commit message, as described at
.



Re: [bug] deleting backward char does not do undo-boundary

2020-08-21 Thread Kyle Meyer
Samuel Wales writes:

> here is my code to try to fix it [note that i fix teh rest of emacs 25
> also].  but that one command does not accept the undo-boundary that i
> call.  i do not udnerstand why this is the case.

Without looking at this too closely, I'd guess it's because ...

>   (define-key org-mode-map [remap org-delete-backward-char]
> #'alpha-org-delete-backward-char)
>   (define-key org-mode-map [remap org-delete-char] #'alpha-org-delete-char)
>   (defun alpha-org-delete-char () (interactive)
> (alpha-wrap-with-undo-boundary 'org-delete-char))
>   (defun alpha-org-delete-backward-char () (interactive)
> (alpha-wrap-with-undo-boundary 'org-delete-backward-char))

... you're trying to remap a command that is itself remapping a command.

  (info "(elisp)remapping commands")

In addition, remapping only works through a single level; in the
following example,

 (define-key my-mode-map [remap kill-line] 'my-kill-line)
 (define-key my-mode-map [remap my-kill-line] 'my-other-kill-line)

‘kill-line’ is _not_ remapped to ‘my-other-kill-line’.  Instead, if
an ordinary key binding specifies ‘kill-line’, it is remapped to
‘my-kill-line’; if an ordinary binding specifies ‘my-kill-line’, it
is remapped to ‘my-other-kill-line’.

Perhaps just bind it directly?

(define-key org-mode-map (kbd "DEL") #'alpha-org-delete-backward-char)



Re: [BUG] babel runs bash instead of zsh when sessions are used

2020-08-21 Thread Kyle Meyer
Rudi C writes:

> #+BEGIN_SRC zsh :session z1
> echo $HOME $0
> #+END_SRC
>
> #+RESULTS:
> : /Users/evar /bin/bash

What version of Org are you using?

I tried with both the latest release (9.3.7) and the current master
branch (220f2b0d9), using default configuration aside from

(org-babel-do-load-languages
 'org-babel-load-languages
 '((shell . t)))

I see "/usr/bin/zsh" in both cases.



Re: configure separator in org-table-insert-hline

2020-08-21 Thread Nicolas Goaziou
Hello,

Vladimir Alexiev  writes:

> But I'm not talking about org-mode !
> I'm talking about orgtbl minor mode.

Of course you are talking about Org mode. You modified org-table-align,
which is clearly an Org function. Also, Orgtbl minor mode is a part of
Org.

> That minor mode is supposed to work in other modes (that's the whole
> purpose of its existence),
> and so it should be able to adapt to the table syntax of those
> modes/notations.

Not at all. It is supposed to bring Org tables into other major modes.
Not the other way. Do you think Orgtbl minor mode adapts to the syntax
in LaTeX?

You may use radio tables to transform an Org table into a Markdown table
(whatever that means, vanilla Markdown doesn't support tables).

Regards,
-- 
Nicolas Goaziou



Bug: Infinite loop in org-agenda-dim-blocked-tasks

2020-08-21 Thread Al Haji-Ali
On the latest release (9.3.7), I am running into an infinite loop when clocking 
in a blocked task if `org-enforce-todo-dependencies` is set to `t`.

The (manual) call stack is:
org-agenda-clock-in
org-agenda.el:9760 org-agenda-change-all-lines
org-agenda.el:9391 org-agenda-finalize
org-agenda.el:3879 org-agenda-dim-blocked-tasks

The while loop on line 4012 is infinite in this case.
The problem is because when `org-agenda-finalize` is called, the region is 
narrowed to a single line. Then in `org-agenda-dim-blocked-tasks` the function 
`(move-beginning-of-line 2)` is called to advance the point, which does not 
work when the buffer has a single line.

In an earlier version, the command `(forward-line)` was called which moved the 
point to eol when the buffer had a single line.

-- Al

Emacs  : GNU Emacs 27.1 (build 4, x8664-pc-linux-gnu, GTK+ Version 
3.22.30, cairo version 1.15.10)
 of 2020-08-21



Re: Bug: :results raw replace header args for a code block don't replace [9.3.7 (9.3.7-18-g093b47-elpaplus @ /Users/skoshelev/.emacs.d/elpa/26.2/develop/org-plus-contrib-20200810/)]

2020-08-21 Thread TEC


Nick Dokos  writes: 

TEC  writes: 
:results raw drawer 


You mean `:results drawer'? There is no reason to include `raw'. 


Ah yes, I mean instead of "raw" use ":results drawer" 

Timothy.


Re: [ANN] Org-webring

2020-08-21 Thread Brett Gilio
Marvin ‘quintus’ Gülker  writes:

> Am Freitag, dem 21. August 2020 schrieb Brett Gilio:
>> I hope this post is well received. Today marks the first stable release
>> of org-webring. Org-webring is an alternative implementation of a
>> feed-based webring, taking inspiration from openring by Drew DeVault.
>> Intended to integrate with Org-based websites and blogs (either
>> directly, or indirectly, as in ox-hugo), it will fetch a given list of
>> web feed files and correctly parse and format the elements to be
>> displayed for sharing.
>
> This looks pretty interesting. I am currently porting my blog from
> nanoc to Org and I could see use for this. In any case, thank you for
> sharing this.
>
>   -quintus

Quintus,

Thank you for your kind remark! More development on the project is to
come. I hope you enjoy it in its current iteration, and will follow for
future releases!

Brett Gilio



Re: [ANN] Org-webring

2020-08-21 Thread Marvin ‘quintus’ Gülker
Am Freitag, dem 21. August 2020 schrieb Brett Gilio:
> I hope this post is well received. Today marks the first stable release
> of org-webring. Org-webring is an alternative implementation of a
> feed-based webring, taking inspiration from openring by Drew DeVault.
> Intended to integrate with Org-based websites and blogs (either
> directly, or indirectly, as in ox-hugo), it will fetch a given list of
> web feed files and correctly parse and format the elements to be
> displayed for sharing.

This looks pretty interesting. I am currently porting my blog from
nanoc to Org and I could see use for this. In any case, thank you for
sharing this.

  -quintus

-- 
Dipl.-Jur. M. Gülker | https://mg.guelker.eu |For security:
Unna, Germany| kont...@guelker.eu| () Avoid HTML e-mail
European Union   | PGP: see homepage | /\ http://asciiribbon.org



Re: Bug: :results raw replace header args for a code block don't replace [9.3.7 (9.3.7-18-g093b47-elpaplus @ /Users/skoshelev/.emacs.d/elpa/26.2/develop/org-plus-contrib-20200810/)]

2020-08-21 Thread Nick Dokos
TEC  writes:

> Julius Dittmar  writes:  
>> as far as I know this is no bug. Reason: How could org tell where
>> the old results end? There's no end marker. Thus instead of removing
>> everything that follows, it refrains from removing anything. 
>
> This is my understanding. It's also why I tend to use
>
> :results raw drawer
>

You mean `:results drawer'? There is no reason to include `raw'.

-- 
Nick

"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler




Indirect buffers, org-store-link, and org-insert-link

2020-08-21 Thread Maxim Nikulin

#+TITLE: Indirect buffers, ~org-store-link~, and ~org-insert-link~

#+begin_abstract
It is inconvenient to work with links pointing to =CUSTOM_ID= anchors
when indirect buffers are involved. Either file name is added to link
or appropriate link target is not stored at all.
#+end_abstract

* Introduction

I have tried to use indirect buffers (=C-u C-c C-x C-b=)
to quickly jump between 2 or 3 location in an org file.
The intention was to add some details to notes
and to cross-link them using =CUSTOM_ID= properties.
Unfortunately behavior of ~org-store-link~ and ~org-insert-link~
functions is not perfect in such use case.
~org-goto~ interface =C-u C-c C-j= is not a suitable
alternative to avoid indirect buffers especially when frame
is split into to windows and ~org-occur~ is invoked
to find something.

* Regular buffer link target
  :PROPERTIES:
  :CUSTOM_ID: reg_buf_target
  :END:

Save link to this section using
=M-x (org-store-link)=

* Link stored from regular buffer inserted to regular buffer

Insert link with =C-u C-u C-u C-c C-l=,
choose the one with =#= (it is the last one and
inserted by default) and clear link description

Actual result is just as the expected one:

: [[#reg_buf_target]]

I would like to get similar links while working with
indirect buffers containing parts of this file.

Store link once more if it was inserted without triple prefix

* Indirect buffer

Open an indirect buffer for this subtree
~M-x (org-tree-to-indirect-buffer)~
and switch to it

** Link inserted to indirect buffer
   :PROPERTIES:
   :CUSTOM_ID: indirect_buf_target
   :END:

Insert link stored from the regular buffer.
Actual result:
: [[file:indirect-link.org::#reg_buf_target]]
Expected result: no file name since link inserted
to the same file
: [[#reg_buf_target]]

Run =M-x org-store-link= to push link to this header.

** Link copied from indirect buffer and inserted to indirect buffer

=C-u C-u C-u C-c C-l= to insert link to previous section

Actual result: only link to header text is available for insertion.

Expected result: there is no problem to choose and to insert link as
: [[#indirect_buf_target]]

Close indirect buffer.

* Link stored in indirect buffer and inserted to regular buffer

Obviously, since a link with =CUSTOM_ID= anchor was not created
inside indirect buffer, it is impossible to create here a link as

: [[#indirect_buf_target]]

using completion menu.

* Version

#+begin_src emacs-lisp
  (concat (emacs-version)
  "\n" (org-version nil 't))
#+end_src

#+RESULTS:
: GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14)
:  of 2020-03-26, modified by Debian
: Org mode version 9.3.7 (release_9.3.7-716-g312a64 @ 
/home/test/src/emacs/org-mode/lisp/)


Is it possible to mark indirect buffers (add some
properties, etc.) in such way that there will be
no problems to obtain and compare file name
in ~org-store-link~ and ~org-insert-link~ functions?

P.S. Maybe links to header text were fixed in 
https://orgmode.org/list/8162z2tf8n.fsf...@gmail.com/





Re: configure separator in org-table-insert-hline

2020-08-21 Thread Vladimir Alexiev
>
> You may suggest it to Markdown mode. I think this is a terrible idea for
> Org mode: syntax should not be optional.
>

But I'm not talking about org-mode !
I'm talking about orgtbl minor mode.
That minor mode is supposed to work in other modes (that's the whole
purpose of its existence),
and so it should be able to adapt to the table syntax of those
modes/notations.

Yes, markdown-mode may need to do something to use orgtbl-mode.
The problem is that the two functions are not adaptable because "+" is
hard-coded in them.


Re: configure separator in org-table-insert-hline

2020-08-21 Thread Nicolas Goaziou
Vladimir Alexiev  writes:

> Here's some code that works for me.
> It overwrites 2 org table functions, changing just one line (see "FIXED").
> Would be nice if this can be adopted in org; of course with a proper option
> etc.

You may suggest it to Markdown mode. I think this is a terrible idea for
Org mode: syntax should not be optional.

Regards,



Re: configure separator in org-table-insert-hline

2020-08-21 Thread Vladimir Alexiev
> That will not work without changing Org syntax. Markdown and Org table
are incompatible.

I guess you're right re support for formulas, table export, table
input/output from code, etc.
But I don't expect any of that of Markdown tables.
All I expect is that I can use table editing and alignment, and have proper
markdown hlines.

Here's some code that works for me.
It overwrites 2 org table functions, changing just one line (see "FIXED").
Would be nice if this can be adopted in org; of course with a proper option
etc.

Cheers!


;; Make org table minor mode (orgtbl-mode) support "|" as hline separator
in markdown

(add-hook 'orgtbl-mode-hook
  (defun my-orgtbl-mode-hook ()
(set (make-local-variable 'org-table-hline-separator)
 (if (memq major-mode '(markdown-mode gfm-mode))
 "|" "+"

(eval-after-load "org" '(fset 'org-table-align 'my-org-table-align))
(eval-after-load "org-table" '(fset 'org-table-insert-hline
'my-org-table-insert-hline))

(defun my-org-table-align ()
  "Align the table at point by aligning all vertical bars."
  (interactive)
  (let ((beg (org-table-begin))
(end (copy-marker (org-table-end
(org-table-save-field
 ;; Make sure invisible characters in the table are at the right
 ;; place since column widths take them into account.
 (org-font-lock-ensure beg end)
 (move-marker org-table-aligned-begin-marker beg)
 (move-marker org-table-aligned-end-marker end)
 (goto-char beg)
 (org-table-with-shrunk-columns
  (let* ((indent (progn (looking-at "[ \t]*") (match-string 0)))
;; Table's rows as lists of fields.  Rules are replaced
;; by nil.  Trailing spaces are removed.
(fields (mapcar
 (lambda (l)
(and (not (string-match-p org-table-hline-regexp l))
(org-split-string l "[ \t]*|[ \t]*")))
 (split-string (buffer-substring beg end) "\n" t)))
;; Compute number of columns.  If the table contains no
;; field, create a default table and bail out.
(columns-number
 (if fields (apply #'max (mapcar #'length fields))
(kill-region beg end)
(org-table-create org-table-default-size)
(user-error "Empty table - created default table")))
(widths nil)
(alignments nil))
;; Compute alignment and width for each column.
(dotimes (i columns-number)
 (let* ((max-width 1)
(fixed-align? nil)
(numbers 0)
(non-empty 0))
   (dolist (row fields)
 (let ((cell (or (nth i row) "")))
(setq max-width (max max-width (org-string-width cell)))
(cond (fixed-align? nil)
 ((equal cell "") nil)
 ((string-match "\\`<\\([lrc]\\)[0-9]*>\\'" cell)
  (setq fixed-align? (match-string 1 cell)))
 (t
  (cl-incf non-empty)
  (when (string-match-p org-table-number-regexp cell)
(cl-incf numbers))
   (push max-width widths)
   (push (cond
  (fixed-align?)
  ((>= numbers (* org-table-number-fraction non-empty)) "r")
  (t "l"))
 alignments)))
(setq widths (nreverse widths))
(setq alignments (nreverse alignments))
;; Store alignment of this table, for later editing of single
;; fields.
(setq org-table-last-alignment alignments)
(setq org-table-last-column-widths widths)
;; Build new table rows.  Only replace rows that actually
;; changed.
(dolist (row fields)
 (let ((previous (buffer-substring (point) (line-end-position)))
(new
(format "%s|%s|"
indent
(if (null row) ;horizontal rule
(mapconcat (lambda (w) (make-string (+ 2 w) ?-))
widths
org-table-hline-separator) ;; FIXED
  (let ((cells ;add missing fields
 (append row
 (make-list (- columns-number
(length row))
""
(mapconcat #'identity
(cl-mapcar #'org-table--align-field
  cells
  widths
  alignments)
"|"))
   (if (equal new previous)
(forward-line)
 (insert new "\n")
 (delete-region (point) (line-beginning-position 2)
(set-marker end nil)
(when org-table-overlay-coordinates (org-table-overlay-coordinates))
(setq org-table-may-need-update nil))

(defun my-org-table-insert-hline ( above)
  "Insert a horizontal-line below the current line into the table.
With prefix ABOVE, insert above the current line."
  (interactive "P")
  (unless (org-at-table-p) (user-error "Not at a table"))
  (when (eobp) (save-excursion (insert "\n")))
  (unless (string-match-p "|[ \t]*$" (org-current-line-string))
(org-table-align))
  (org-table-with-shrunk-columns
   (let ((line (org-table-clean-line
(buffer-substring (point-at-bol) (point-at-eol
(col (current-column)))
 (while (string-match "|\\( +\\)|" line)
   (setq line (replace-match
  (concat org-table-hline-separator ;; FIXED
   (make-string (- (match-end 1) (match-beginning
1)) ?-)
   "|") t t line)))
 (and (string-match "\\+" line) (setq line (replace-match "|" t t
line)))
 (beginning-of-line (if above 1 2))
 (insert line "\n")
 (beginning-of-line (if above 1 -1))
 (org-move-to-column col)
 (when org-table-overlay-coordinates (org-table-align)


Re: configure separator in org-table-insert-hline

2020-08-21 Thread Nicolas Goaziou
Hello,

Vladimir Alexiev  writes:

> org-table-insert-hline (org-table.el) inserts lines like this
> |++|
>
> But I often use orgtbl-mode in markdown-mode,
> and in markdown the hlines should be like this:
> ||||
>
> Perhaps all that's needed is to make this conditional:
> (concat "+"

That will not work without changing Org syntax. Markdown and Org table
are incompatible.

Regards,
-- 
Nicolas Goaziou



configure separator in org-table-insert-hline

2020-08-21 Thread Vladimir Alexiev
org-table-insert-hline (org-table.el) inserts lines like this
|++|

But I often use orgtbl-mode in markdown-mode,
and in markdown the hlines should be like this:
||||

Perhaps all that's needed is to make this conditional:
(concat "+"


Re: Bug: org-set-tags-command deletes inherited tags [9.3.7 (9.3.7-18-g093b47-elpaplus @ /home/ionasal/.emacs.d/elpa/org-plus-contrib-20200810/)]

2020-08-21 Thread Allen Li
Kyle Meyer  writes:

> That looks good as far as fixing the misbehavior you report.  I wonder
> though whether there's a deeper org-get-tags issue here worth
> considering.  Its documentation says
>
> ... the returned list of tags contains tags in this order: file
> tags, tags inherited from parent headlines, local tags.
>
> But it's not specified what happens when a tag is both local and
> inherited.  The current implementation drops the local tag variant
> through its delete-dups call:
>
> (delete-dups
>  (append (org-remove-uninherited-tags itags) ltags))
>
> I would have expected the local tag to get priority here.  If that were
> the case (e.g., something like below), that would also solve the issue
> you describe.
>
> Thoughts?

That sounds reasonable, let me prepare a new patch.

>
> -- >8 --
> diff --git a/lisp/org.el b/lisp/org.el
> index fb95590fc..3dac42b7b 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -12310,8 +12310,10 @@ (defun org-get-tags ( pos local)
>(org--get-local-tags))
>itags)))
>  (setq itags (append org-file-tags itags))
> -(delete-dups
> - (append (org-remove-uninherited-tags itags) ltags
> +(nreverse
> + (delete-dups
> +  (nreverse (nconc (org-remove-uninherited-tags itags)
> +   ltags))
>  
>  (defun org-get-buffer-tags ()
>"Get a table of all tags used in the buffer, for completion."



Re: Bug: :results raw replace header args for a code block don't replace [9.3.7 (9.3.7-18-g093b47-elpaplus @ /Users/skoshelev/.emacs.d/elpa/26.2/develop/org-plus-contrib-20200810/)]

2020-08-21 Thread TEC


Julius Dittmar  writes: 

as far as I know this is no bug. Reason: How could org tell 
where the old results end? There's no end marker. Thus instead 
of removing everything that follows, it refrains from removing 
anything. 


This is my understanding. It's also why I tend to use

:results raw drawer

Hope that helps.

Timothy.



Re: Bug: :results raw replace header args for a code block don't replace [9.3.7 (9.3.7-18-g093b47-elpaplus @ /Users/skoshelev/.emacs.d/elpa/26.2/develop/org-plus-contrib-20200810/)]

2020-08-21 Thread Julius Dittmar
Hi Sergey,

Am 18.08.20 um 00:36 schrieb Sergey Koshelev:
> When a source block (I have tested with python, see below) has `raw`
> header arg it ignores `replace` argument. The result instead is prepended.
>
> Example:
>
> #+begin_src python :results output raw replace
>   print('This line will be added every time this code runs')
> #+end_src
>
> #+RESULTS:
> This line will be added every time this code runs
> This line will be added every time this code runs

as far as I know this is no bug. Reason: How could org tell where the
old results end? There's no end marker. Thus instead of removing
everything that follows, it refrains from removing anything.

HTH,
Julius Dittmar