Re: [PATCH] Add org-md-src-block for src-block formater

2020-08-26 Thread Nicolas Goaziou
Hello,

Naoya Yamashita  writes:

> I found `ox-md` exporter drop src-block language information.
> My patch fixes the behavior.

This is a feature. "ox-md" exports to vanilla Markdown, which doesn't
support such syntax. You may want to use other back-ends, e.g.,
"ox-gfm".

Regards,
-- 
Nicolas Goaziou



[PATCH] Add org-md-src-block for src-block formater

2020-08-26 Thread Naoya Yamashita
Hi,
I found `ox-md` exporter drop src-block language information.
My patch fixes the behavior; to embed src-block language information
using markdown src block grammar.

1. Open some buffer
2. Tnsert below code
3. Turn on `org-mode`
4. `C-c C-e m M` (export as markdown in temp buffer)

## org source
```org
#+begin_src python
print(1 + 2)
#+end_src

#+begin_src emacs-lisp
(print "hello")
#+end_src

#+begin_src
something source code
#+end_src
```

## before
```markdown

# Table of Contents



print(1 + 2)

(print "hello")

something source code

```

## after
```markdown

# Table of Contents



```python
print(1 + 2)
```

```emacs-lisp
(print "hello")
```

```
something source code
```

```
From 0ffa1f8f6dede26b7f1e8ce4afc1fbcd2f45755b Mon Sep 17 00:00:00 2001
From: conao3 
Date: Thu, 27 Aug 2020 13:52:50 +0900
Subject: [PATCH] Add org-md-src-block for src-block formater

* lisp/ox-md.el (org-md-src-block): Add new formater for src block
* lisp/ox-md.el (org-export-define-derived-backend 'md): use it
---
 lisp/ox-md.el | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index 1d20c04f4..59db0c765 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -110,7 +110,7 @@ The %s will be replaced by the footnote reference itself."
 		 (quote-block . org-md-quote-block)
 		 (section . org-md-section)
 		 (special-block . org-md--convert-to-html)
-		 (src-block . org-md-example-block)
+		 (src-block . org-md-src-block)
 		 (table . org-md--convert-to-html)
 		 (template . org-md-template)
 		 (verbatim . org-md-verbatim))
@@ -331,6 +331,18 @@ channel."
(org-remove-indentation
 (org-export-format-code-default example-block info
 
+(defun org-md-src-block (src-block _contents info)
+  "Transcode SRC-BLOCK element into Markdown format.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (let ((lang (pcase (plist-get info :parse-tree)
+(`(org-data ,_ (section ,_ (src-block (:language ,l . ,_ l
+(format
+ "```%s\n%s```"
+ (or lang "")
+ (org-remove-indentation
+  (org-export-format-code-default src-block info)
+
 (defun org-md-export-block (export-block contents info)
   "Transcode a EXPORT-BLOCK element from Org to Markdown.
 CONTENTS is nil.  INFO is a plist holding contextual information."
-- 
2.28.0



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-08-26 Thread Kyle Meyer
Eric S Fraga writes:

> Hi,
>
> for those of us using more recent versions of Emacs, the new
> tab-bar-mode can be quite useful.  As I have been playing with, I
> thought it would make sense to have the option for agenda views to
> pop-up in a new tab as an option.  I've coded something that behaves in
> a similar way to the 'other-frame option that currently exists for
> org-agenda-window-setup.
>
> Patch attached.  Comments welcome, of course.

Thanks.  Sounds fine to me.

> Subject: [PATCH] added other-tab option for org-agenda-window-setup
>
> * org-agenda.el (org-agenda-prepare-window, org-agenda--quit): handle
> other-tab option for agenda view creation and exit.

Style conventions: s/added/Add/s/handle/Handle/

> ---
>  lisp/org-agenda.el | 18 +-
>  1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index 8ebc882fc..abb969fe4 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -1100,11 +1100,15 @@ reorganize-frame  Show only two windows on the 
> current frame, the current
>window and the agenda.
>  other-frame   Use `switch-to-buffer-other-frame' to display agenda.
>Also, when exiting the agenda, kill that frame.
> +other-tab Use `switch-to-buffer-other-tab' to display the agenda.
> +  Also, kill that tab when exiting the agenda view.
> +

I think it's worth noting here which Emacs version gained tab support.

>  See also the variable `org-agenda-restore-windows-after-quit'."
>:group 'org-agenda-windows
>:type '(choice
> (const current-window)
> (const other-frame)
> +   (const other-tab)
> (const other-window)
> (const only-window)
> (const reorganize-frame)))
> @@ -1118,11 +1122,11 @@ It only matters if `org-agenda-window-setup' is 
> `reorganize-frame'."
> [...]
> @@ -3769,6 +3773,8 @@ FILTER-ALIST is an alist of filters we need to apply 
> when
>(org-switch-to-buffer-other-window abuf))
>   ((eq org-agenda-window-setup 'other-frame)
>(switch-to-buffer-other-frame abuf))
> + ((eq org-agenda-window-setup 'other-tab)
> +  (switch-to-buffer-other-tab abuf))
>   ((eq org-agenda-window-setup 'only-window)
>(delete-other-windows)
>(pop-to-buffer-same-window abuf))
> @@ -7389,6 +7395,8 @@ agenda."
>(cond
> ((eq org-agenda-window-setup 'other-frame)
>   (delete-frame))
> +   ((eq org-agenda-window-setup 'other-tab)
> + (tab-bar-close-tab))
> ((and org-agenda-restore-windows-after-quit
>wconf)

As you suggest in your follow-up message, you need to guard these calls
for the sake of older versions.  Perhaps something like

(if (fboundp 'FN)
(FN ...)
  (user-error "Your Emacs version doesn't support tabs"))

in both spots.  (That will silence the byte-compiler warnings too.)



[PATCH] Re: org-forward-heading-same-level and the invisible-ok argument

2020-08-26 Thread D

> I guess it is simply because nobody though that the leading stars can be
> hidden via fontification.
> 
> I think the whole issue can be fixed by changing the call to
> org-invisible-p inside org-forward-heading-same-level. org-invisible-p
> has an optional third argument to ignore text hidden via fontification.
> You can try to make a patch for org-forward-heading-same-level and
> similar commands adding that third argument.

I looked into the git repository and noticed that org-invisible-p
already, thanks to a patch from Nicolas Goaziou (b1822760f4).
What I am wondering is whether it would make more sense as an argument
for org-forward-heading-same-level and similar commands, or as a
(potentially buffer-local) org variable to tweak the behavior, given
it's most likely going to affect these functions as interactive commands
(see alternative_org.el.diff).  This version has the advantage of
allowing minor modes to easily mess with Org's behavior buffer-locally.

I considered how adding a third argument to
org-forward-heading-same-level, but realized that adding another
invisibility argument would kinda leak a little complexity, as we'd wind
up with TWO invisibility-related arguments (which only differ in subtle
ways) and their interactions.  So instead I'd recommend to instead allow
a distinct, non-nil option for invisible-ok, for example `t', `nil' and
`except-folding' (see org.el.diff).  This version would be more
transparent, as it would not change the behavior of ALL calls in the
buffer, but comes at the cost of minor modes needing to overshadow
bindings to accomplish the same.

I whipped up a quick diff for both versions, and will gladly make a
patch once we settled on one, but I wanted to discuss which is
preferable before making an uninformed decision on my own.
diff --git a/lisp/org.el b/lisp/org.el
index 71dbc611e..b8e6d47c2 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20482,7 +20482,12 @@ entry."
   "Move forward to the ARG'th subheading at same level as this one.
 Stop at the first and last subheadings of a superior heading.
 Normally this only looks at visible headings, but when INVISIBLE-OK is
-non-nil it will also look at invisible ones."
+non-nil it will also look at invisible ones.
+
+If INVISIBLE-OK is set to the symbol `except-folding', continue
+ignoring all parts that are invisible due to folding of a
+headline, a block or a drawer, i.e., not because of
+fontification."
   (interactive "p")
   (let ((backward? (and arg (< arg 0
 (if (org-before-first-heading-p)
@@ -20495,12 +20500,14 @@ non-nil it will also look at invisible ones."
 	(result (point)))
 	(while (and (> count 0)
 		(funcall f org-outline-regexp-bol nil 'move))
-	  (let ((l (- (match-end 0) (match-beginning 0) 1)))
+	  (let ((l (- (match-end 0) (match-beginning 0) 1))
+		(folding-only (eq 'except-folding invisible-ok)))
 	(cond ((< l level) (setq count 0))
 		  ((and (= l level)
-			(or invisible-ok
+			(or (and invisible-ok (not folding-only))
 			(not (org-invisible-p
-  (line-beginning-position)
+  (line-beginning-position)
+  folding-only
 		   (cl-decf count)
 		   (when (= l level) (setq result (point)))
 	(goto-char result))
diff --git a/lisp/org.el b/lisp/org.el
index 71dbc611e..8e0040814 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20478,6 +20478,18 @@ entry."
 		((looking-at-p re) (forward-line))
 		(t (throw 'exit t
 
+
+(defcustom org-navigate-invisible-headings nil
+  "If non-nil, navigate through (unfolded) invisible headings normally.
+Commands such as `org-forward-heading-same-level' and
+`org-forward-heading-same-level' will consider all invisible
+headings except for those that are invisible due to folding of a
+headline, a block or a drawer."
+  :group 'org
+  :type '(choice
+	  (const :tag "Don't navigate invisible headings" nil)
+	  (const :tag "Navigate invisible (unfolded) headings" t)))
+
 (defun org-forward-heading-same-level (arg  invisible-ok)
   "Move forward to the ARG'th subheading at same level as this one.
 Stop at the first and last subheadings of a superior heading.
@@ -20498,9 +20510,11 @@ non-nil it will also look at invisible ones."
 	  (let ((l (- (match-end 0) (match-beginning 0) 1)))
 	(cond ((< l level) (setq count 0))
 		  ((and (= l level)
-			(or invisible-ok
+			(or (and invisible-ok
+ (not org-navigate-invisible-headings))
 			(not (org-invisible-p
-  (line-beginning-position)
+  (line-beginning-position)
+  org-navigate-invisible-headings
 		   (cl-decf count)
 		   (when (= l level) (setq result (point)))
 	(goto-char result))


Re: save plot in python babel

2020-08-26 Thread Jeremie Juste
Hello Jack,

Many thanks for having taken the time to reply.
I'll definitely try ob-jupyter. 

>
> My goal is to make ob-python a serious alternative to these external
> ob-* packages eventually. Here are some of the improvements I have in
> mind:
>
> - Improved plotting
> - Support for pandas DataFrames and numpy Arrays
> - Async session evaluation 
yes these improvements would be great. My elisp skills are poor but I'll
be sure to give you feedback on these features.


> I've been delayed working on this as I've gotten very busy due to the
> pandemic (I am a bioinformaticist working on SARS-CoV-2 sequencing). But
> I'm hoping to make a bit of progress this week, as I'm on vacation and
> unable to go outside due to the smoke from the California fires.
>
> It's unclear to me if we're in a feature freeze, so I'm currently
> pushing ob-python development to a separate branch [6], which I'll
> cherry pick into master after the Org 9.4 release.
In your own time will be just fine. I've been only an enthusiastic user
of org-mode until now. I'll go through the manual again and I'll try to
give back what I can.

Stay safe,
Jeremie






Re: Bug: no math-mode detection for align-environment [9.3.7 (9.3.7-13-ge62ca4-elpaplus @ /home/stefi/.emacs.d/elpa/org-plus-contrib-20200713/)]

2020-08-26 Thread Stefi
I can also confirm that org-try-cdlatex-tab outputs "t" in all cases but
does not expand in align environment.

I noticed that cdlatex-env-alist-default does not include the align
environment. I tried to add it to "Cdlatex Env Alist" in the customize
browser but it did not change the behavior to what I expect.

I skimmed through cdlatex.el but did not find anything suspicious. I am
not a hardcore lisp coder though.

On 8/26/20 5:44 AM, Kyle Meyer wrote:
> Stefi writes:
> 
>> Hi Kyle, hi mailing list,
>>
>> I also evaluated (org-inside-LaTeX-fragment-p) and got non-nil values
>> for all blocks, however, inside the align* environment, the "fr" does
>> not get expanded on TAB whereas it does in equation environment. So
>> either the matchers do not include align/align*, or there is something
>> different now with cdlatex.
> 
> I'm leaning towards there being something different with cdlatex.
> 
> I've now installed cdlatex from
> .  The
> file header says the version is 4.8, and the file's md5sum is
> 9246a4e9f30c9589406783ffd5270641.
> 
> I tried your example file with this minimal configuration:
> 
> (require 'org)
> (add-hook 'org-mode-hook (lambda () (org-cdlatex-mode 1)))
> (require 'edebug)
> (edebug-instrument-function 'org-try-cdlatex-tab)
> 
> As you and Rafael report, "fr => \frac{}{}" is not expanded in the align
> or align* environments, while it is expanded in the equation
> environment.  However, stepping through the org-try-cdlatex-tab call,
> cdlatex-tab is called in all cases.  So it would seem that something has
> changed downstream.
> 
> In line with this idea, I observed the same behavior with both the
> latest commit of the master branch (cdfc404be) and v9.2 (released in Dec
> 2018).  Also, as I mentioned in earlier in the thread, I don't see any
> recent changes on Org's side related to the cdlatex functionality.
> 



new feature for consideration: other-tab for org-agenda-window-setup

2020-08-26 Thread Eric S Fraga
Hi,

for those of us using more recent versions of Emacs, the new
tab-bar-mode can be quite useful.  As I have been playing with, I
thought it would make sense to have the option for agenda views to
pop-up in a new tab as an option.  I've coded something that behaves in
a similar way to the 'other-frame option that currently exists for
org-agenda-window-setup.

Patch attached.  Comments welcome, of course.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-719-gcdfc40.dirty
>From e715a495f9659a5cef39e25822e18651ecefcf32 Mon Sep 17 00:00:00 2001
From: Eric S Fraga 
Date: Wed, 26 Aug 2020 17:17:42 +0100
Subject: [PATCH] added other-tab option for org-agenda-window-setup

* org-agenda.el (org-agenda-prepare-window, org-agenda--quit): handle
other-tab option for agenda view creation and exit.
---
 lisp/org-agenda.el | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 8ebc882fc..abb969fe4 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -1100,11 +1100,15 @@ reorganize-frame  Show only two windows on the current frame, the current
   window and the agenda.
 other-frame   Use `switch-to-buffer-other-frame' to display agenda.
   Also, when exiting the agenda, kill that frame.
+other-tab Use `switch-to-buffer-other-tab' to display the agenda.
+  Also, kill that tab when exiting the agenda view.
+
 See also the variable `org-agenda-restore-windows-after-quit'."
   :group 'org-agenda-windows
   :type '(choice
 	  (const current-window)
 	  (const other-frame)
+	  (const other-tab)
 	  (const other-window)
 	  (const only-window)
 	  (const reorganize-frame)))
@@ -1118,11 +1122,11 @@ It only matters if `org-agenda-window-setup' is `reorganize-frame'."
 
 (defcustom org-agenda-restore-windows-after-quit nil
   "Non-nil means restore window configuration upon exiting agenda.
-Before the window configuration is changed for displaying the agenda,
-the current status is recorded.  When the agenda is exited with
-`q' or `x' and this option is set, the old state is restored.  If
-`org-agenda-window-setup' is `other-frame', the value of this
-option will be ignored."
+Before the window configuration is changed for displaying the
+agenda, the current status is recorded.  When the agenda is
+exited with `q' or `x' and this option is set, the old state is
+restored.  If `org-agenda-window-setup' is `other-frame' or
+`other-tab', the value of this option will be ignored."
   :group 'org-agenda-windows
   :type 'boolean)
 
@@ -3769,6 +3773,8 @@ FILTER-ALIST is an alist of filters we need to apply when
   (org-switch-to-buffer-other-window abuf))
  ((eq org-agenda-window-setup 'other-frame)
   (switch-to-buffer-other-frame abuf))
+ ((eq org-agenda-window-setup 'other-tab)
+  (switch-to-buffer-other-tab abuf))
  ((eq org-agenda-window-setup 'only-window)
   (delete-other-windows)
   (pop-to-buffer-same-window abuf))
@@ -7389,6 +7395,8 @@ agenda."
   (cond
((eq org-agenda-window-setup 'other-frame)
 	(delete-frame))
+   ((eq org-agenda-window-setup 'other-tab)
+	(tab-bar-close-tab))
((and org-agenda-restore-windows-after-quit
 	 wconf)
 	;; Maybe restore the pre-agenda window configuration.  Reset
-- 
2.28.0



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-08-26 Thread Eric S Fraga
PS -advice on protecting the new code for versions of Emacs that have
tab-bar-mode would be welcome.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-719-gcdfc40.dirty



org-link-set-parameters :complete how to prompt for description?

2020-08-26 Thread TRS-80

Good day, everyone!

I have been trying to create a new custom link type with
org-link-set-parameters, which in turn calls functions for the various
"methods" (for lack of a better term), like so:

  (org-link-set-parameters "zdlink"
   :complete  #'my-zetteldeft-org-complete-link
   :follow#'my-zetteldeft-org-follow-link
   :help-echo #'my-zetteldeft-org-help-echo
   :store #'my-zetteldeft-org-store-link)

The only one I seem to be having trouble with is :complete.  I can get 
it to
prompt me for completing-read, and it returns the link portion only, but 
how
to get it to also prompt for a description?  Here is my :complete 
function:


  (defun my-zetteldeft-org-complete-link ()
"Link completion for Org zdlink type links"
(let* ((file (completing-read "File to link to: "
  (deft-find-all-files-no-prefix)))
   (link (zetteldeft--lift-id file)))
   (unless link (user-error "No file selected"))
   (concat "zdlink:" link)))

I searched the Internet, this mailing list archives, etc. high and low, 
all

to no avail.  So I decide to join the mailing list today.  Probably long
overdue anyway.  :)

Any tips would be greatly appreciated.

Cheers,
TRS-80



Re: convert a org table to plain text

2020-08-26 Thread Carsten Dominik
You can also export to an ascii buffer with  C-c C-e t A
and get the result from there.  Not sure if this is what you want, how
important is it that the results is in the same buffer right away?

Cheers

Carsten

On Wed, Aug 26, 2020 at 3:17 PM Nick Dokos  wrote:

> Uwe Brauer  writes:
>
> >> Uwe Brauer  writes:
> >
> >> Does this:
> >
> >>
> https://stackoverflow.com/questions/17717483/howto-convert-org-mode-table-to-original-tabbed-format/17726489#17726489
> >
> >
> > Yes, very much so. It would be great to have that code included in
> > orgmode. Did anybody try to contact the author?
> >
>
> You mean orgtbl-to-tsv and related? All of that *is* part of Org mode. All
> you have to do is write a code block calling it
> to convert.
>
> --
> Nick
>
> "There are only two hard problems in computer science: cache
> invalidation, naming things, and off-by-one errors." -Martin Fowler
>
>
>


Re: convert a org table to plain text

2020-08-26 Thread Nick Dokos
Uwe Brauer  writes:

>> Uwe Brauer  writes:
>
>> Does this:
>
>> 
>> https://stackoverflow.com/questions/17717483/howto-convert-org-mode-table-to-original-tabbed-format/17726489#17726489
>
>
> Yes, very much so. It would be great to have that code included in
> orgmode. Did anybody try to contact the author?
>

You mean orgtbl-to-tsv and related? All of that *is* part of Org mode. All you 
have to do is write a code block calling it
to convert.

-- 
Nick

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




Re: convert a org table to plain text

2020-08-26 Thread Uwe Brauer
>>> "PN" == Peter Neilson  writes:

> On Tue, 25 Aug 2020 15:44:30 -0400, Uwe Brauer  wrote:
>> 
>> Hi
>> 
>> What is the inverse function to
>> org-table-convert-region?
>> 
>> I am unable to find anything in the documentation or google.
>> 
>> Regards
>> 
>> We Brauer

> I tried M-x table-release as suggested by the documentation and did
> not get anything.



I tried this also, but this is for table.el not for orgmode table. They
have, unfortunately, a slightly different format.

Would be great to merge these two but I presume this would imply quite a
bit of work.


smime.p7s
Description: S/MIME cryptographic signature


Re: convert a org table to plain text

2020-08-26 Thread Uwe Brauer

> Uwe Brauer  writes:

> Does this:

> 
> https://stackoverflow.com/questions/17717483/howto-convert-org-mode-table-to-original-tabbed-format/17726489#17726489


Yes, very much so. It would be great to have that code included in
orgmode. Did anybody try to contact the author?



smime.p7s
Description: S/MIME cryptographic signature