[PATCH] ox-html: Add webp as an inline image format

2021-03-08 Thread Jay Kamat

Hi,

By default, ox-html inlines most image links (such as png and jpg). However, 
this is currently not the case for webp.


Webp is a image format introduced in 2010 by Google, which now has widespread 
adoption in mainstream browsers. I personally would like to use it because it 
has much better compression levels than the older alternatives. For more 
information on support levels, this site has a synopsis: 
https://caniuse.com/webp


Since it has widespread adoption and support, I would like to propose adding 
it to the default filetypes ox-html inlines as images. A patch is provided 
below to do this. Let me know if you have any thoughts or suggestions.


Thanks for all your hard work,
-Jay

>From e7385370a9a023a68f123374793bc8d706d5580c Mon Sep 17 00:00:00 2001
From: Jay Kamat 
Date: Mon, 8 Mar 2021 16:55:37 -0800
Subject: [PATCH] ox-html: Add webp as an inline image format

* lisp/ox-html.el (org-html-inline-image-rules): Add webp as an inline
  image format

Webp is an image format introduced in 2010, which now has widespread
support in browsers. ox-html can inline webp images identically to how
it does already for other image formats.

Signed-off-by: Jay Kamat 
---
 lisp/ox-html.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 11757bb35..3fa5ef864 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -848,9 +848,9 @@ link to the image."
   :type 'boolean)
 
 (defcustom org-html-inline-image-rules
-  `(("file" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg")))
-("http" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg")))
-("https" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg"
+  `(("file" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg" ".webp")))
+("http" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg" ".webp")))
+("https" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg" ".webp"
   "Rules characterizing image files that can be inlined into HTML.
 A rule consists in an association whose key is the type of link
 to consider, and value is a regexp that will be matched against
-- 
2.20.1



Re: [O] git push to Worg error

2018-04-13 Thread Jay Kamat
I'm not sure if anything changed since you sent this, but I'm able to
push to my forked repo on code.orgmode.org just fine. 

-Jay

stardiviner  writes:

> I got following error when I push to Worg repo.
>
>   0 git … remote set-url --add origin https\://code.orgmode.org/bzg/worg.git
>   0 git … remote set-url --delete origin 
> \^git\@code\\.orgmode\\.org\:bzg/worg\\.git\$
>   1 git … push -v origin master\:refs/heads/master
> Pushing to https://code.orgmode.org/bzg/worg.git
> Counting objects: 18, done.
> Writing objects: 100% (18/18), 5.87 KiB | 1.17 MiB/s, done.
> Total 18 (delta 13), reused 0 (delta 0)
> POST git-receive-pack (6160 bytes)
> Password for 'https://stardivi...@code.orgmode.org': 
> POST git-receive-pack (6160 bytes)
> error: RPC failed; HTTP 403 curl 22 The requested URL returned error: 403 
> Forbidden
> fatal: The remote end hung up unexpectedly
> fatal: The remote end hung up unexpectedly
> Everything up-to-date
>
> I have uploaded my SSH key to code.orgmode.org already.
>
> Magit prompt to ask for password: https://stardivi...@code.orgmode.org
> I inputted the password. But still upper error.


signature.asc
Description: PGP signature


[O] [patch] fix error when using org-notify with no agenda files

2018-04-09 Thread Jay Kamat
Hi,

Previously, when `org-agenda-files' was nil, and `org-notify-start' had
been called (org-notify running), I got the following error every time
`org-notify-process' would run.

Wrong type argument: stringp, nil

This patch fixes this so `org-notify' won't throw errors if no agenda
files are present.

Please let me know if you spot any issues. I thought about adding a
one-time message warning the user, would this be a good idea (or should
we just stay out of their way)? I would be happy to implement it if that
would be preferable.

Thanks,
-Jay

From d0dc9035b2d7c77dc65102ab27ecacf3664599fa Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Mon, 9 Apr 2018 21:47:58 -0400
Subject: [PATCH] org-notify.el: Fix an error in `org-notify-process' when
 unconfigured

* contrib/lisp/org-notify.el (org-notify-todo-list): Return nil if
  `org-agenda-files' is nil
---
 contrib/lisp/org-notify.el | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/contrib/lisp/org-notify.el b/contrib/lisp/org-notify.el
index 8e800eec7..56cf85d9d 100644
--- a/contrib/lisp/org-notify.el
+++ b/contrib/lisp/org-notify.el
@@ -137,15 +137,16 @@ simple timestamp string."
   "Create the todo-list for one org-agenda file."
   (let* ((files (org-agenda-files 'unrestricted))
  (max (1- (length files
-(setq org-notify-parse-file
-  (if (or (not org-notify-parse-file) (>= org-notify-parse-file max))
-  0
-(1+ org-notify-parse-file)))
-(save-excursion
-  (with-current-buffer (find-file-noselect
-(nth org-notify-parse-file files))
-(org-element-map (org-element-parse-buffer 'headline)
- 'headline 'org-notify-make-todo)
+(when files
+  (setq org-notify-parse-file
+	(if (or (not org-notify-parse-file) (>= org-notify-parse-file max))
+		0
+	  (1+ org-notify-parse-file)))
+  (save-excursion
+	(with-current-buffer (find-file-noselect
+			  (nth org-notify-parse-file files))
+	  (org-element-map (org-element-parse-buffer 'headline)
+	  'headline 'org-notify-make-todo))
 
 (defun org-notify-maybe-too-late (diff period heading)
   "Print warning message, when notified significantly later than defined by
-- 
2.14.2



signature.asc
Description: PGP signature


[O] [PATCH] Allow :urgency flags for org-notify

2018-01-13 Thread Jay Kamat
Hi,

I recently began using the org-notify package, and I would like to pass
the :urgency flag to `notifications-notify' occasionally. This small
patch passes the :urgency key from the org-notify configuration on to
`notitifications-notify'.

For example, after this patch, you can:

(org-notify-add 'test-notifications
'(:time "10m" :period "1m" :actions -notify/window :urgency critical))

And get notifications labeled as critical in that way.

Eventually, I would like to write an alert
(https://github.com/jwiegley/alert) backend for org-notify, would that
be suitable for inclusion in the core package?

Thanks,
-Jay

>From dc8d8917720985e7006e75100ccc9f32c0e27b06 Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Sat, 13 Jan 2018 19:03:07 -0500
Subject: [PATCH] Respect :urgency tags for org-notify windows

* contrib/lisp/org-notify.el (org-notify-action-notify): pass :urgency
  to notifications-notify.
---
 contrib/lisp/org-notify.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/lisp/org-notify.el b/contrib/lisp/org-notify.el
index 5f64d3162b..96e7d4ee27 100644
--- a/contrib/lisp/org-notify.el
+++ b/contrib/lisp/org-notify.el
@@ -373,6 +373,7 @@ org-notify window.  Mostly copied from `appt-select-lowest-window'."
   :title (plist-get plist :heading)
   :body  (org-notify-body-text plist)
   :timeout   (if duration (* duration 1000))
+  :urgency   (plist-get plist :urgency)
   :actions   org-notify-actions
   :on-action 'org-notify-on-action-notify)))
 (setq org-notify-on-action-map
-- 
2.11.0



Re: [O] Bug: syntax highlighting in ox-odt and emacs26+ broken [9.1.2 (9.1.2-elpa @ /home/jay/Code/tmp/emacs/lisp/org/)]

2017-10-17 Thread Jay Kamat
I submitted a bug report to emacs core, and Eli says:

> Having read all of the references and discussions you've provided, I
> see no evidence that this is an Emacs issue, as opposed to an Org
> issue.  I think the Org developers should take a look at this first,
> and only if they provide clear evidence that the problem is due to
> Emacs, should the problem come here.

http://lists.gnu.org/archive/html/emacs-orgmode/2017-10/msg00163.html

I tried to take a look at this, but this problem seems more subtle than
I originally thought. The `org-odt-src-block' function seems to be
returning the exact same thing in both scenarios, so the problem
(unfortunately) must be related to the highest level (where the odt is
stitched together). I'll try to keep looking at this, but I would
appreciate if someone else could take a look. I would also be happy to
accept any pointers relating to the ox-odt build process.

-Jay

Jay Kamat <jaygka...@gmail.com> writes:

> Hi Tim,
>
>> My recommendation would be to confirm if the problem exists in the org
>> bundled with Emacs 26 (9.1.1) and if it is, report this on the emacs
>> devel list, making it clear the issue does not exist with emacs
>> 25.3. This will at least allow Emacs devel to note that something which
>> it is changing is either buggy and needs more work or is an incompatible
>> change for org (and possibly other modes) which will need to be
>> added to the changes/News file and addressed by mode authors prior to 26
>> being released.
>
> This bug does indeed exist in the org bundled with emacs. Reporting this
> to emacs-devel sounds like a good plan, and I'll do so in a couple days
> to let anyone on the org mailing list have a chance to correct me if I'm
> doing anything wrong on the org side. But I do agree this looks like a
> bug in emacs core (even though I wansn't able to find the cause).
>
> -Jay



Re: [O] Bug: syntax highlighting in ox-odt and emacs26+ broken [9.1.2 (9.1.2-elpa @ /home/jay/Code/tmp/emacs/lisp/org/)]

2017-10-09 Thread Jay Kamat
Hi Tim,

> My recommendation would be to confirm if the problem exists in the org
> bundled with Emacs 26 (9.1.1) and if it is, report this on the emacs
> devel list, making it clear the issue does not exist with emacs
> 25.3. This will at least allow Emacs devel to note that something which
> it is changing is either buggy and needs more work or is an incompatible
> change for org (and possibly other modes) which will need to be
> added to the changes/News file and addressed by mode authors prior to 26
> being released.

This bug does indeed exist in the org bundled with emacs. Reporting this
to emacs-devel sounds like a good plan, and I'll do so in a couple days
to let anyone on the org mailing list have a chance to correct me if I'm
doing anything wrong on the org side. But I do agree this looks like a
bug in emacs core (even though I wansn't able to find the cause).

-Jay





[O] Bug: syntax highlighting in ox-odt and emacs26+ broken [9.1.2 (9.1.2-elpa @ /home/jay/Code/tmp/emacs/lisp/org/)]

2017-10-09 Thread Jay Kamat
Hi Everyone,

I think 'francisv' from the #org-mode irc channel found a interesting
bug in emacs or org mode. I don't know enough about emacs to figure out
exactly what's going on, so I'll provide as much information as I'm able
to find out.

orgmode syntax highlighting when exporting to ox-odt in emacs 26 seems
to be broken. This is not reproducible under emacs 25 at all. In
addition, this seems to be dependent on which emacs is compiling org
bytecode.

Steps to Reproduce:
1. Compile Emacs *26* from source
2. Load an org file with the following (built-in org):

#+BEGIN_SRC c
int main() {
return 0;
}
#+END_SRC

3. Export to odt via C-c C-e o o 
4. Open file in libreoffice

Expected Results

Syntax highlighting for the code block as in emacs25

Actual Results

Code seems to be colored in a single color, interestingly, this is *not*
black.

(I can provide screenshots if that would be helpful)

After poking around, I found a bit more information on how to reproduce
it:

Environments with working syntax export:
1. Emacs25, always (unless unrelated errors are present)
2. Emacs26, when running org compiled with emacs 25 (from elpa/repo)
3. Emacs26, when running org 'interpreted' (not compiled to bytecode)

Environments with broken syntax export:
1. Emacs26 when compiled from source, using builtin org
2. Emacs26 when org is compiled with Emacs 26 (from elpa/repo)

I tested all emacs versions on org 0b83168465, changing which version
org was compiled with by modifying the EMACS variable in local.mk in
org. I also ran everything in ~emacs -Q~.

I attempted to bisect emacs to find which change in emacs is causing
this, bug I wasn't able to compile some older versions of emacs. I was
able to find that it was '14 revisions away from 5f3379b338' but I don't
know if that's helpful.

A stackexchange question about this is here:
https://emacs.stackexchange.com/questions/36023/how-to-export-babel-source-blocks-with-syntax-highlighting-to-odt-in-org-mode-in

This is probably not a bug in org mode (but rather in emacs 26) but I
wanted to post it here first to see if anyone had any idea what could be
causing this. If this dosen't seem like an org bug, I'm happy to
redirect it to emacs bug reports.

Please let me know if anyone has any questions, and apologies if
anything is wrong about this report.

Emacs  : GNU Emacs 26.0.60 (build 5, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-10-07
Package: Org mode version 9.1.2 (9.1.2-elpa @ 
/home/jay/Code/tmp/emacs/lisp/org/)

Thanks,
-Jay



Re: [O] [PATCH] Export of irc links in ox-html

2017-09-24 Thread Jay Kamat
Hi Nicolas,

> Would you mind providing an ORG-NEWS entry about it?

I need to stop forgetting to do this :).

I've attached a patch which adds an entry to the 'Miscellaneous'
section. Please let me know if you think anything is wrong with it.

-Jay

>From e321f926217460a506d6536ad494b1f25c247c4b Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Sun, 24 Sep 2017 21:30:39 -0400
Subject: [PATCH] ORG-NEWS: Add an entry for supporting export in org-irc.el

---
 etc/ORG-NEWS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index d2fb264b18..7c69efa89d 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -108,6 +108,12 @@ you should expect to see something like:
 ** Miscellaneous
 
 *** ~org-publish-resolve-external-link~ accepts a new optional argument.
+*** ~org-irc.el~ now supports exporting =irc:= links properly
+
+Previously, irc links were exported by ~ox-md~ and ~ox-html~ as normal
+file links, which lead to them being broken in web browsers. Now both
+of these exporters will properly export to =irc:= links, which will
+open properly in irc clients from web browsers.
 
 * Version 9.1
 
-- 
2.11.0



Re: [O] [PATCH] Export of irc links in ox-html

2017-09-24 Thread Jay Kamat
Hi Nicolas,

> The proper fix would be to patch "org-irc.el" and add an export function
> there. "irc" links are not default links in Org, so there is no reason
> to hard-code them in "ox-html.el".

Thanks for pointing that out! I didn't even realize up until now org had
support for custom link types.

I've attached a second patch which adds a new function to org-irc.el,
which seems to handle export of irc links in ox-md and ox-html
properly. I'm very new to this system, so please make sure it's correct,
and I'll be happy to follow up with corrections if it isn't!

Because I added support for md links in org-irc.el, I also removed the
workaround I added a while back for that in ox-md.el.

-Jay

>From e6c824f363bf6959f0eb35e4b8208a14d2cbffcb Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Sun, 24 Sep 2017 12:11:52 -0400
Subject: [PATCH] org-irc.el: Add proper export functions for irc

* lisp/org-irc.el (org-irc-export): Add a new function,
  org-irc-export, which properly exports irc links to html and markdown

* lisp/ox-md.el (org-md-link): Remove workaround to get irc links
  working properly in ox-md, and use org-irc's export functions instead
---
 lisp/org-irc.el | 20 +++-
 lisp/ox-md.el   |  2 +-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/lisp/org-irc.el b/lisp/org-irc.el
index 5889f6d2fe..eee71aef52 100644
--- a/lisp/org-irc.el
+++ b/lisp/org-irc.el
@@ -71,7 +71,10 @@
 
 ;; Generic functions/config (extend these for other clients)
 
-(org-link-set-parameters "irc" :follow #'org-irc-visit :store #'org-irc-store-link)
+(org-link-set-parameters "irc"
+			 :follow #'org-irc-visit
+			 :store #'org-irc-store-link
+			 :export #'org-irc-export)
 
 (defun org-irc-visit (link)
   "Parse LINK and dispatch to the correct function based on the client found."
@@ -245,6 +248,21 @@ default."
   ;; no server match, make new connection
   (erc-select :server server :port port
 
+(defun org-irc-export (link description format)
+  "Export an info link.
+See `org-link-parameters' for details about LINK, DESCRIPTION and FORMAT."
+  (let* ((desc (or description link)))
+(pcase format
+  (`html
+   (format "%s"
+	   link
+	   desc))
+  (`md
+   (format "[%s](irc:%s)"
+	   desc
+	   link))
+  (_ nil
+
 (provide 'org-irc)
 
 ;; Local variables:
diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index 5ba52e7faf..146956eedf 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -449,7 +449,7 @@ a communication channel."
  (t (let* ((raw-path (org-element-property :path link))
 	   (path
 		(cond
-		 ((member type '("http" "https" "ftp" "mailto" "irc"))
+		 ((member type '("http" "https" "ftp" "mailto"))
 		  (concat type ":" raw-path))
 		 ((string= type "file")
 		  (org-export-file-uri (funcall link-org-files-as-md raw-path)))
-- 
2.11.0



[O] [PATCH] Export of irc links in ox-html

2017-09-23 Thread Jay Kamat
Hi!

IRC links in ox-html are currently broken. There exists a special 'irc'
content handler on the web, telling browsers to open an irc link in an
external irc client. The format for such links seems identical to org
(irc:irc.freenode.net/user).

Previously links such as:

[[irc:irc.freenode.net/test][Irc link]]

Would export to 

Irc link

in ox-html.

After this tiny patch, it exports to:

Irc link

which tells browsers such as firefox to open links in irc clients.

Let me know if you find any issues!

-Jay

>From fa1a5ad3bf63158775ffa8ab3de37fb056103ab4 Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Sun, 24 Sep 2017 01:11:42 -0400
Subject: [PATCH] ox-html.el: Fix irc links exporting to link to local files

* lisp/ox-html.el: Add "irc" to special link types which are exported
  as their link type and path separated by ':', so that browser irc
  content handlers work properly.
---
 lisp/ox-html.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index d91ca73622..8756cda7e5 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2973,7 +2973,7 @@ INFO is a plist holding contextual information.  See
 	 (desc (org-string-nw-p desc))
 	 (path
 	  (cond
-	   ((member type '("http" "https" "ftp" "mailto" "news"))
+	   ((member type '("http" "https" "ftp" "mailto" "news" "irc"))
 	(url-encode-url (org-link-unescape (concat type ":" raw-path
 	   ((string= type "file")
 	;; Treat links to ".org" files as ".html", if needed.
-- 
2.11.0



Re: [O] [PATCH] Update statistic cookies when archiving

2017-09-03 Thread Jay Kamat
Hi,

> Be warned that we're in a feature-freeze phase. It will have to wait for
> Org 9.1 before being merged.

Sounds good to me!

>
>> +;; Go to parent, even if no children exist
>
> Nitpick: Missing final dot.
>
>> +(org-up-heading-safe)
>> +;; Update cookie of parent
>
> Ditto.
>> +(org-update-statistics-cookies nil)))
>>  (message "Subtree archived %s"
>>   (if (eq this-buffer buffer)
>>   (concat "under heading: " heading)
>> @@ -470,6 +476,9 @@ Archiving time is retained in the ARCHIVE_TIME node 
>> property."
>>  (outline-hide-subtree)
>>  (org-cycle-show-empty-lines 'folded)
>>  (goto-char pos)))
>> +(when org-provide-todo-statistics
>> +  ;; update todo statistics of parent
>
> Ditto. Missing capital, too.
>
>> +  (org-update-parent-todo-statistics))
>>  (org-reveal)
>>  (if (looking-at "^[ \t]*$")
>>  (outline-next-visible-heading 1

Fixed.

> Could you provide some tests and an ORG-NEWS entry? For the latter, you
> can start a new "Version 9.2" top heading.

Done.

I'm not sure if I did the tests 'correctly' though. I placed them in
test-org-element.el since there was a little bit of archive based
testing there, is there a better place to put them? I couldn't find any
file for org-archive testing. Maybe I'll write some more archive tests
later...

+(should (string=
+ (org-element-property :title (org-element-at-point))
+ "Top [0%]")))
Is there a better way to extract the status cookie percentage from the
header? I couldn't find anything in (org-element-property)'s output.

Thanks,
-Jay

>From 612d4daac54e12556333fcd2e07771aa8344c86c Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Sat, 2 Sep 2017 15:57:36 -0400
Subject: [PATCH] org-archive.el: Update statistic cookies when archiving

* lisp/org-archive.el (org-archive-subtree): Update todo statistics
  when calling `org-archive-subtree'.
(org-archive-to-archive-sibling): Update cookie statistics when
calling `org-archive-to-archive-sibling'.

This can be disabled by setting `org-provide-todo-statistics' to nil.
---
 etc/ORG-NEWS | 22 ++
 lisp/org-archive.el  |  9 +
 testing/lisp/test-org-element.el | 33 +
 3 files changed, 64 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 9f3e62406..316a75f2f 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -8,6 +8,28 @@ See the end of the file for license conditions.
 
 Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
 
+* Version 9.2
+
+** Incompatible changes
+** New features
+*** ~org-archive~ functions update status cookies
+
+Archiving headers through ~org-archive-subtree~ and
+~org-archive-to-archive-sibling~ such as the ones listed below:
+
+#+BEGIN_SRC org
+  ,* Top [1/2]
+  ,** DONE Completed
+  ,** TODO Working
+#+END_SRC
+
+Will update the status cookie in the top level header.
+
+** Removed functions
+** Removed options
+** New functions
+** Miscellaneous
+
 * Version 9.1
 
 ** Incompatible changes
diff --git a/lisp/org-archive.el b/lisp/org-archive.el
index adb922e75..9ba73a8de 100644
--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -393,6 +393,12 @@ direct children of this heading."
 	(when (featurep 'org-inlinetask)
 	  (org-inlinetask-remove-END-maybe))
 	(setq org-markers-to-move nil)
+	(when org-provide-todo-statistics
+	  (save-excursion
+	;; Go to parent, even if no children exist.
+	(org-up-heading-safe)
+	;; Update cookie of parent.
+	(org-update-statistics-cookies nil)))
 	(message "Subtree archived %s"
 		 (if (eq this-buffer buffer)
 		 (concat "under heading: " heading)
@@ -470,6 +476,9 @@ Archiving time is retained in the ARCHIVE_TIME node property."
 	(outline-hide-subtree)
 	(org-cycle-show-empty-lines 'folded)
 	(goto-char pos)))
+(when org-provide-todo-statistics
+  ;; Update todo statistics of parent.
+  (org-update-parent-todo-statistics))
 (org-reveal)
 (if (looking-at "^[ \t]*$")
 	(outline-next-visible-heading 1
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 7d1c55f36..e9506d2b0 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -1070,6 +1070,39 @@ Some other text
  (let ((org-archive-tag "Archive"))
(org-element-property :archivedp (org-element-at-point))
 
+(ert-deftest test-org-element/archive-update-status-cookie ()
+  "Test archiving properly updating status cookies."
+  ;; Test org-archive-subtree with two children.
+  (org-test-with-temp-text-in-file "* Top [%]\n** DONE One\n** TODO Two"

Re: [O] [PATCH] Update statistic cookies when archiving

2017-09-02 Thread Jay Kamat

Sorry, forgot to actually attach the patch, here it is.

>From 95cdfa8c3ec81b3a0763b68044611c10a4dadc29 Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Sat, 2 Sep 2017 15:57:36 -0400
Subject: [PATCH] org-archive.el: Update statistic cookies when archiving

* lisp/org-archive.el (org-archive-subtree): Update todo statistics
  when calling `org-archive-subtree'.
(org-archive-to-archive-sibling): Update cookie statistics when
calling `org-archive-to-archive-sibling'.

This can be disabled by setting `org-provide-todo-statistics' to nil.
---
 lisp/org-archive.el | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lisp/org-archive.el b/lisp/org-archive.el
index adb922e75..9c24d356c 100644
--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -393,6 +393,12 @@ direct children of this heading."
 	(when (featurep 'org-inlinetask)
 	  (org-inlinetask-remove-END-maybe))
 	(setq org-markers-to-move nil)
+	(when org-provide-todo-statistics
+	  (save-excursion
+	;; Go to parent, even if no children exist
+	(org-up-heading-safe)
+	;; Update cookie of parent
+	(org-update-statistics-cookies nil)))
 	(message "Subtree archived %s"
 		 (if (eq this-buffer buffer)
 		 (concat "under heading: " heading)
@@ -470,6 +476,9 @@ Archiving time is retained in the ARCHIVE_TIME node property."
 	(outline-hide-subtree)
 	(org-cycle-show-empty-lines 'folded)
 	(goto-char pos)))
+(when org-provide-todo-statistics
+  ;; update todo statistics of parent
+  (org-update-parent-todo-statistics))
 (org-reveal)
 (if (looking-at "^[ \t]*$")
 	(outline-next-visible-heading 1
-- 
2.11.0



Jay Kamat <jaygka...@gmail.com> writes:

> Hi,
>
> Currently, statistic cookies do not update when archiving headings. For
> example, when archiving the 'Two' header in the below example:
>
> * Top [50%]
> ** TODO One
> ** DONE Two
>
> The status cookie on 'Top' does not get set to [100%].
>
> I have attached a draft patch to add support for this. However, I think
> it needs a little bit more work.
>
> There are 3 archive methods, org-archive-subtree,
> org-archive-to-archive-sibling, and org-archive-set-tag.
>
> For org-archive-set-tag, setting the :ARCHIVE: tag does not seem to
> affect the status cookie, so I did not touch that.
>
> For org-archive-to-archive-sibling, I used the
> (org-update-parent-todo-statistics) function, which seems to work as
> expected.
>
> For org-archive-subtree, the solution I came up with is a little more
> complicated, to handle the edge case of archiving the last child
> header. In this case, 'parent' refers to the wrong (or non-existent)
> header, so I use a small function to call (org-up-heading-safe) on one
> header above point, which seems to work even for this edge case. I'm not
> entirely sure if it's the proper solution though.
>
> Let me know if you have any feedback!
>
> -Jay


[O] [PATCH] Update statistic cookies when archiving

2017-09-02 Thread Jay Kamat
Hi,

Currently, statistic cookies do not update when archiving headings. For
example, when archiving the 'Two' header in the below example:

* Top [50%]
** TODO One
** DONE Two

The status cookie on 'Top' does not get set to [100%].

I have attached a draft patch to add support for this. However, I think
it needs a little bit more work.

There are 3 archive methods, org-archive-subtree,
org-archive-to-archive-sibling, and org-archive-set-tag.

For org-archive-set-tag, setting the :ARCHIVE: tag does not seem to
affect the status cookie, so I did not touch that.

For org-archive-to-archive-sibling, I used the
(org-update-parent-todo-statistics) function, which seems to work as
expected.

For org-archive-subtree, the solution I came up with is a little more
complicated, to handle the edge case of archiving the last child
header. In this case, 'parent' refers to the wrong (or non-existent)
header, so I use a small function to call (org-up-heading-safe) on one
header above point, which seems to work even for this edge case. I'm not
entirely sure if it's the proper solution though.

Let me know if you have any feedback!

-Jay




Re: [O] [PATCH] Add TITLE export to ox-md

2017-08-27 Thread Jay Kamat
Hi, 

> The point of "md" export back-end is not to provide the same features as
> full-fledged ones like "latex" or "html". I wrote it to take care of the
> boring stuff of markdown syntax. Anyone willing to write a back-end with
> a different Markdown flavour just needs to concentrate of the
> differences between the original syntax.

Ah, this makes a lot more sense now. I think that this patch is better suited
towards more specific md backends (like ox-hugo or ox-gfm), so they can
implement title in the way that supports their import the best. Adding this
probably would get in the way of better title exports for the respective org
exporter derivations.

> AFAIC, I think ... or even ...
> ..., as you suggested, are better choices.

I do agree (from creating a vanilla markdown exporter standpoint), but I dislike
it purely because the github markdown renderer doesn't display inline html that
well (even though that's per standard). It ranges from being displayed as a H1
header to being displayed as normal (non-heading) text, depending on the way
it's done.

In summary, I think I'll try to get this into ox-gfm (and other org md exporters
I can find) instead of ox-md. I think ox-hugo supports titles already though.
Thanks again for taking a look at this!

-Jay



Re: [O] [PATCH] Add TITLE export to ox-md

2017-08-24 Thread Jay Kamat

>  I'm not so sure about it. Vanilla Markdown does not support title.
>  Neither does "ox-md.el"

I agree that vanilla markdown does not support title, but if ox-md does not
support any form of title, then there is disparity between the output of other
org exports and the markdown exporter. I would like to solve that disparity if
possible.

> Correct, vanilla Markdown does not support title. The file name is the title.

I'm not entirely sure about that (file name being the title). Unfortunately
markdown is very fragmented, so it's hard to tell what the 'standard' is. From
the markdown that I've worked with, this isn't the case. The original markdown
tool (https://daringfireball.net/projects/markdown/) dosen't seem to output
filename titles in it's export, so I wouldn't think it's part of the vanilla
standard.

>  But then you would need to shift all headlines 1 or 2 levels down.
>  `setext' style becomes unusable because there is no room left for other
>  headlines.

Is there a reason we need to move all the other header under the title header? I
was thinking of leaving the rest of the headlines as they are. So:

#+TITLE: My Title

* One
** Two

Would export to

# My Title

# One

## Two

It's a little bit ugly to have two h1 headings right next to each other, though.

Another option is to take advantage of html features of markdown to format the
title in a way that does not alter the headings (similar to how the TOC is
exported now). For example, we could add


  My Title


to the start of the markdown, but that seems to break the github markdown
renderer. Does anyone who knows more html have any ideas here (besides adding h1
headings in html)?


I don't like the idea of shifting headlines down a level to accommodate the
title since people would then be unable to create new H1 headings in markdown
files with a title.

> Maybe we eventually end up with 3 options (something like below):
>
> - org-md-title-as-h1
> - org-md-subtitle-as-h2
> - org-md-heading-offset

that's probably the best idea I've heard so far, since I would imagine most
people would either not want to have two H1 headings right after each other, or
not want to have their headings shifted. Having such options would allow people
to pick the scenario they want (shifting headings under the title, including the
title but no offset, or not including the title at all).

Does creating these options (defaulting to nil) sound like a good plan to move
forward on? Other ideas and feedback would be appreciated, (since this is a
tricky situation, standards wise).

-Jay

PS: ox-hugo looks very nice, and I look forward to trying it out! :)



[O] [PATCH] Add TITLE export to ox-md

2017-08-23 Thread Jay Kamat
Hi!

Currently, the markdown org exporter does not export titles. For example, the
following org file:

#+TITLE: My Title
#+SUBTITLE: My Subtitle
#+OPTIONS: toc:nil

exports to an empty file. This patch adds title support to ox-md. Currently it
exports them as markdown headers. For example, the above org file will export
to:

# My Title


## My Subtitle

Of course, the title can be suppressed by adding #+OPTIONS: title:nil.

The style used for the title export can be configured using the already existing
org-md-headline-style variable.

The markdown editor should support TITLE, but I'm not sure if this is the
'correct' way to support it. It seems like the simplest way for now. If people
want it, I could add a new option to add different title export formats.

There is an existing bug report and discussion at this issue tracker:
https://github.com/larstvei/ox-gfm/issues/21.

>From that issue, YAML front-matter is an option for title export, but I would
like to stay away from that (at least by default) since that dosen't seem to be
a feature in default markdown.

Feedback, suggestions, and feature requests are very much appreciated!

-Jay

PS: Apologies if any part of this email is broken, I'm attempting to switch to 
gnus.

>From fe45823c8b6da4ecae3347de4859127add03e253 Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Sun, 20 Aug 2017 19:01:29 -0400
Subject: [PATCH] ox-md.el: Add TITLE export to markdown export

* lisp/ox-md.el (org-md-template): Add title export to md template.
  Title will be exported as level 1 and 2 headers, as determined by
  org-md-headline-style

See https://github.com/larstvei/ox-gfm/issues/21 for an external bug report
---
 lisp/ox-md.el | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index ac94ba648..a552063e8 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -649,14 +649,26 @@ holding export options."
;; Footnotes section.
(org-md--footnote-section info)))
 
-(defun org-md-template (contents _info)
+(defun org-md-template (contents info)
   "Return complete document string after Markdown conversion.
 CONTENTS is the transcoded contents string.  INFO is a plist used
 as a communication channel."
-  contents)
+  (concat
+;; Generate title and subtitle, if possible
+(let ((title (and (plist-get info :with-title)
+		   (plist-get info :title)))
+	   (subtitle (plist-get info :subtitle))
+	   (style (plist-get info :md-headline-style)))
+  (when title
+	(concat
+	  (org-md--headline-title style
+	1 (org-export-data title info))
+	  (when subtitle
+	(org-md--headline-title style
+	  2 (org-export-data subtitle info))
+contents))
 
 
-
 ;;; Interactive function
 
 ;;;###autoload
-- 
2.11.0



Re: [O] Bug: export to markdown invalid URL

2017-08-22 Thread Jay Kamat
Hi,

> Isn't it already the case?

Sorry, I sent that email without reading the 'applied' email, so it
was premature. The fix looks good currently.

> I think the current patch is fine. Yours is equivalent, but since we
> already bound `raw-path', we might as well use it.

yup, that is true, I'm happy with the current patch for now, since we
don't have to bind additional variables it ends up being simpler.

Thanks,
-Jay



Re: [O] Bug: export to markdown invalid URL

2017-08-22 Thread Jay Kamat
Hi again,

sorry for the repeated emails, but I think I've come up with a better
solution to this issue, to just use the raw link target in the target
of the markdown export, which I've attached to this email. Feel free
to pick either one of these patches or come up with something better.

Hope this gets fixed soon,
-Jay


On Tue, Aug 22, 2017 at 5:33 PM, Jay Kamat <jaygka...@gmail.com> wrote:
> Hi,
>
> Thanks for catching that. That was my fault, for failing to test
> commit f3d7284ebd0c6e8248f7c3c444937270402b0ba6 properly.
>
> See http://lists.gnu.org/archive/html/emacs-orgmode/2017-08/msg00147.html
> for the previous thread.
>
> I've attached a trivial patch which appears to fix the issue for me,
> but I don't know if there's a cleaner way to do it or not (is there a
> link property that keeps the ':' in either the link or the type?).
>
> Thanks,
> -Jay
>
> On Tue, Aug 22, 2017 at 5:16 PM, Fabio Leimgruber
> <fabio.leimgru...@posteo.eu> wrote:
>> Hello everyone,
>>
>> using latest master, an org file containing just the link
>>
>> #+BEGIN_SRC org
>> [[http://orgmode.org/img/org-mode-unicorn-logo.png]]
>> #+END_SRC
>>
>> on export to markdown with =C-c C-e m m= produces the md file
>>
>> #+BEGIN_EXAMPLE
>> # Table of Contents
>>
>>
>>
>> ![img](http//orgmode.org/img/org-mode-unicorn-logo.png)
>> #+END_EXAMPLE
>>
>> containing an invalid URL.
>>
>> Best Regards,
>>
>> --
>> Fabio Leimgruber
>>
From 743daf53843a29b1202553345b4fc298ac87c74e Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Tue, 22 Aug 2017 17:28:28 -0400
Subject: [PATCH] ox-md.el: Fix missing ':' in exported markdown image links

* lisp/ox-md.el (org-md-link): Use raw-link for markdown link target
  instead of merging type and raw-path
---
 lisp/ox-md.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index 0dd1be095..9afb5227e 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -431,8 +431,9 @@ a communication channel."
 		   description
 		   (org-export-get-reference destination info
  ((org-export-inline-image-p link org-html-inline-image-rules)
-  (let ((path (let ((raw-path (org-element-property :path link)))
-		(cond ((not (equal "file" type)) (concat type raw-path))
+   (let ((path (let ((raw-path (org-element-property :path link))
+			  (raw-link (org-element-property :raw-link link)))
+		(cond ((not (equal "file" type)) raw-link)
 			  ((not (file-name-absolute-p raw-path)) raw-path)
 			  (t (expand-file-name raw-path)
 	(caption (org-export-data
-- 
2.11.0



Re: [O] Bug: export to markdown invalid URL

2017-08-22 Thread Jay Kamat
Hi,

Thanks for catching that. That was my fault, for failing to test
commit f3d7284ebd0c6e8248f7c3c444937270402b0ba6 properly.

See http://lists.gnu.org/archive/html/emacs-orgmode/2017-08/msg00147.html
for the previous thread.

I've attached a trivial patch which appears to fix the issue for me,
but I don't know if there's a cleaner way to do it or not (is there a
link property that keeps the ':' in either the link or the type?).

Thanks,
-Jay

On Tue, Aug 22, 2017 at 5:16 PM, Fabio Leimgruber
<fabio.leimgru...@posteo.eu> wrote:
> Hello everyone,
>
> using latest master, an org file containing just the link
>
> #+BEGIN_SRC org
> [[http://orgmode.org/img/org-mode-unicorn-logo.png]]
> #+END_SRC
>
> on export to markdown with =C-c C-e m m= produces the md file
>
> #+BEGIN_EXAMPLE
> # Table of Contents
>
>
>
> ![img](http//orgmode.org/img/org-mode-unicorn-logo.png)
> #+END_EXAMPLE
>
> containing an invalid URL.
>
> Best Regards,
>
> --
> Fabio Leimgruber
>
From 5d92257575e497e0955b3414fb1e1a69e5ea97f8 Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Tue, 22 Aug 2017 17:28:28 -0400
Subject: [PATCH] ox-md.el: Fix missing ':' in exported markdown image links

* lisp/ox-md.el (org-md-link): Append ':' to the type of non-file
  image links.
---
 lisp/ox-md.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index 0dd1be095..ac94ba648 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -432,7 +432,7 @@ a communication channel."
 		   (org-export-get-reference destination info
  ((org-export-inline-image-p link org-html-inline-image-rules)
   (let ((path (let ((raw-path (org-element-property :path link)))
-		(cond ((not (equal "file" type)) (concat type raw-path))
+		(cond ((not (equal "file" type)) (concat type ":" raw-path))
 			  ((not (file-name-absolute-p raw-path)) raw-path)
 			  (t (expand-file-name raw-path)
 	(caption (org-export-data
-- 
2.11.0



Re: [O] [PATCH] Fix ox-md remote image links export

2017-08-06 Thread Jay Kamat
Hi,

> Thank you for the report and the patch. I have committed a slightly
> different change. Does it solve your issue?

Yup, this commit solves my issues, thanks! It's also a lot cleaner
than my patch :).

Thanks again,
-Jay

On Sun, Aug 6, 2017 at 12:15 AM, Nicolas Goaziou <m...@nicolasgoaziou.fr> wrote:
> Hello,
>
> Jay Kamat <jaygka...@gmail.com> writes:
>
>> I discovered a bug in the ox-md exporter and have created a patch to fix it:
>>
>> Previously, this image link:
>> [[https://git-scm.com/images/l...@2x.png]]
>>
>> would export to:
>> ![img](//git-scm.com/images/l...@2x.png)
>>
>> which is an invalid markdown image, and won't display properly in
>> browsers and other places.
>>
>> A workaround (which I have been using extremely heavily), is:
>> [[file:https://git-scm.com/images/l...@2x.png]]
>>
>> which exports to
>> ![img](https://git-scm.com/images/l...@2x.png)
>>
>> Which is the proper (unbroken) image link.
>>
>> I have attached a patch which fixes the first example, so it exports
>> the same link as the workaround (and is no longer broken).
>
> Thank you for the report and the patch. I have committed a slightly
> different change. Does it solve your issue?
>
>> My papers are currently being processed, but I thought I would post
>> this patch early to get feedback, since ideally I would like this bug
>> to be fixed as soon as possible :). Hopefully they'll be done before
>> the review is completed.
>
> Great! Let me know when the process is done.
>
> Regards,
>
> --
> Nicolas Goaziou



[O] [PATCH] Fix ox-md remote image links export

2017-08-05 Thread Jay Kamat
Hi!

I discovered a bug in the ox-md exporter and have created a patch to fix it:

Previously, this image link:
[[https://git-scm.com/images/l...@2x.png]]

would export to:
![img](//git-scm.com/images/l...@2x.png)

which is an invalid markdown image, and won't display properly in
browsers and other places.

A workaround (which I have been using extremely heavily), is:
[[file:https://git-scm.com/images/l...@2x.png]]

which exports to
![img](https://git-scm.com/images/l...@2x.png)

Which is the proper (unbroken) image link.

I have attached a patch which fixes the first example, so it exports
the same link as the workaround (and is no longer broken).

One of my concerns with the attached patch is whether there's a better
way to determine if a link is 'remote'. Maybe I should make a constant
in the file listing 'remote' types and use that everywhere.
I'm also not sure if I broke any other type of image link (but the
simple local case seems to work fine).

My papers are currently being processed, but I thought I would post
this patch early to get feedback, since ideally I would like this bug
to be fixed as soon as possible :). Hopefully they'll be done before
the review is completed.

Let me know if you see anything wrong, and thanks again for hacking org mode :D.

-Jay
From b4768baf2c6ea234c92f24540ed927cf8473e999 Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Sat, 5 Aug 2017 19:14:44 -0700
Subject: [PATCH] ox-md.el: Fix exporting of remote image links

* lisp/ox-md.el (org-md-link): Check if a link is a remote, and if so,
  use the raw-link property of the link, rather than the path.

A workaround for this bug is to do this:
[[file:http://orgmode.org/img/org-mode-unicorn-logo.png]]

This commit lets the workaround continue working, while the proper method:
[[http://orgmode.org/img/org-mode-unicorn-logo.png]]
is fixed.
---
 lisp/ox-md.el | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index 08e3852823..a4e1d6749b 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -430,8 +430,14 @@ a communication channel."
 	   (format "[%s](#%s)"
 		   description
 		   (org-export-get-reference destination info
+ ;; Generate a md image link
  ((org-export-inline-image-p link org-html-inline-image-rules)
-  (let ((path (let ((raw-path (org-element-property :path link)))
+   ;; Get the path and caption to insert into the image
+   (let ((path (let ((raw-path
+			   ;; types of links which we just use the raw link
+			   (if (member type '("http" "https" "ftp"))
+			 (org-element-property :raw-link link)
+			 (org-element-property :path link
 		(if (not (file-name-absolute-p raw-path)) raw-path
 		  (expand-file-name raw-path
 	(caption (org-export-data
-- 
2.11.0



Re: [O] [PATCH] Support for 'using namespace *' in ob-C.el

2017-08-01 Thread Jay Kamat
Hi Nicolas,

Sorry for bumping this, but could you apply the patch I made to update
worg for documentation as well (or provide feedback)? I'd like that to
stay updated as well if possible.

If there's another mailing list for worg let me know and I'll post it there.

The patch is re-attached for convenience.

-Jay

On Tue, Aug 1, 2017 at 9:48 AM, Nicolas Goaziou <m...@nicolasgoaziou.fr> wrote:
> Hello,
>
> Jay Kamat <jaygka...@gmail.com> writes:
>
>> From 65c8add92842c2e547b13d5c6fb2485e7fdbf2db Mon Sep 17 00:00:00 2001
>> From: Jay Kamat <jaygka...@gmail.com>
>> Date: Mon, 31 Jul 2017 22:47:33 -0700
>> Subject: [PATCH] ORG-NEWS: Fix a small typo in new org babel header example
>>
>> * etc/ORG-NEWS (Using): Fix typo in babel :header-args: conversion
>>
>> TINYCHANGE
>
> Applied. Thank you.
>
> Regards,
> --
> Nicolas Goaziou


0001-Add-documentation-for-ob-C-namespaces.patch
Description: Binary data


Re: [O] [PATCH] Support for 'using namespace *' in ob-C.el

2017-07-31 Thread Jay Kamat
Hi Chuck,

Thanks for pointing that out, this all makes a lot more sense now.
Prior to this patch ':includes' and ':defines' seem to work in the
property list (as described in the old version of the org manual), so
(I think) the updated version of this patch also removes those usages
(for :defines, :includes), so you must use the new format described in
the manual.

Speaking of the manual, that entry managed to get me very confused at
first, as it didn't seem to work for me, but then I realized that
there is actually a typo in the NEWS entry, the second line should be:

:header-args+: :var a=1 b=2

I'm not sure what the policy is on changing old NEWS entries, but I've
attached a small patch to fix the typo.

Let me know if  you have any other feedback! :)

-Jay


On Mon, Jul 31, 2017 at 8:34 AM, Charles C. Berry <ccbe...@ucsd.edu> wrote:
> On Mon, 31 Jul 2017, Jay Kamat wrote:
>
>> Hello!
>>
>> Sorry for the late reply, I was pretty busy last week. An updated
>> patch is attached!
>>
>
> [snip]
>
>>
>>> Using `org-entry-get' is no longer supported. You can replace the `or'
>>> with
>>>
>>>   (cdr (assq :namespaces params))
>>
>>
>> Done, I also replaced the other uses of 'org-entry-get' around the one
>> I modified
>>
>
> I don't think Nicolas meant that `org-entry-get' is no longer supported
> literally. I think he was referring to using it to enable using Babel header
> arguments as property names (as it did in your code). See:
>
> http://orgmode.org/Changes.html#org343de47
>
>
> HTH,
>
> Chuck
From 65c8add92842c2e547b13d5c6fb2485e7fdbf2db Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Mon, 31 Jul 2017 22:47:33 -0700
Subject: [PATCH] ORG-NEWS: Fix a small typo in new org babel header example

* etc/ORG-NEWS (Using): Fix typo in babel :header-args: conversion

TINYCHANGE
---
 etc/ORG-NEWS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index d7bd3e2ce7..5acaf7ee52 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -582,7 +582,7 @@ should be written instead
 ,* Headline
 :PROPERTIES:
 :header-args: :exports code
-:header-args: :var a=1 b=2
+:header-args+: :var a=1 b=2
 :header-args+: :var c=3
 :END:
 #+END_EXAMPLE
-- 
2.11.0



Re: [O] [PATCH] Support for 'using namespace *' in ob-C.el

2017-07-31 Thread Jay Kamat
Hello!

Sorry for the late reply, I was pretty busy last week. An updated
patch is attached!

> I suggest to add the following to "ob-C.el" so that `org-lint' can issue
> a warning whenever :namespaces is used in a C block.

Done. I needed to tweak the code a bit though to get it to work and to
prevent flagging valid C headers as errors with org lint.

> Using `org-entry-get' is no longer supported. You can replace the `or'
> with
>
>   (cdr (assq :namespaces params))

Done, I also replaced the other uses of 'org-entry-get' around the one
I modified

> Nitpick: I would put the "\n" on another line.

I agree, and done :)

> Could you also provide an ORG-NEWS entry for the feature?

Done. I'm not sure if it went in the right place and if it's formatted
correctly though, so can you give that a look over to make sure it
looks good?

Thanks again for taking the time to review this for me :D

Let me know if you spot anything fishy or wrong.

Also, RE: Copyright, this is the form I need to send, correct?
http://orgmode.org/request-assign-future.txt

-Jay


On Sun, Jul 23, 2017 at 7:44 AM, Nicolas Goaziou <m...@nicolasgoaziou.fr> wrote:
> Hello,
>
> Jay Kamat <jaygka...@gmail.com> writes:
>
>> However, it would be nice to add a "using namespace std" to this
>> source code block, so it can become:
>>
>> #+BEGIN_SRC C++ :includes  :namespaces std
>>   cout << "Hello world\n";
>> #+END_SRC
>>
>>
>> Which makes it cleaner and easier to read, especially for very short
>> code snippets, using a bunch of std tools.
>
> Good idea.
>
>> One concern that I have is that "using namespace *;" is only available
>> in C++ and not C, but there isn't an easy way I could find to limit
>> it's usage to only C++ blocks without a bunch of restructuring, so
>> this will fail if you attempt to set a namespace on a plain C block.
>
> I suggest to add the following to "ob-C.el" so that `org-lint' can issue
> a warning whenever :namespaces is used in a C block.
>
>   (defconst org-babel-header-args:C '((includes . :any))
> "C-specific header arguments.")
>
>   (defconst org-babel-header-args:C++
> `(,(append '((namespaces . :any))
>  org-babel-header-args:C))
> "C++-specific header arguments.")
>
>> Also, this contribution puts me very close to the 15 line limit before
>> I need to get FSF papers signed. I intend to sign papers soon, but I'm
>> a little busy right now, and I'll get around to submitting the request
>> later on.
>
> Thank you. FYI, in many cases, the whole process is very quick and not
> time-consuming.
>
>> Subject: [PATCH] ob-C.el: Add support for specifying namespaces in C/C++
>>
>> * lisp/ob-C.el (org-babel-C-expand-C): Add a :namespaces export option
>>   to C++ org babel blocks. Namespaces specified here will be added to
>>   the file in the format 'using namespace %s;'. Multiple namespaces
>>   can be specified, separated by spaces.
>
> Some comments follow.
>
>> + (namespaces (org-babel-read
>> +   (or (cdr (assq :namespaces params))
>> +   (org-entry-get nil "namespaces" t))
>> +nil)))
>
> Using `org-entry-get' is no longer supported. You can replace the `or'
> with
>
>   (cdr (assq :namespaces params))
>
>> + ;; namespaces
>> + (mapconcat
>> +  (lambda (inc) (format "using namespace %s;" inc))
>> +  namespaces "\n")
>
> Nitpick: I would put the "\n" on another line.
>
> Could you also provide an ORG-NEWS entry for the feature?
>
> Regards,
>
> --
> Nicolas Goaziou
From bf08fb4f89024428a95615bdfede86e3c883d87c Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Sun, 16 Jul 2017 21:55:24 -0700
Subject: [PATCH] ob-C.el: Add support for specifying namespaces in C/C++

* lisp/ob-C.el (org-babel-C-expand-C): Add a :namespaces export option
  to C++ org babel blocks. Namespaces specified here will be added to
  the file in the format 'using namespace %s;'. Multiple namespaces
  can be specified, separated by spaces.

TINYCHANGE
---
 etc/ORG-NEWS | 14 ++
 lisp/ob-C.el | 34 --
 2 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 936ecc36b2..1d08f9ba9d 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -200,6 +200,20 @@ To use =vertica= in an sql =SRC_BLK= set the =:engine= like this:
   SELECT * FROM nodes;
   ,#+END_SRC
 #+END_EXAMPLE
+ C++: New header ~:namespaces~
+
+The new ~:namespaces~ export option can be used to s

[O] [PATCH] Support for 'using namespace *' in ob-C.el

2017-07-16 Thread Jay Kamat
Hi!

A problem that I came across recently was the difficulty of writing
C++ tutorials for beginners to programming in org mode. In such
tutorials, it would be ideal to keep as much boilerplate away from the
examples so they don't ask questions (until we get to those topics).

The shortest ob-C++ example available is:

#+begin_src C++ :includes 
  std::cout<<"Hello World!\n";
#+end_src

However, it would be nice to add a "using namespace std" to this
source code block, so it can become:

#+BEGIN_SRC C++ :includes  :namespaces std
  cout << "Hello world\n";
#+END_SRC

Which makes it cleaner and easier to read, especially for very short
code snippets, using a bunch of std tools.

Attached are patches for adding a :namespaces export option to C++
blocks, and a patch to documentation on worg that documents this
change.

One concern that I have is that "using namespace *;" is only available
in C++ and not C, but there isn't an easy way I could find to limit
it's usage to only C++ blocks without a bunch of restructuring, so
this will fail if you attempt to set a namespace on a plain C block.
Since it's clear that namespaces aren't part of plain C, I don't think
this is too big of a deal.

Please give this a more thorough review than usual, I'm very new to all of this!

Thanks again for creating/maintaining org mode, it's the greatest!

Also, this contribution puts me very close to the 15 line limit before
I need to get FSF papers signed. I intend to sign papers soon, but I'm
a little busy right now, and I'll get around to submitting the request
later on.

Thanks,
-Jay

PS:

I'm getting an error when I try to run:
#+BEGIN_SRC C :exports output :includes stdio.h
printf("hello world\n");
#+END_SRC
because 'stdio.h' is not surrounded by quotes. I can do  and
have it work fine, but how can I include quotes in the header line?
They seem to be stripped by org, and backslash ecaping them does not
work.
From 1e5fff1741dc853214962b7ea90b0832b4ae3e69 Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Sun, 16 Jul 2017 21:55:24 -0700
Subject: [PATCH] ob-C.el: Add support for specifying namespaces in C/C++

* lisp/ob-C.el (org-babel-C-expand-C): Add a :namespaces export option
  to C++ org babel blocks. Namespaces specified here will be added to
  the file in the format 'using namespace %s;'. Multiple namespaces
  can be specified, separated by spaces.

TINYCHANGE
---
 lisp/ob-C.el | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-C.el b/lisp/ob-C.el
index 2bdda68d5..ba10833d0 100644
--- a/lisp/ob-C.el
+++ b/lisp/ob-C.el
@@ -202,9 +202,15 @@ its header arguments."
 	(defines (org-babel-read
 		  (or (cdr (assq :defines params))
 		  (org-entry-get nil "defines" t))
-		  nil)))
+		   nil))
+	(namespaces (org-babel-read
+		  (or (cdr (assq :namespaces params))
+		  (org-entry-get nil "namespaces" t))
+		   nil)))
 (when (stringp includes)
   (setq includes (split-string includes)))
+(when (stringp namespaces)
+  (setq namespaces (split-string namespaces)))
 (when (stringp defines)
   (let ((y nil)
 	(result (list t)))
@@ -224,6 +230,10 @@ its header arguments."
 		(mapconcat
 		 (lambda (inc) (format "#define %s" inc))
 		 (if (listp defines) defines (list defines)) "\n")
+		;; namespaces
+		(mapconcat
+		 (lambda (inc) (format "using namespace %s;" inc))
+		 namespaces "\n")
 		;; variables
 		(mapconcat 'org-babel-C-var-to-C vars "\n")
 		;; table sizes
-- 
2.11.0

From 3267aeac0b90c76f5091104e13389ce6050dd580 Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Sun, 16 Jul 2017 22:09:06 -0700
Subject: [PATCH] Add documentation for ob-C :namespaces

---
 org-contrib/babel/languages/ob-doc-C.org | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/org-contrib/babel/languages/ob-doc-C.org b/org-contrib/babel/languages/ob-doc-C.org
index b1aac99b..faf2b77f 100644
--- a/org-contrib/babel/languages/ob-doc-C.org
+++ b/org-contrib/babel/languages/ob-doc-C.org
@@ -66,7 +66,7 @@ the results of evaluation inserted into the buffer.
 :   int b=1;
 :   printf("%d\n", a+b);
 : #+end_src
-: 
+:
 : #+results:
 : : 2
 
@@ -154,6 +154,11 @@ It features:
  (C & C++ only) just like =:includes= but for =#defines= lines at the
  top of the code.
 
+- =:namespaces= ::
+ (C++ only)
+ accepts either a single name, or a list of names of namespaces to use.
+ The final format will look like this: =using namespace name;=
+
 - =:libs= ::
  (C & C++ only) useful for linking with a library, may be given
  =-L/path/to/lib= and =-llibrary= instructions.
-- 
2.11.0



[O] Fixing mailto and irc links in ox-md.el

2017-07-09 Thread Jay Kamat
Hi!

I would like to submit a patch to org mode, which fixes the behavior
of mailto and irc links in markdown export.

Previously, these org mode snippets:

[[mailto:some.em...@server.net][Jane Doe]]
[[irc:/irc.com/#emacs/bob][bob]]

would export to:

 [Jane Doe](some.em...@server.net)
 [bob](/irc.com/#emacs/bob)

which causes broken links in browsers when they try to view exported markdown.

The new behavior exports them to:

[Jane Doe](mailto:some.em...@server.net)
[bob](irc:/irc.com/#emacs/bob)

so that browsers can open the proper respective application when
opening said links.

The patch that I have made is very small (only one line), and is attached.

There is an external report of this bug here:
https://github.com/larstvei/ox-gfm/issues/17

This is my first time submitting a patch to anything big like org
mode, so please let me know if I've done anything wrong or if anything
seems amiss.

Thanks for looking at this, and thanks for making/developing on org
mode (it's changed my life completely)!

-Jay Kamat
From 0ef21fcd6394b3551a94a5878d414f2e7d17e372 Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Sun, 9 Jul 2017 17:50:09 -0700
Subject: [PATCH] ox-md.el: Fix export of irc and mailto links

* lisp/ox-md.el (org-md-link): Add mailto and irc to links that pass
their types through to markdown export

See: https://github.com/larstvei/ox-gfm/issues/17  for an external
bug report

TINYCHANGE
---
 lisp/ox-md.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index e2b3d29e1..08e385282 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -448,7 +448,7 @@ a communication channel."
  (t (let* ((raw-path (org-element-property :path link))
 	   (path
 		(cond
-		 ((member type '("http" "https" "ftp"))
+		 ((member type '("http" "https" "ftp" "mailto" "irc"))
 		  (concat type ":" raw-path))
 		 ((string= type "file")
 		  (org-export-file-uri (funcall link-org-files-as-md raw-path)))
-- 
2.11.0