Re: problem when linking to headlines?

2020-02-26 Thread Alan Schmitt
On 2020-02-26 16:38, Nicolas Goaziou  writes:

> Oops. Fixed. Thank you!

Thanks a lot for the quick fix!

Best,

Alan



Re: How to collapse all LOGBOOKS at once?

2020-02-26 Thread William Denton

On 27 February 2020, Kyle Meyer wrote:


William Denton  writes:


The only thing I really use drawers for is with clock tracking, so for me this
is just about :LOGBOOK: but it could be about other types of drawers, or all
drawers:  is there a way to collapse them all at once?


I'm not aware of a dedicated command that does that, but I think you can
get the behavior you're after by defining a command that calls

 (org-cycle-hide-drawers 'all)


Aha, thanks!  There are probably many betters way to do it, but this works:

;; Use C-c d to close all the open drawers in a file
(defun add-org-close-all-drawers-key ()
  (local-set-key (kbd "C-c d") (lambda () (interactive) (org-cycle-hide-drawers 
'all
(add-hook 'org-mode-hook 'add-org-close-all-drawers-key)

Bill
--
William Denton :: Toronto, Canada   ---   Listening to Art: 
https://listeningtoart.org/
https://www.miskatonic.org/ ---   GHG.EARTH: https://ghg.earth/
Caveat lector.  ---   STAPLR: https://staplr.org/



Re: How to collapse all LOGBOOKS at once?

2020-02-26 Thread Kyle Meyer
William Denton  writes:

> The only thing I really use drawers for is with clock tracking, so for me 
> this 
> is just about :LOGBOOK: but it could be about other types of drawers, or all 
> drawers:  is there a way to collapse them all at once?

I'm not aware of a dedicated command that does that, but I think you can
get the behavior you're after by defining a command that calls

  (org-cycle-hide-drawers 'all)



Re: Running in-line babel code at auto-insert template file open

2020-02-26 Thread Lawrence Bottorff
Got a good answer over at emacs.stackexchange

that
uses Emacs text-buffer lore. Still, it seems like org-mode should be able
to auto-run in-line code just like the solution does. Alas, someday I hope
to be able to just tackle a problem like this and submit the solution. Hope
springs eternal (which Google-Gmail just auto-completed!)...

On Mon, Feb 24, 2020 at 9:51 PM Lawrence Bottorff  wrote:

> Let's say I have a standard org file I want to have created multiple
> times. I've created a template file and told Emacs autoinsert where it is.
> Here's the relevant in my init
>
> (use-package autoinsert
>   :ensure t
>   ...
>   :config
>   (define-auto-insert "poolchem.org?$" "poolchem.org"))
>
> So in this template file poolchem.org I have six table skeletons, but I
> also want various customized additions. For example, I would like the table
> names to reflect the current week starting with the coming Sunday's date
>
> #+tblname: pc1-*src_emacs-lisp[:results raw]{(org-read-date nil nil
> "++sun" nil (org-time-string-to-time "2020-02-24"))}*
>
> which would hopefully show up in the newly created buffer as
>
> #+tblname: pc1-2020-03-01
>
> But then nothing of the sort happens, i.e., the in-line code just comes
> back verbatim when I create a new file, unevaluated. I guess I'm totally
> missing what is going on with in-line code. It seems other methods of
> template creation allow code to be embedded, then to be evaluated. (The
> variable auto-insert-alist has entire templates.) I've experimented with
> eval of org-sbe in # local variables: ... but that was for running code
> blocks upon file open, not individual embedded functions that would
> customize my newly created org file. Any ideas?
>
> LB
>
>


How to collapse all LOGBOOKS at once?

2020-02-26 Thread William Denton
The only thing I really use drawers for is with clock tracking, so for me this 
is just about :LOGBOOK: but it could be about other types of drawers, or all 
drawers:  is there a way to collapse them all at once?


When I'm fixing up the amounts of time I've been working on this, or when I sync 
a file across two machines, I often end up with a lot of LOGBOOK drawers open 
but they're just taking up screen space.  Using TAB to close them one by one is 
good for a bit of tidying, but I'd like to do them all at once.


Thanks,

Bill
--
William Denton :: Toronto, Canada   ---   Listening to Art: 
https://listeningtoart.org/
https://www.miskatonic.org/ ---   GHG.EARTH: https://ghg.earth/
Caveat lector.  ---   STAPLR: https://staplr.org/



Re: correct remote path handling

2020-02-26 Thread Felipe Lema
Hey, y'all

I found out that ob-shell was more broken than I thought so I had to upgrade 
my sword and get a new shield to fix it.

Tramp support for ob-python and ob-shell look OK now, although still no tests. 
I'll wait until this review is done until I start working on the tests. Will 
probably take a while because I'm thinking of some cross-section code that 
will do the a set of tests (all current? some marked? some new instead?) using 
a remote directory.

Using `ssh localhost` should suffice, but should these remote tests be done by 
default? It's most likely that everyone running tests will require a 
passwordless setup. While I've automatized this for a separate package, it may 
be bothersome to someone else (see [1]).

Anyway, I hope the patch file is correct now. I messed up my mirror repo and I 
/think/ I got it right.

BTW I just got a mail that FSF papers are approved now.

Gards, Felipe

[1]: https://github.com/FelipeLema/emacs-counsel-gtags/blame/
5d2a8c2c2d358e374a576cf8a3a67f7997a8839b/.travis.yml#L6

On Tuesday, 25 February 2020 16:14:05 -03 Bastien wrote:
> Hi Felipe and Jack,
> 
> > Felipe Lema  writes:
> >> I've signed the necessary papers from (to?) the FSF involving org
> >> mode, so I'm ready on my side to add tests and maybe add support
> >> for other tramp-related stuff.
> 
> I've checked and the papers are not yet processed by the FSF.
> 
> > Great, we should add you to the list of copyrighted contributors:
> > https://orgmode.org/worg/org-contribute.html
> 
> Done -  https://orgmode.org/worg/org-contribute.html#org7c578f2
> 
> Let's iterate on this patch and get it ready for 9.5.
> 
> Thanks,

fix tramp support for ob-shell & ob-python

* ob-python.el (org-babel-python-evaluate-session): use file path local to (maybe) remote process.
* ob-shell.el (org-babel-execute:shell, org-babel-sh-evaluate): call-process-…→ process-file-… (tramp aware), wrap :session block in a function, separate "ob overhead" from "eval block", add documentation.

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index dbcfac08d..1afea9cb3 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -327,7 +327,8 @@ last statement in BODY, as elisp."
 		  "python-")))
 			   (with-temp-file tmp-src-file (insert body))
 			   (format org-babel-python--exec-tmpfile
-   tmp-src-file))
+   (org-babel-local-file-name
+	tmp-src-file)))
 			   body)))
 	   (mapconcat
 		#'org-trim
@@ -345,9 +346,10 @@ last statement in BODY, as elisp."
 	  "python-")))
 			   (with-temp-file tmp-src-file (insert body))
 			   (format org-babel-python--eval-ast
-   tmp-src-file
-   (org-babel-comint-with-output
-   (session org-babel-python-eoe-indicator nil body)
+   (org-babel-local-file-name
+tmp-src-file)
+	   (org-babel-comint-with-output
+		   (session org-babel-python-eoe-indicator nil body)
  (let ((comint-process-echoes nil))
(funcall input-body body)
 		   (dolist
diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el
index 347ffedd1..66cdfb94c 100644
--- a/lisp/ob-shell.el
+++ b/lisp/ob-shell.el
@@ -82,12 +82,17 @@ This function is called by `org-babel-execute-src-block'."
 	 (value-is-exit-status
 	  (member "value" (cdr (assq :result-params params
 	 (cmdline (cdr (assq :cmdline params)))
+	 (shebang (cdr (assq :shebang params)))
+	 (padline (not (equal "no" (cdr (assq :padline params)
+	 (result-params (cdr (assq :result-params params)))
  (full-body (concat
 		 (org-babel-expand-body:generic
 		  body params (org-babel-variable-assignments:shell params))
 		 (when value-is-exit-status "\necho $?"
 (org-babel-reassemble-table
- (org-babel-sh-evaluate session full-body params stdin cmdline)
+ (org-babel-sh-evaluate session full-body
+			stdin cmdline shebang value-is-exit-status padline
+			result-params)
  (org-babel-pick-name
   (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
  (org-babel-pick-name
@@ -206,76 +211,114 @@ var of the same value."
   "String to indicate that evaluation has completed.")
 (defvar org-babel-sh-eoe-output "org_babel_sh_eoe"
   "String to indicate that evaluation has completed.")
+(defvar org-babel-sh-block-function-name "org_babel_block"
+  "Name of the shell function that will hold the code to be executed.")
 
-(defun org-babel-sh-evaluate (session body  params stdin cmdline)
-  "Pass BODY to the Shell process in BUFFER.
-If RESULT-TYPE equals `output' then return a list of the outputs
-of the statements in BODY, if RESULT-TYPE equals `value' then
-return the value of the last statement in BODY."
-  (let* ((shebang (cdr (assq :shebang params)))
-	 (value-is-exit-status
-	  (member "value" (cdr (assq :result-params params
-	 (results
-	  (cond
-	   ((or stdin cmdline)	   ; external shell script w/STDIN
-	(let ((script-file (org-babel-temp-file "sh-script-"))
-		  

Re: get subtree contents as string

2020-02-26 Thread Eric Abrahamsen
Matt Price  writes:

> I have the following convenience function that scans contents of a subtree
> and then sets a property, adds an overlay, and changes the TODO status:
> (defun org-lms-set-grade ()
>   "set grade property for all headings on basis of \"- Grade :: \" line
>   Use with caution."
>   (interactive)
>   (save-restriction
> (org-narrow-to-subtree)
>   (save-excursion
>   (org-back-to-heading)
>   (while (re-search-forward ol-grade-regex nil t )
> (org-set-property "GRADE" (or (match-string 2) 0))
> (org-todo "READY"
>   (org-lms-overlay-headings)  )
>
> It works, but there's a short (<1sec) non-responsive period when it runs.
> I'm wondering if it has to do with ~org-narrow-to-subtree~, so I thought
> I'd just copy the contents of the subtree as a string and replace
> re-search-forward with string-match. However, I'm not finding a
> super-obvious way to copy the subtree as a string. Am I missing something?
> And am I likely to be right that that's the source of the delay (as I write
> this, I'mwondering if hte overlay drawing might be the real problem? The
> whole project this is part of (https://github.com/titaniumbones/org-lms)
> suffers from delays while the buffer redraws, so I'm keen to figure out
> Better Ways To Do Things.

If it's just a matter of getting the subtree text, you could use
buffer-substring with org-end-of-subtree to find the end of the string.
Does that do it?




get subtree contents as string

2020-02-26 Thread Matt Price
I have the following convenience function that scans contents of a subtree
and then sets a property, adds an overlay, and changes the TODO status:
(defun org-lms-set-grade ()
  "set grade property for all headings on basis of \"- Grade :: \" line
  Use with caution."
  (interactive)
  (save-restriction
(org-narrow-to-subtree)
  (save-excursion
  (org-back-to-heading)
  (while (re-search-forward ol-grade-regex nil t )
(org-set-property "GRADE" (or (match-string 2) 0))
(org-todo "READY"
  (org-lms-overlay-headings)  )

It works, but there's a short (<1sec) non-responsive period when it runs.
I'm wondering if it has to do with ~org-narrow-to-subtree~, so I thought
I'd just copy the contents of the subtree as a string and replace
re-search-forward with string-match. However, I'm not finding a
super-obvious way to copy the subtree as a string. Am I missing something?
And am I likely to be right that that's the source of the delay (as I write
this, I'mwondering if hte overlay drawing might be the real problem? The
whole project this is part of (https://github.com/titaniumbones/org-lms)
suffers from delays while the buffer redraws, so I'm keen to figure out
Better Ways To Do Things.

Thanks as always,
Matt


Bibliography entry in the menu-bar

2020-02-26 Thread Sharon Kimble

I'm hoping that someone can help, but when I'm in a buffer of my
bibliography, there is a drop-down list in the menu-bar, of buffer
commands titled 'Entry-Types'. But what program puts it there?

I want to create a new command to an entry in it, but I don't know what
the originating program is. Can anyone help please?

Thanks
Sharon.
-- 
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk
Debian 10.2, fluxbox 1.3.7, emacs 26.3, org 9.3.6


signature.asc
Description: PGP signature


Re: problem when linking to headlines?

2020-02-26 Thread Nicolas Goaziou
Hello,

Alan Schmitt  writes:

> I have these two files:
>
> link1.org:
>
> * Test
>
> link2.org:
>
> [[file:link1.org::*Test][Test]]
>
> When I click on the first link, I get this in a dired buffer (there is
> no error).
>
>   /home/schmitta/tmp:
>   wildcard link1.org::*Test
>   zsh:1: no matches found: link1.org::*Test
>
> I'm using Org Mode 9.4, and this issue started occurring recently after
> I upgraded org.
>
> Is this a consequence of the recent change on file links? How can I
> debug which link handler is used?

Oops. Fixed. Thank you!

The link handler is "file", using `org-link-open-as-file' to follow it.

Regards,

-- 
Nicolas Goaziou



Re: attachment: link type export to HTML invalid attach dir

2020-02-26 Thread Nicolas Goaziou
Hello,

Gustav Wikström  writes:

> Expanding attachment-links in the buffer makes the link type no longer
> be attachment.

What makes you think that? The link type is preserved during the
substitution, according to the (concat "attachment" ...).

> I would prefer if we explicitly set the link type to
> files here instead. Storing intermediate state in an attachment link
> types makes less sense imo.
>
> One issue with the current way it's done is that images are treated
> differently between attachment links and file links. For HTML exports,
> file links are wrapped in a div with class figure where expanded
> attachment links are not.

It would be nice to investigate why this happens.

> Letting org-attach-expand-links do the full
> transform to file links would solve that issue. That also
> means :export is not needed for org-link-set-parameters.
>
> Patch attached if you agree to this.

Of course! This is what I suggested, like, 6 weeks ago (although, at
this time, I was thinking about having the substitution in "ox.el").

Regards,

-- 
Nicolas Goaziou



problem when linking to headlines?

2020-02-26 Thread Alan Schmitt
Hello,

I have these two files:

link1.org:

* Test

link2.org:

[[file:link1.org::*Test][Test]]

When I click on the first link, I get this in a dired buffer (there is
no error).

  /home/schmitta/tmp:
  wildcard link1.org::*Test
  zsh:1: no matches found: link1.org::*Test

I'm using Org Mode 9.4, and this issue started occurring recently after
I upgraded org.

Is this a consequence of the recent change on file links? How can I
debug which link handler is used?

Thanks,

Alan