[O] ox-html: Opt out of htmlize.el

2017-11-09 Thread Chunyang Xu
Hi,

I think htmlize.el should be optional for ox-html. Although htmlize.el
is cool, there are still reasons to don't use it, e.g.,

- Colors looks nice in Emacs looks bad in the web browser
- No color at all in batch mode
- I want to use third party solutions such pygmentize and highlight.js

When user sets org-html-htmlize-output-type to nil, don't use
htmlize.el.

>From 902e6cea48912bd291c1d3192cb30dc9a1a41fa3 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <m...@xuchunyang.me>
Date: Thu, 9 Nov 2017 23:43:32 +0800
Subject: [PATCH] ox-html: Allow disabling htmlize

* lisp/ox-html.el (org-html-fontify-code): Do it.

Disable htmlize by setting org-html-htmlize-output-type to nil.

TINYCHANGE
---
 lisp/ox-html.el | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 1c3dd8090..d0fe33f2a 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2158,7 +2158,11 @@ is the language used for CODE, as a string, or nil."
  ((not lang)
   ;; Simple transcoding.
   (org-html-encode-plain-text code))
- ;; Case 2: No htmlize or an inferior version of htmlize
+ ;; Case 2: plain text explicitly set
+ ((not org-html-htmlize-output-type)
+  ;; Simple transcoding.
+  (org-html-encode-plain-text code))
+ ;; Case 3: No htmlize or an inferior version of htmlize
  ((not (and (or (require 'htmlize nil t)
 		(error "Please install htmlize from https://github.com/hniksic/emacs-htmlize;))
 		(fboundp 'htmlize-region-for-paste)))
@@ -2166,10 +2170,6 @@ is the language used for CODE, as a string, or nil."
   (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
   ;; Simple transcoding.
   (org-html-encode-plain-text code))
- ;; Case 3: plain text explicitly set
- ((not org-html-htmlize-output-type)
-  ;; Simple transcoding.
-  (org-html-encode-plain-text code))
  (t
   ;; Map language
   (setq lang (or (assoc-default lang org-src-lang-modes) lang))
-- 
2.14.2



[O] [PATCH] * doc/org.texi: Add org-babel-load-languages to Variable Index

2017-08-13 Thread Chunyang Xu

TINYCHANGE
---
 doc/org.texi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/doc/org.texi b/doc/org.texi
index 944c9c56e..032087fc2 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -15541,6 +15541,7 @@ Org supports the following languages for the @samp{src} 
code blocks:
 Additional documentation for some languages are at
 @uref{http://orgmode.org/worg/org-contrib/babel/languages.html}.
 
+@vindex org-babel-load-languages
 By default, only @code{emacs-lisp} is enabled for evaluation.  To enable or
 disable other languages, customize the @code{org-babel-load-languages}
 variable either through the Emacs customization interface, or by adding code
-- 
2.14.1







Re: [O] Bug: Babel result block '#+end_example' not indented [9.0.9 (release_9.0.9-748-g3359e0 @ /Users/xcy/src/org-mode/lisp/)]

2017-08-13 Thread Chunyang Xu

I find my last patch breaks at least ":result org", please see the newer
patch.

>From 4ef5b67af22469bf2591dda0b9b90db1f4df8617 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <m...@xuchunyang.me>
Date: Sun, 13 Aug 2017 15:08:52 +0800
Subject: [PATCH] ob-core: Fix indentation

* lisp/ob-core.el (org-babel-insert-result): Track the end position of the
result block with the marker 'end'.

TINYCHANGE
---
 lisp/ob-core.el | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index f8a660312..dd1efb710 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2290,6 +2290,7 @@ INFO may provide the values of these header arguments (in the
 (org-escape-code-in-region (min (point) end) end))
 			  (goto-char end)
 			  (unless no-newlines (goto-char (point-at-eol)))
+			  (when (markerp end) (set-marker end nil))
 			  (setq end (point-marker
 		  (tabulablep
 		   (lambda (r)
@@ -2384,8 +2385,8 @@ INFO may provide the values of these header arguments (in the
 			   ;; Hard code {{{results(...)}}} on top of customization.
 			   (format "{{{results(%s)}}}"
    org-babel-inline-result-wrap)))
-		  (org-babel-examplify-region beg end results-switches inline)
-		  (setq end (point))
+		  (set-marker-insertion-type end t)
+		  (org-babel-examplify-region beg end results-switches inline)
 		;; Possibly indent results in par with #+results line.
 		(when (and (not inline) (numberp indent) (> indent 0)
 			   ;; In this case `table-align' does the work
@@ -2398,6 +2399,7 @@ INFO may provide the values of these header arguments (in the
 			(message "Code block returned no value.")
 		  (message "Code block produced no output."))
 		  (message "Code block evaluation complete.")))
+	(when (markerp end) (set-marker end nil))
 	(when outside-scope (narrow-to-region visible-beg visible-end))
 	(set-marker visible-beg nil)
 	    (set-marker visible-end nil)))
-- 
2.14.1


Chunyang Xu <m...@xuchunyang.me> writes:

> For example (noticing the last line '#+end_example' is not indented with
> two space)
>
> * test
>   #+BEGIN_SRC sh :results output
>   seq 10
>   #+END_SRC
>
>   #+RESULTS:
>   #+begin_example
>   1
>   2
>   3
>   4
>   5
>   6
>   7
>   8
>   9
>   10
> #+end_example
>
>
> By reading the source code, I think 'indent-rigidly' doesn't the correct
> end bound so the last line is not indented
>
> (defun org-babel-insert-result (result  result-params info hash lang)
>   ...
>   (org-babel-examplify-region beg end results-switches inline)
>   (setq end (point))
>   ...
>   (indent-rigidly beg end indent)
>   ...
>   )
>
> 'org-babel-examplify-region' wraps the result within
> #+begin_example..#+end_example but doesn't move the point forward by one
> line because of using save-excursion.
>
> I attach a patch which uses the marker 'end' to track where the result
> block ends, instead of (point). I have tested it against Emacs
> 24.5 and 25.2 slightly.
>
> From f48e1dfc70e7f91fe39c5545997e84855981db82 Mon Sep 17 00:00:00 2001
> From: Chunyang Xu <m...@xuchunyang.me>
> Date: Sun, 13 Aug 2017 15:08:52 +0800
> Subject: [PATCH] ob-core: Fix indentation
>
> * lisp/ob-core.el (org-babel-insert-result): Track the end position of the
> result block with the marker 'end'.
>
> TINYCHANGE
> ---
>  lisp/ob-core.el | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/lisp/ob-core.el b/lisp/ob-core.el
> index f8a660312..cb4d463a4 100644
> --- a/lisp/ob-core.el
> +++ b/lisp/ob-core.el
> @@ -2290,7 +2290,9 @@ INFO may provide the values of these header arguments 
> (in the
>   (org-escape-code-in-region (min (point) end) 
> end))
> (goto-char end)
> (unless no-newlines (goto-char (point-at-eol)))
> -   (setq end (point-marker
> +   (when (markerp end) (set-marker end nil))
> +   (setq end (point-marker))
> +   (set-marker-insertion-type end t)))
> (tabulablep
>  (lambda (r)
>;; Non-nil when result R can be turned into
> @@ -2345,6 +2347,7 @@ INFO may provide the values of these header arguments 
> (in the
>(org-babel-chomp result "\n"
>  (t (goto-char beg) (insert result)))
> (setq end (point-marker))
> +   (set-marker-insertion-type end t)
> ;; possibly wrap result
> (cond
> 

[O] Bug: Babel result block '#+end_example' not indented [9.0.9 (release_9.0.9-748-g3359e0 @ /Users/xcy/src/org-mode/lisp/)]

2017-08-13 Thread Chunyang Xu

For example (noticing the last line '#+end_example' is not indented with
two space)

* test
  #+BEGIN_SRC sh :results output
  seq 10
  #+END_SRC

  #+RESULTS:
  #+begin_example
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
#+end_example


By reading the source code, I think 'indent-rigidly' doesn't the correct
end bound so the last line is not indented

(defun org-babel-insert-result (result  result-params info hash lang)
  ...
  (org-babel-examplify-region beg end results-switches inline)
  (setq end (point))
  ...
  (indent-rigidly beg end indent)
  ...
  )

'org-babel-examplify-region' wraps the result within
#+begin_example..#+end_example but doesn't move the point forward by one
line because of using save-excursion.

I attach a patch which uses the marker 'end' to track where the result
block ends, instead of (point). I have tested it against Emacs
24.5 and 25.2 slightly.

>From f48e1dfc70e7f91fe39c5545997e84855981db82 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <m...@xuchunyang.me>
Date: Sun, 13 Aug 2017 15:08:52 +0800
Subject: [PATCH] ob-core: Fix indentation

* lisp/ob-core.el (org-babel-insert-result): Track the end position of the
result block with the marker 'end'.

TINYCHANGE
---
 lisp/ob-core.el | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index f8a660312..cb4d463a4 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2290,7 +2290,9 @@ INFO may provide the values of these header arguments (in the
 (org-escape-code-in-region (min (point) end) end))
 			  (goto-char end)
 			  (unless no-newlines (goto-char (point-at-eol)))
-			  (setq end (point-marker
+			  (when (markerp end) (set-marker end nil))
+			  (setq end (point-marker))
+			  (set-marker-insertion-type end t)))
 		  (tabulablep
 		   (lambda (r)
 			 ;; Non-nil when result R can be turned into
@@ -2345,6 +2347,7 @@ INFO may provide the values of these header arguments (in the
 			 (org-babel-chomp result "\n"
 		   (t (goto-char beg) (insert result)))
 		  (setq end (point-marker))
+		  (set-marker-insertion-type end t)
 		  ;; possibly wrap result
 		  (cond
 		   ((assq :wrap (nth 2 info))
@@ -2384,8 +2387,7 @@ INFO may provide the values of these header arguments (in the
 			   ;; Hard code {{{results(...)}}} on top of customization.
 			   (format "{{{results(%s)}}}"
    org-babel-inline-result-wrap)))
-		  (org-babel-examplify-region beg end results-switches inline)
-		  (setq end (point))
+		  (org-babel-examplify-region beg end results-switches inline)
 		;; Possibly indent results in par with #+results line.
 		(when (and (not inline) (numberp indent) (> indent 0)
 			   ;; In this case `table-align' does the work
@@ -2398,6 +2400,7 @@ INFO may provide the values of these header arguments (in the
 			(message "Code block returned no value.")
 		  (message "Code block produced no output."))
 		  (message "Code block evaluation complete.")))
+	(when (markerp end) (set-marker end nil))
 	(when outside-scope (narrow-to-region visible-beg visible-end))
 	(set-marker visible-beg nil)
 	(set-marker visible-end nil)))
-- 
2.14.1



[O] Bug: http://orgmode.org/cgit.cgi/org-mode.git/ - 502 Bad Gateway

2017-07-31 Thread Chunyang Xu

I visited the URL by clicking "cgit" on http://orgmode.org/.





[O] Bug: :results pp and code not working with multiple expressions for Emacs Lisp [9.0.9 (release_9.0.9-647-g0c9feb @ /Users/xcy/src/org-mode/lisp/)]

2017-07-16 Thread Chunyang Xu
The following Emacs Lisp code block has multiple expressions. When I try
to execute it, it fails and says "princ: Invalid function: (a b c)".

#+BEGIN_SRC emacs-lisp :results value pp
  (setq my-list '(a b c))
  my-list
#+END_SRC

Is it intended?

---
Here is the Backtrace:

Debugger entered--Lisp error: (invalid-function (a b c))
  (a b c)(40)
  princ("(a b c)\n" (a b c))
  pp((a b c) (a b c))
  (progn (pp (setq my-list (quote (a b c))) my-list))
  eval((progn (pp (setq my-list (quote (a b c))) my-list)) nil)
  (let* ((lexical (cdr (assq :lexical params))) (result (eval (read (format (if 
(member "output" ...) "(with-output-to-string %s)" "(progn %s)") 
(org-babel-expand-body:emacs-lisp body params))) (if (listp lexical) lexical 
(member lexical (quote ("yes" "t"))) (let ((--params (cdr (assq 
:result-params params (if (member "none" --params) nil (if (or (member 
"scalar" --params) (member "verbatim" --params) (member "html" --params) 
(member "code" --params) (member "pp" --params) (member "file" --params) (and 
(or (member "output" --params) (member "raw" --params) (member "org" --params) 
(member "drawer" --params)) (not (member "table" --params (let 
((print-level nil) (print-length nil)) (if (or (member "scalar" ...) (member 
"verbatim" ...)) (format "%S" result) (format "%s" result))) 
(org-babel-reassemble-table result (org-babel-pick-name (cdr (assq 
:colname-names params)) (cdr (assq :colnames params))) (org-babel-pick-name 
(cdr (assq :rowname-names params)) (cdr (assq :rownames params
  (progn (let* ((lexical (cdr (assq :lexical params))) (result (eval (read 
(format (if ... "(with-output-to-string %s)" "(progn %s)") 
(org-babel-expand-body:emacs-lisp body params))) (if (listp lexical) lexical 
(member lexical (quote ...)) (let ((--params (cdr (assq :result-params 
params (if (member "none" --params) nil (if (or (member "scalar" --params) 
(member "verbatim" --params) (member "html" --params) (member "code" --params) 
(member "pp" --params) (member "file" --params) (and (or ... ... ... ...) (not 
...))) (let ((print-level nil) (print-length nil)) (if (or ... ...) (format 
"%S" result) (format "%s" result))) (org-babel-reassemble-table result 
(org-babel-pick-name (cdr ...) (cdr ...)) (org-babel-pick-name (cdr ...) (cdr 
...
  (unwind-protect (progn (let* ((lexical (cdr (assq :lexical params))) (result 
(eval (read (format ... ...)) (if (listp lexical) lexical (member lexical 
...) (let ((--params (cdr (assq :result-params params (if (member 
"none" --params) nil (if (or (member "scalar" --params) (member "verbatim" 
--params) (member "html" --params) (member "code" --params) (member "pp" 
--params) (member "file" --params) (and ... ...)) (let (... ...) (if ... ... 
...)) (org-babel-reassemble-table result (org-babel-pick-name ... ...) 
(org-babel-pick-name ... ...))) (set-window-configuration wconfig))
  (let ((wconfig (current-window-configuration))) (unwind-protect (progn (let* 
((lexical (cdr (assq :lexical params))) (result (eval (read ...) (if ... 
lexical ... (let ((--params (cdr ...))) (if (member "none" --params) nil 
(if (or ... ... ... ... ... ... ...) (let ... ...) (org-babel-reassemble-table 
result ... ...)) (set-window-configuration wconfig)))
  org-babel-execute:emacs-lisp("(setq my-list '(a b c))\nmy-list" 
((:colname-names) (:rowname-names) (:result-params "replace" "value" "pp") 
(:result-type . value) (:results . "replace value pp") (:exports . "code") 
(:session . "none") (:cache . "no") (:noweb . "no") (:hlines . "no") (:tangle . 
"no") (:lexical . "no")))
  org-babel-execute-src-block(nil ("emacs-lisp" "(setq my-list '(a b 
c))\nmy-list" ((:colname-names) (:rowname-names) (:result-params "pp" "value" 
"replace") (:result-type . value) (:results . "pp value replace") (:exports . 
"code") (:lexical . "no") (:tangle . "no") (:hlines . "no") (:noweb . "no") 
(:cache . "no") (:session . "none")) "" nil 5500 "(ref:%s)"))
  org-ctrl-c-ctrl-c(nil)
  funcall-interactively(org-ctrl-c-ctrl-c nil)
  call-interactively(org-ctrl-c-ctrl-c nil nil)
  command-execute(org-ctrl-c-ctrl-c)


Emacs  : GNU Emacs 25.2.1 (x86_64-apple-darwin16.6.0, Carbon Version 157 AppKit 
1504.83)
 of 2017-07-10
Package: Org mode version 9.0.9 (release_9.0.9-647-g0c9feb @ 
/Users/xcy/src/org-mode/lisp/)





[O] [PATCH] * doc/library-of-babel.org: Replace non-existent with-temp-filebuffer.

2017-07-13 Thread Chunyang Xu
TINYCHANGE
---
 doc/library-of-babel.org | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/library-of-babel.org b/doc/library-of-babel.org
index 0098e7263..b6c90c763 100644
--- a/doc/library-of-babel.org
+++ b/doc/library-of-babel.org
@@ -73,7 +73,7 @@ Read local or remote file in [[http://www.json.org/][json]] 
format into emacs-li
   (require 'json)
   (cond
(file
-(with-temp-filebuffer file
+(org-babel-with-temp-filebuffer file
   (goto-char (point-min))
   (json-read)))
(url
-- 
2.13.1





Re: [O] org-protocol documentation

2017-06-19 Thread Chunyang Xu
Mario Martelli  writes:

>> for what it's worth, the Emacs Mac Port supports org-protocol out of
>> box. It works without the Emacs server (emacsclient), e.g.,
>
> Good to know. I’ve listed it in the documentation.
> Do you plan to provide ready built binaries?

The author of the Emacs Mac Port is Mitsuharu Yamamoto and I don't think
there is any built binaries provided by him. I installed the built
binaries via MacPorts (a package manager for Mac) with:

  $ sudo port install emacs-mac-app

and I also heard that it is also available from Homebrew (another
package manager).

[...]





Re: [O] org-protocol documentation

2017-06-19 Thread Chunyang Xu
Mario Martelli  writes:

> Hi,
>
> recently I’ve updated my macOS - Org mode setup. I had some pain setting up 
> org-protocol properly

for what it's worth, the Emacs Mac Port supports org-protocol out of
box. It works without the Emacs server (emacsclient), e.g.,

  $ open 
'org-protocol://store-link?url=http%3A%2F%2Forgmode.org=Org%20mode'

Thus for Emacs Mac Port users, no setup is needed.

[Emacs Mac Port] https://bitbucket.org/mituharu/emacs-mac

[...]






Re: [O] Asks user what to do with each tangle-file before overriding?

2017-06-18 Thread Chunyang Xu
"Charles C. Berry"  writes:


[...]

> It sounds like you are re-inventing version control and wanting it to be 
> implemented in org-babel-tangle.
>
> `org-babel-tangle' can do a lot of work to assemble the files that result 
> from tangling.  Modifying `org-babel-tangle' to do what you ask would be 
> far from trivial and make a complicated function even more tortuous.

Yes, I agree it is not an easy task.

> IMHO, it is better to solve your problem as follows: Set up a separate 
> directory into which files are tangled.  Use version control on that 
> directory.  Inspect changes after each tangle using the version control 
> system's diff tools, commit good changes, and revert unwanted ones.  Then 
> run a script that uses the VC's data to identify changed files and copy 
> those files to the location on your system where they will be used.

I found 'C-x s' ('save-some-buffers') can be used as the "version
control", so I made a wrapper command for 'org-babel-tangle' using it.
The wrapper command is not perfect (I guess it doesn't support
remote-file and doesn't always respect tangle-mode, for example), but I
am OK with it and it already does what I want.

   #+BEGIN_SRC emacs-lisp :results silent :lexical yes
 (defun chunyang-org-babel-tangle ( arg target-file lang)
   "Like `org-babel-tangle' but don't override without permission."
   (declare (interactive-only org-babel-tangle))
   (interactive "P")
   (require 'ob-tangle)
   (require 'seq)
   (require 'cl-lib)
   (save-some-buffers)
   (let* ((tmpdir (let ((dir "/tmp/org-babel-tangle/"))
(or (file-exists-p dir) (make-directory dir))
dir))
  (mkbak (lambda (filename)
   (expand-file-name
(replace-regexp-in-string "/" "!" (expand-file-name 
filename))
tmpdir)))
  (diffp (lambda (file-a file-b)
   (/= 0 (call-process diff-command nil nil nil 
(expand-file-name file-a) file-b
  (swap (lambda (file-a file-b)
  (let ((tmp (make-temp-name tmpdir)))
(copy-file file-a tmp t t t t)
(copy-file file-b file-a t t t t)
(copy-file tmp file-b t t t t
  deleted-files
  tangled-files
  (advice (define-advice delete-file (:around (old-fun filename 
 args) dont-delete)
(push filename deleted-files)
(copy-file filename (funcall mkbak filename) t t t t)
(apply old-fun filename args
 (unwind-protect
 (progn
   (setq tangled-files (org-babel-tangle arg target-file lang)
 deleted-files (nreverse deleted-files))
   (cl-loop for f in (seq-intersection deleted-files tangled-files)
for bak = (funcall mkbak f)
do
(funcall swap f bak)
(if (funcall diffp f bak)
(with-current-buffer (find-file-noselect f)
  (message "Diff %s..." f)
  (delete-region (point-min) (point-max))
  (insert-file-contents bak))
  (message "Skip %s..." f))
finally (save-some-buffers)))
   (advice-remove 'delete-file advice
   #+END_SRC


[...]






Re: [O] Asks user what to do with each tangle-file before overriding?

2017-06-18 Thread Chunyang Xu
Nicolas Goaziou  writes:

[...]

> I don't think it is a good idea to have file that can be both edited
> manually, and auto-generated (i.e., tangled). Or, to put it differently,
> the idea behind tangling is that you only handle the code block, not the
> file itself.

I still think overriding exist files is dangerous, user can lost data
because of it, so it should be safer if org-babel-tangle can let user
decide how to deal with it.

Besides, if a code block is not changed and I have already tangled it
before, I don't want org-babel-tangle to update the last modified
timestamp of the tangle-file every time I tangle, as along as there is
no actual changes. It is simply unnecessary to me and makes the last
modified timestamp more or less useless. So I would like
org-babel-tangle let me choose what I want.

[...]





[O] Asks user what to do with each tangle-file before overriding?

2017-06-15 Thread Chunyang Xu
Hi,

Currently 'C-c C-v C-t' ('org-babel-tangle') simply overrides existing
tangle-file, I would like org to ask me what to do? such as

a) yes (override)
b) no (don't override)
c) show the diff then ask again

In addition, if there is no diff (i.e., having the same contents), user
can choose (e.g., via a user option) to simply pass this tangle-file
without overriding.

I am asking for this feature because I am storing my dotfiles in a
single Org file [1], and when I change my Bash configuration then
tangle, I don't need to worry if Org is tangling other configuration
correctly, especially ~/.ssh/id_rsa and ~/.authinfo.gpg. I would rather
leave these unchanged files than override (even only file modification
timestamps are updated).

[1] https://raw.githubusercontent.com/xuchunyang/dotfiles/master/README.org





Re: [O] org to static site?

2017-05-31 Thread Chunyang Xu
Matt Price  writes:

> I'm trying to wean myself off of Wordpress for next year's teaching
> websites, and am wondering what solutions other people are using for
> turning a collection of org pages and/or subtrees into a static html site.
> I am leaning towards Hugo but honestly not for any sensible reason; I've
> seen other people use Jekyll, though the fact that Github doesn't support
> direct conversion from org-mode removes some of Jekyll's appeal; and I know
> there are a number of other solutions too.
>
> So, I would love to hear what you all recommend.

It is said that Nanoc is flexible. You can convert org mode to HTML with
Pandoc or Emacs. Nanoc supports Pandoc out of box. To use Emacs, you
need to write your own "filter" (Nanoc's terminology, i.e., convert one
format into another), for example,

#+BEGIN_SRC ruby
require 'tempfile'

class OrgFilter < Nanoc::Filter
  identifier :org

  def run(content, params = {})
file = Tempfile.new(['nanoc', '.org'])
file.write(content)
file.close
system("emacs --batch --load init.el #{file.path} --eval 
'(org-html-export-to-html nil nil nil t)'")
html = "#{File.dirname(file.path)}/#{File.basename(file.path, '.org')}.html"
file.unlink
File.read(html)
  end
end
#+END_SRC

I just created my own site  with it last
week. The syntax highlighting on code block is provided by htmlize.el.
I noticed `org-html-export-to-html' produces different HTML every time
even the org file is unchanged at all. It is very annoying to me. I
found a work-around to avoid it,

#+BEGIN_SRC emacs-lisp
;; -*- lexical-binding: t; -*-
(let ((id 0))
  (defun org-export-new-reference--use-persistent-id (references)
(let ((new id))
  (while (rassq new references)
(setq new (incf id)))
  new)))

(advice-add 'org-export-new-reference
:override #'org-export-new-reference--use-persistent-id)
#+END_SRC

[...]

--
Org mode version 9.0.7 (release_9.0.7-496-g3d3e24 @
/Users/xcy/src/org-mode/lisp/)





[O] Bug: org-git-link.el fails for file in $HOME but not under Git [9.0.7 (release_9.0.7-493-g82a503 @ /Users/xcy/src/org-mode/lisp/)]

2017-05-29 Thread Chunyang Xu
Hi,

After loading org-git-link.el, 'C-c l' ('org-store-link') fails for file
in $HOME but not under Git, such as "~/foo.c". The following is contents
of the *Backtrace* buffer while the error happens. I have attached a
patch to fix this issue.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  directory-file-name(nil)
  (file-name-directory (directory-file-name dirpath))
  (let ((dirname (file-name-directory (directory-file-name dirpath))) 
(basename (file-name-nondirectory (directory-file-name dirpath (list 
dirname basename))
  org-git-split-dirpath(nil)
  (let ((dirlist (org-git-split-dirpath dir))) (if (string= (nth 1 dirlist) 
"") (progn (throw (quote toplevel) nil))) (setq dir (nth 0 dirlist) relpath 
(concat (file-name-as-directory (nth 1 dirlist)) relpath)))
  (while (not (file-exists-p (expand-file-name ".git" dir))) (let ((dirlist 
(org-git-split-dirpath dir))) (if (string= (nth 1 dirlist) "") (progn (throw 
(quote toplevel) nil))) (setq dir (nth 0 dirlist) relpath (concat 
(file-name-as-directory (nth 1 dirlist)) relpath
  (catch (quote toplevel) (while (not (file-exists-p (expand-file-name 
".git" dir))) (let ((dirlist (org-git-split-dirpath dir))) (if (string= (nth 1 
dirlist) "") (progn (throw (quote toplevel) nil))) (setq dir (nth 0 dirlist) 
relpath (concat (file-name-as-directory (nth 1 dirlist)) relpath (list 
(expand-file-name ".git" dir) relpath))
  (let ((dir (file-name-directory path)) (relpath (file-name-nondirectory 
path))) (catch (quote toplevel) (while (not (file-exists-p (expand-file-name 
".git" dir))) (let ((dirlist (org-git-split-dirpath dir))) (if (string= (nth 1 
dirlist) "") (progn (throw (quote toplevel) nil))) (setq dir (nth 0 dirlist) 
relpath (concat (file-name-as-directory (nth 1 dirlist)) relpath (list 
(expand-file-name ".git" dir) relpath)))
  org-git-gitrepos-p("~/foo.c")
  (if (org-git-gitrepos-p file) (progn (org-store-link-props :type "git" 
:link (org-git-create-git-link file line
  (let ((file (abbreviate-file-name (buffer-file-name))) (line 
(line-number-at-pos))) (if (org-git-gitrepos-p file) (progn 
(org-store-link-props :type "git" :link (org-git-create-git-link file line)
  (progn (let ((file (abbreviate-file-name (buffer-file-name))) (line 
(line-number-at-pos))) (if (org-git-gitrepos-p file) (progn 
(org-store-link-props :type "git" :link (org-git-create-git-link file line))
  (if (buffer-file-name) (progn (let ((file (abbreviate-file-name 
(buffer-file-name))) (line (line-number-at-pos))) (if (org-git-gitrepos-p file) 
(progn (org-store-link-props :type "git" :link (org-git-create-git-link file 
line)))
  org-git-store-link()
  #[257 "\300. \205\f..B\211\262.\207" [nil] 4 "\n\n(fn 
F)"](org-git-store-link)
  mapcar(#[257 "\300. \205\f..B\211\262.\207" [nil] 4 "\n\n(fn F)"] 
(org-git-store-link org-rmail-store-link org-mhe-store-link org-irc-store-link 
org-info-store-link org-gnus-store-link org-docview-store-link 
org-bibtex-store-link org-bbdb-store-link org-w3m-store-link 
org-notmuch-search-store-link org-notmuch-store-link org-eww-store-link 
org-man-store-link))
  org-store-link(nil)
  funcall-interactively(org-store-link nil)
  call-interactively(org-store-link nil nil)
  command-execute(org-store-link)

Emacs  : GNU Emacs 25.2.1 (x86_64-apple-darwin16.4.0, Carbon Version 157 AppKit 
1504.81)
 of 2017-04-26
Package: Org mode version 9.0.7 (release_9.0.7-493-g82a503 @ 
/Users/xcy/src/org-mode/lisp/)

>From 15a25f5dba882aa913b12ae42fa89874b3cd8a0d Mon Sep 17 00:00:00 2001
From: Chunyang Xu <m...@xuchunyang.me>
Date: Mon, 29 May 2017 17:03:24 +0800
Subject: [PATCH] org-git-link.el: Fix `org-git-find-gitdir'

* contrib/lisp/org-git-link.el (org-git-find-gitdir): Expand
abbreviated directory name.
---
 contrib/lisp/org-git-link.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/lisp/org-git-link.el b/contrib/lisp/org-git-link.el
index 65f25b294..0028daf9b 100644
--- a/contrib/lisp/org-git-link.el
+++ b/contrib/lisp/org-git-link.el
@@ -126,7 +126,7 @@
   the path. Example: (org-git-find-gitdir
   \"~/gitrepos/foo/bar.txt\") returns
   '(\"/home/user/gitrepos/.git\" \"foo/bar.txt\"). When not in a git repository, return nil."
-  (let ((dir (file-name-directory path))
+  (let ((dir (expand-file-name (file-name-directory path)))
 (relpath (file-name-nondirectory path)))
 (catch 'toplevel
   (while (not (file-exists-p (expand-file-name ".git" dir)))
-- 
2.13.0



Re: [O] Bug: link formating problem [9.0.5 (9.0.5-elpaplus @ /Users/mistkafka/.emacs.d/elpa/org-plus-contrib-20170210/)]

2017-05-27 Thread Chunyang Xu
Nicolas Goaziou <m...@nicolasgoaziou.fr> writes:

> Hello,
>
> Chunyang Xu <m...@xuchunyang.me> writes:
>
>> I changed `org-plain-link-re' to make it not longer think "[" and "]"
>> are valid characters in a URL, which solves the problem.
>
> Thank you.
>
> I solved the problem differently, but your suggestion still makes sense.
> Would you mind making it a proper patch, using "git format-patch", with
> a proper commit message? Don't forget to add TINYCHANGE cookie at the
> end if you haven't signed papers yet.

Here is the patch.

>From c0b86176dc99f63385bcebc1ccbcb5d41f062a2c Mon Sep 17 00:00:00 2001
From: Chunyang Xu <m...@xuchunyang.me>
Date: Sun, 28 May 2017 12:10:58 +0800
Subject: [PATCH] Exclude '[' and ']' in `org-plain-link-re'

* lisp/org.el (org-make-link-regexps): Do it.

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

diff --git a/lisp/org.el b/lisp/org.el
index 102a9b265..c2818299e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5687,7 +5687,7 @@ This should be called after the variable `org-link-parameters' has changed."
 	  org-plain-link-re
 	  (concat
 	   "\\<" types-re ":"
-	   "\\([^ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] \t\n]\\|/\\)\\)\\)")
+	   "\\([^][ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] \t\n]\\|/\\)\\)\\)")
 	  ;;	 "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)")
 	  org-bracket-link-regexp
 	  "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]"
-- 
2.13.0


> Regards,
>
> -- 
> Nicolas Goaziou


Re: [O] Bug: link formating problem [9.0.5 (9.0.5-elpaplus @ /Users/mistkafka/.emacs.d/elpa/org-plus-contrib-20170210/)]

2017-05-27 Thread Chunyang Xu
Nicolas Goaziou <m...@nicolasgoaziou.fr> writes:

> Hello,
>
> Chunyang Xu <m...@xuchunyang.me> writes:
>
>> I changed `org-plain-link-re' to make it not longer think "[" and "]"
>> are valid characters in a URL, which solves the problem.
>
> Thank you.
>
> I solved the problem differently, but your suggestion still makes sense.
> Would you mind making it a proper patch, using "git format-patch", with
> a proper commit message? Don't forget to add TINYCHANGE cookie at the
> end if you haven't signed papers yet.

Sure, I will do that when it is possible (Right now, I can not git-clone
org-mode's repository,

~$ git clone git://orgmode.org/org-mode.git
Cloning into 'org-mode'...
fatal: read error: Connection reset by peer

and the mirror at http://repo.or.cz/w/org-mode.git is also outdated for
about 4 days).

> Regards,
>
> -- 
> Nicolas Goaziou





Re: [O] Bug: link formating problem [9.0.5 (9.0.5-elpaplus @ /Users/mistkafka/.emacs.d/elpa/org-plus-contrib-20170210/)]

2017-05-26 Thread Chunyang Xu

I changed `org-plain-link-re' to make it not longer think "[" and "]"
are valid characters in a URL, which solves the problem.

diff -u --label 
/Users/xcy/.emacs.d/elpa-25.2.1/org-plus-contrib-20170515/org.el --label 
\#\ 
/Users/xcy/.emacs.d/elpa-25.2.1/org-plus-contrib-20170515/org.el 
/var/folders/7f/s191h4q97p90374yw15ssrs0gn/T/buffer-content-71053Vt
--- /Users/xcy/.emacs.d/elpa-25.2.1/org-plus-contrib-20170515/org.el
+++ #
@@ -5847,7 +5847,7 @@
  org-plain-link-re
  (concat
   "\\<" types-re ":"
-  "\\([^ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] 
\t\n]\\|/\\)\\)\\)")
+  "\\([^][ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] 
\t\n]\\|/\\)\\)\\)")
  ;; "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)")
  org-bracket-link-regexp
  "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]"

Diff finished.  Fri May 26 16:01:30 2017

林镇国  writes:

> Remember to cover the basics, that is, what you expected to happen and
> what in fact did happen.  You don't know how to make a good report?  See
>
>  http://orgmode.org/manual/Feedback.html#Feedback
>
> Your bug report will be posted to the Org mailing list.
> 
>
> Hi!
>
> When I insert a link to my note, such as“这是一个[[link][链接]]啦~”,
> the text after the link, "啦~", will be formatting as link style.
>
> Space participe is not work in some language, such as Chinese and
> Japanese. If I use a space to participe the link the the text after
> it, that's really ugly in Chinese.
>
> And I wonder even in English, must we add a space after a link?
>
> By the way, it just a formatting problem(with org-hide-emphasis-markers
> is t), not export problem, the link export to html is ok!
>
> Emacs  : GNU Emacs 25.2.1 (x86_64-apple-darwin13.4.0, Carbon Version 157 
> AppKit 1265.21)
> of 2017-02-06
> Package: Org mode version 9.0.5 (9.0.5-elpaplus @ 
> /Users/mistkafka/.emacs.d/elpa/org-plus-contrib-20170210/)
>
> current state:
> ==
> (setq
> org-id-locations-file "/Users/mistkafka/.emacs.d/.cache/.org-id-locations"
> org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
> org-babel-header-arg-expand)
> org-clock-persist-file "/Users/mistkafka/.emacs.d/.cache/org-clock-save.el"
> org-speed-command-hook '(org-speed-command-default-hook 
> org-babel-speed-command-hook)
> org-time-clocksum-format '(:hours "%d" :require-hours t :minutes ":%02d" 
> :require-minutes t)
> org-occur-hook '(org-first-headline-recenter)
> org-imenu-depth 8
> org-metaup-hook '(org-babel-load-in-session-maybe)
> org-html-format-drawer-function '(closure
>(htmlize-buffer-places 
> org-html-format-table-no-css htmlize-css-name-prefix htmlize-output-type 
> htmlize-output-type
> htmlize-css-name-prefix t)
>(_name contents) contents)
> org-log-done t
> org-latex-format-inlinetask-function 
> 'org-latex-format-inlinetask-default-function
> org-confirm-shell-link-function 'yes-or-no-p
> org-image-actual-width nil
> org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
> org-link-translation-function 'toc-org-unhrefify
> org-present-mode-hook '(spacemacs//org-present-start)
> org-agenda-restore-windows-after-quit t
> org-latex-format-headline-function 'org-latex-format-headline-default-function
> org-default-notes-file "notes.org"
> org-todo-keyword-faces '(("NEXT" :inherit warning) ("PROJECT" :inherit 
> font-lock-string-face))
> org-after-todo-state-change-hook '(org-clock-out-if-current)
> org-latex-format-drawer-function '(closure (t) (_ contents) contents)
> org-odt-format-headline-function 'org-odt-format-headline-default-function
> org-todo-repeat-to-state "NEXT"
> org-src-mode-hook '(org-src-babel-configure-edit-buffer 
> org-src-mode-configure-edit-buffer)
> org-agenda-before-write-hook '(org-agenda-add-entry-text)
> org-babel-pre-tangle-hook '(save-buffer)
> org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook 
> change-major-mode-hook org-show-block-all append local] 5]
>  #[0 "\300\301\302\303\304$\207" [add-hook 
> change-major-mode-hook org-babel-show-result-all append local] 5] 
> org-babel-result-hide-spec
>  org-babel-hide-all-hashes spacemacs/load-yasnippet 
> toc-org-enable org-download-enable org-bullets-mode 
> spacemacs//org-babel-do-load-languages flyspell-mode
>  spacemacs/add-org-surrounds evil-org-mode org-eldoc-load 
> spacemacs//init-company-org-mode company-mode)
> org-archive-hook '(org-attach-archive-delete-maybe)
> org-ascii-format-drawer-function '(closure (t) (_name contents _width) 
> contents)
> org-odt-format-inlinetask-function 'org-odt-format-inlinetask-default-function
> org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers 
> org-cycle-show-empty-lines 

Re: [O] Bug: link formating problem [9.0.5 (9.0.5-elpaplus @ /Users/mistkafka/.emacs.d/elpa/org-plus-contrib-20170210/)]

2017-05-26 Thread Chunyang Xu
Kaushal Modi <kaushal.m...@gmail.com> writes:

> On Wed, May 24, 2017 at 9:50 AM Chunyang Xu <m...@xuchunyang.me> wrote:
>
>>
>> Nicolas Goaziou writes:
>>
>> > Hello,
>> >
>> > 林镇国 <mistka...@gmail.com> writes:
>> >
>> >> When I insert a link to my note, such as“这是一个[[link][链接]]啦~”,
>> >> the text after the link, "啦~", will be formatting as link style.
>> >
>> > FWIW, I cannot reproduce it, i.e., only "链接" appears with a link face.
>>
>> I can reproduce if "link" is a real link and "description" doesn't
>> contain white space, for example,
>>
>> [[http://example.com/][Example]]blah
>> 
>> Also under the org-link face
>>
>> It looks like `org-plain-link-re' doesn't think a link is end unless
>> a punctuation character is found:
>>
>> org-plain-link-re
>> (concat
>>  "\\<" types-re ":"
>>  "\\([^ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:]
>> \t\n]\\|/\\)\\)\\)")
>>   ^
>>
>> It is a reasonable assumption for English, but not for Chinese.
>>
>
> I actually stumbled across this few days back, and when using English
> language :)
>
> Here's a solution that might work for you too (and my notes on why I set
> this):
>
> ;; The default value of `org-highlight-links' contains `plain' too.
> ;; - "plain" links are links in normal text, no whitespace, like
> http://foo.com.
> ;; Here's why I remove "plain" from this list:
> ;; - If I have two bracketed links next to each-other in org-mode (like
> below),
> ;; [[http://google.com][1]],[[http://orgmode.org][2]]
> ;; - and, if `plain' is in the `org-highlight-links' list,
> ;;  the "," in there will also be highlighted as a link. So it would look
> ;;  as if the "1,2" string pointed to a single link!
> ;;But without `plain' as part of this list, the "1" and "2" strings will
> ;; look like separate links (as should be the case), as the "," will not be
> ;; highlighted as a link.
> (setq org-highlight-links (delete 'plain org-highlight-links))

Oh, I didn't know the user option, I just added it to my init file.
Thanks.

>
> -- 
>
> Kaushal Modi





Re: [O] Bug: link formating problem [9.0.5 (9.0.5-elpaplus @ /Users/mistkafka/.emacs.d/elpa/org-plus-contrib-20170210/)]

2017-05-24 Thread Chunyang Xu

Nicolas Goaziou writes:

> Hello,
>
> 林镇国  writes:
>
>> When I insert a link to my note, such as“这是一个[[link][链接]]啦~”,
>> the text after the link, "啦~", will be formatting as link style.
>
> FWIW, I cannot reproduce it, i.e., only "链接" appears with a link face.

I can reproduce if "link" is a real link and "description" doesn't
contain white space, for example,

[[http://example.com/][Example]]blah

Also under the org-link face

It looks like `org-plain-link-re' doesn't think a link is end unless
a punctuation character is found:

org-plain-link-re
(concat
 "\\<" types-re ":"
 "\\([^ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] \t\n]\\|/\\)\\)\\)")
  ^

It is a reasonable assumption for English, but not for Chinese.

> Regards,





Re: [O] Bug: Can't execute C code block from remote directory [9.0.5 (release_9.0.5-401-g86ff11 @ /Users/xcy/src/org-mode/lisp/)]

2017-04-05 Thread Chunyang Xu

Nicolas Goaziou writes:

> Hello,
>
> Chunyang Xu <m...@xuchunyang.me> writes:
>
>> Here is a patch which can fix the issue.
>
> Thank you.
>
>> From e42b22f74c2f04a4d8e7eec0a6bdacbd08bebf12 Mon Sep 17 00:00:00 2001
>> From: Chunyang Xu <m...@xuchunyang.me>
>> Date: Mon, 3 Apr 2017 14:46:51 +0800
>> Subject: [PATCH] ob-C: Fix remote executing
>>
>> * lisp/ob-C.el (org-babel-C-execute): Process remote bin file.
>>
>> TINYCHANGE
>> ---
>>  lisp/ob-C.el | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lisp/ob-C.el b/lisp/ob-C.el
>> index 795bcb2b7..e54e17492 100644
>> --- a/lisp/ob-C.el
>> +++ b/lisp/ob-C.el
>> @@ -161,7 +161,7 @@ or `org-babel-execute:C++' or `org-babel-execute:D'."
>> (org-babel-eval
>>  (pcase org-babel-c-variant
>>((or `c `cpp)
>> -   (concat tmp-bin-file cmdline))
>> +   (concat (org-babel-process-file-name tmp-bin-file) cmdline))
>
> I see that `tmp-bin-file' is used a couple other times in the body.
> Would it make sense to wrap the initial binding within
> `org-babel-process-file-name' instead of doing it only for this
> occurrence?

Both ways look OK to me. `tmp-bin-file' is used only twice and invoking
`org-babel-process-file-name' is cheap. And converting `tmp-bin-file'
from remote to local name only when 100% necessary (i.e. within
`org-babel-eval') looks more logical to me. On the other hand,
`tmp-bin-file' as a remote file name is useless, thus the way you
suggested is reasonable as well.

> Regards,





Re: [O] Bug: Can't execute C code block from remote directory [9.0.5 (release_9.0.5-401-g86ff11 @ /Users/xcy/src/org-mode/lisp/)]

2017-04-03 Thread Chunyang Xu

Here is a patch which can fix the issue.

>From e42b22f74c2f04a4d8e7eec0a6bdacbd08bebf12 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <m...@xuchunyang.me>
Date: Mon, 3 Apr 2017 14:46:51 +0800
Subject: [PATCH] ob-C: Fix remote executing

* lisp/ob-C.el (org-babel-C-execute): Process remote bin file.

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

diff --git a/lisp/ob-C.el b/lisp/ob-C.el
index 795bcb2b7..e54e17492 100644
--- a/lisp/ob-C.el
+++ b/lisp/ob-C.el
@@ -161,7 +161,7 @@ or `org-babel-execute:C++' or `org-babel-execute:D'."
 	   (org-babel-eval
 	(pcase org-babel-c-variant
 	  ((or `c `cpp)
-	   (concat tmp-bin-file cmdline))
+	   (concat (org-babel-process-file-name tmp-bin-file) cmdline))
 	  (`d
 	   (format "%s %s %s %s"
 		   org-babel-D-compiler
-- 
2.12.0


Chunyang Xu writes:

> Hi.
>
> My computer is running Mac OS, I would like to run some C code from my
> VPS which is running GNU/Linux Ubuntu. For example,
>
> #+BEGIN_SRC C :dir /ssh:xuchunyang.me:
> puts("Hello, World!");
> #+END_SRC
>
> but when I execute this code block with C-c C-c, it popups *Org-Babel
> Error Output* and here is its contents
>
> /bin/sh: 1: /ssh:xuchunyang.me:/tmp/C-bin-18285iKe: not found
>
> However, the file does exist and produce the desired output
>
> #+BEGIN_SRC sh :dir /ssh:xuchunyang.me:
> /tmp/C-bin-18285U4c
> #+END_SRC
>
> #+RESULTS:
> | Hello | World! |



[O] Bug: Can't execute C code block from remote directory [9.0.5 (release_9.0.5-401-g86ff11 @ /Users/xcy/src/org-mode/lisp/)]

2017-04-01 Thread Chunyang Xu
Hi.

My computer is running Mac OS, I would like to run some C code from my
VPS which is running GNU/Linux Ubuntu. For example,

#+BEGIN_SRC C :dir /ssh:xuchunyang.me:
puts("Hello, World!");
#+END_SRC

but when I execute this code block with C-c C-c, it popups *Org-Babel
Error Output* and here is its contents

/bin/sh: 1: /ssh:xuchunyang.me:/tmp/C-bin-18285iKe: not found

However, the file does exist and produce the desired output

#+BEGIN_SRC sh :dir /ssh:xuchunyang.me:
/tmp/C-bin-18285U4c
#+END_SRC

#+RESULTS:
| Hello | World! |


--
Emacs  : GNU Emacs 26.0.50 (build 10, x86_64-apple-darwin16.4.0, NS 
appkit-1504.81 Version 10.12.3 (Build 16D32))
 of 2017-03-28
Package: Org mode version 9.0.5 (release_9.0.5-401-g86ff11 @ 
/Users/xcy/src/org-mode/lisp/)





[O] Bug: Empty result when Emacs Lisp code block evals to nil [9.0.5 (release_9.0.5-401-g86ff11 @ /Users/xcy/src/org-mode/lisp/)]

2017-04-01 Thread Chunyang Xu
Hi.

I notice that if the result is nil during executing emacs-lisp code
block, org simply displays a empty #+RESULT block. For example,


#+BEGIN_SRC emacs-lisp
t
#+END_SRC

#+RESULTS:
: t

#+BEGIN_SRC emacs-lisp
nil
#+END_SRC

#+RESULTS:


I don't see why 'nil' is special than other values like 't'.


--
Emacs  : GNU Emacs 26.0.50 (build 10, x86_64-apple-darwin16.4.0, NS 
appkit-1504.81 Version 10.12.3 (Build 16D32))
 of 2017-03-28
Package: Org mode version 9.0.5 (release_9.0.5-401-g86ff11 @ 
/Users/xcy/src/org-mode/lisp/)





[O] HTTPS support of Org ELPA?

2017-03-14 Thread Chunyang Xu
Hi.

Can someone add HTTPS support for Org ELPA? Github user @thblt
complained about lacking HTTPS support via
https://github.com/melpa/melpa/issues/4554#issuecomment-278638944

Thanks.





[O] Bug: http://orgmode.org/worg/org-configs/org-hooks.php 404 [9.0.5 (release_9.0.5-347-g2f4860 @ /Users/xcy/src/org-mode/lisp/)]

2017-03-14 Thread Chunyang Xu
Hi.

The URL  is mentioned
at (info "(org) Hooks"), when I open it in web browser, it says "404 Not
Found"





[O] Bug: "Tbl -> Calculate -> Which Column?" says "Wrong type argument: commandp, org-table-current-column" [9.0.3 (release_9.0.3-255-g728929 @ /Users/xcy/src/org-mode/lisp/)]

2017-01-31 Thread Chunyang Xu

In an Org Mode buffer, put point in a table and click
"Tbl -> Calculate -> Which Column?" in Menu bar, it fails and reports
the following in the echo area

  Wrong type argument: commandp, org-table-current-column

by looking at the source code of 'org-table-current-column', it is not a
interactive command. Thus I think it's a bug, although I don't know
which command it should run.

Emacs  : GNU Emacs 25.1.1 (x86_64-apple-darwin16.3.0, Carbon Version 157 AppKit 
1504.76)
 of 2017-01-15
Package: Org mode version 9.0.3 (release_9.0.3-255-g728929 @ 
/Users/xcy/src/org-mode/lisp/)





[O] [PATCH] org-info: Fix html export of info link

2017-01-19 Thread Chunyang Xu
Hi,

I notice the html export (actually, the HTML URL anchor part) of info
link is incorrect in some cases, for example
in (info "(org) Built-in table editor"), the corresponding org link is

  [[info:org#Built-in%20table%20editor][info:org#Built-in table editor]]

org exports it to

  
https://www.gnu.org/software/emacs/manual/html_mono/org.html#Built-in-table-editor

but the correct one is

  
https://www.gnu.org/software/emacs/manual/html_mono/org.html#Built_002din-table-editor

I have submitted a patch to fix this.
>From 3084d1145968d32831270e8f00ca4aaf8c27c820 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <m...@xuchunyang.me>
Date: Fri, 20 Jan 2017 01:08:26 +0800
Subject: [PATCH] org-info: Fix html export of info link

* org-info.el (org-info-map-node-url): New defun.
(org-info-export): Use the new function.
---
 lisp/org-info.el | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/lisp/org-info.el b/lisp/org-info.el
index cbe4289fc..821348b61 100644
--- a/lisp/org-info.el
+++ b/lisp/org-info.el
@@ -113,6 +113,24 @@ See `org-info-emacs-documents' and 
`org-info-other-documents' for details."
((cdr (assoc filename org-info-other-documents)))
(t (concat filename ".html"
 
+(defun org-info-map-anchor-url (node)
+  "Return URL associated to Info NODE."
+  ;; See (info "(texinfo) HTML Xref Node Name Expansion") for the
+  ;; expansion rule
+  (let* ((node (replace-regexp-in-string "[ \t\n\r]+" " " (org-trim node)))
+ (node (mapconcat (lambda (c)
+(if (string-match "[a-zA-Z0-9 ]" (string c))
+(string c)
+  (format "_%04x" c)))
+  (string-to-list node) ""))
+ (node (replace-regexp-in-string " " "-" node))
+ (url (if (string= node "")
+ ""
+   (if (string-match "[0-9]" (substring node 0 1))
+   (concat "g_t" node)
+ node
+url))
+
 (defun org-info-export (path desc format)
   "Export an info link.
 See `org-link-parameters' for details about PATH, DESC and FORMAT."
@@ -123,7 +141,7 @@ See `org-link-parameters' for details about PATH, DESC and 
FORMAT."
  (node (or (match-string 2 path) "Top")))
   (format "%s"
  (org-info-map-html-url filename)
- (replace-regexp-in-string " " "-" node)
+ (org-info-map-anchor-url node)
  (or desc path)
 
 (provide 'org-info)
-- 
2.11.0



Re: [O] [PATCH] org-info: Fix docstring

2016-12-14 Thread Chunyang Xu

Nicolas Goaziou writes:

> Hello,
>
> Chunyang Xu <m...@xuchunyang.me> writes:
>
>> Never mind. The first patch was incorrect. I have attached a new
>> patch.
>
> Thank you. Since that docstring was badly formatted, I applied your
> suggestion along with other changes.

No problem at all. Thank you for your work.

> Regards,






Re: [O] [PATCH] org-info: Fix docstring

2016-12-14 Thread Chunyang Xu

Never mind. The first patch was incorrect. I have attached a new patch.

>From 7c5ee47741f1a9cbdb6b2df8ddad99aa95cb01e5 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <m...@xuchunyang.me>
Date: Thu, 15 Dec 2016 03:19:08 +0800
Subject: [PATCH] org-info: Fix docstring

* lisp/org-info.el (org-info-map-html-url): Fix docstring, there is no
  `org-info-official-gnu-document' anymore.
---
 lisp/org-info.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-info.el b/lisp/org-info.el
index d82168e..3b363f0 100644
--- a/lisp/org-info.el
+++ b/lisp/org-info.el
@@ -105,7 +105,7 @@ converted to use these URL's.")
 (defun org-info-map-html-url (filename)
   "Given info FILENAME, either return it (plus '.html' suffix added) or convert
 it to URL pointing to the official page on internet, e.g., use gnu.org for all
-emacs related documents. See `org-info-official-gnu-document' and
+emacs related documents. See `org-info-emacs-documents' and
 `org-info-other-documents' for details."
   (if (member filename org-info-emacs-documents)
   (format "http://www.gnu.org/software/emacs/manual/html_mono/%s.html;
-- 
2.10.2


Chunyang Xu writes:

> User-agent: mu4e 0.9.18; emacs 25.1.1
> * lisp/org-info.el (org-info-map-html-url): Fix docstring, there is no
>   `org-info-official-gnu-document' anymore.
> ---
>  lisp/org-info.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lisp/org-info.el b/lisp/org-info.el
> index d82168e..a0d9e8a 100644
> --- a/lisp/org-info.el
> +++ b/lisp/org-info.el
> @@ -105,7 +105,7 @@ converted to use these URL's.")
>  (defun org-info-map-html-url (filename)
>"Given info FILENAME, either return it (plus '.html' suffix added) or 
> convert
>  it to URL pointing to the official page on internet, e.g., use gnu.org for 
> all
> -emacs related documents. See `org-info-official-gnu-document' and
> +emacs related documents. See `org-info-other-documents' and
>  `org-info-other-documents' for details."
>(if (member filename org-info-emacs-documents)
>(format "http://www.gnu.org/software/emacs/manual/html_mono/%s.html;



[O] [PATCH] org-info: Fix docstring

2016-12-14 Thread Chunyang Xu
User-agent: mu4e 0.9.18; emacs 25.1.1
* lisp/org-info.el (org-info-map-html-url): Fix docstring, there is no
  `org-info-official-gnu-document' anymore.
---
 lisp/org-info.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-info.el b/lisp/org-info.el
index d82168e..a0d9e8a 100644
--- a/lisp/org-info.el
+++ b/lisp/org-info.el
@@ -105,7 +105,7 @@ converted to use these URL's.")
 (defun org-info-map-html-url (filename)
   "Given info FILENAME, either return it (plus '.html' suffix added) or convert
 it to URL pointing to the official page on internet, e.g., use gnu.org for all
-emacs related documents. See `org-info-official-gnu-document' and
+emacs related documents. See `org-info-other-documents' and
 `org-info-other-documents' for details."
   (if (member filename org-info-emacs-documents)
   (format "http://www.gnu.org/software/emacs/manual/html_mono/%s.html;
-- 
2.10.2





[O] [PATCH] org-mac-link: Add autoload cookies for all commands

2016-11-19 Thread Chunyang Xu
Hi,

I would like to add autoload cookies for commands in org-mac-link.el, so
I don't have to autoload them manually in my init.el.

>From 5e00fa82001b57051770f0e4854e03ece39cc68d Mon Sep 17 00:00:00 2001
From: Chunyang Xu <m...@xuchunyang.me>
Date: Wed, 16 Nov 2016 21:30:13 +0800
Subject: [PATCH] org-mac-link: Add autoload cookies for all commands

---
 contrib/lisp/org-mac-link.el | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index ae2def3..f8a44c7 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -233,6 +233,7 @@
   (setq return (shell-command-to-string cmd))
   (concat "\"" (org-trim return) "\""
 
+;;;###autoload
 (defun org-mac-grab-link ()
   "Prompt for an application to grab a link from.
 When done, go grab the link, and insert it at point."
@@ -340,11 +341,13 @@ The links are of the form ::split::."
 	   "return links as string\n"
 (car (split-string result "[\r\n]+" t
 
+;;;###autoload
 (defun org-mac-firefox-get-frontmost-url ()
   (interactive)
   (message "Applescript: Getting Firefox url...")
   (org-mac-paste-applescript-links (org-as-mac-firefox-get-frontmost-url)))
 
+;;;###autoload
 (defun org-mac-firefox-insert-frontmost-url ()
   (interactive)
   (insert (org-mac-firefox-get-frontmost-url)))
@@ -378,11 +381,13 @@ The links are of the form ::split::."
 (replace-regexp-in-string
  "\s+-\s+Vimperator" "" (car (split-string result "[\r\n]+" t)
 
+;;;###autoload
 (defun org-mac-vimperator-get-frontmost-url ()
   (interactive)
   (message "Applescript: Getting Vimperator url...")
   (org-mac-paste-applescript-links (org-as-mac-vimperator-get-frontmost-url)))
 
+;;;###autoload
 (defun org-mac-vimperator-insert-frontmost-url ()
   (interactive)
   (insert (org-mac-vimperator-get-frontmost-url)))
@@ -408,11 +413,13 @@ The links are of the form ::split::."
 (replace-regexp-in-string
  "^\"\\|\"$" "" (car (split-string result "[\r\n]+" t)
 
+;;;###autoload
 (defun org-mac-chrome-get-frontmost-url ()
   (interactive)
   (message "Applescript: Getting Chrome url...")
   (org-mac-paste-applescript-links (org-as-mac-chrome-get-frontmost-url)))
 
+;;;###autoload
 (defun org-mac-chrome-insert-frontmost-url ()
   (interactive)
   (insert (org-mac-chrome-get-frontmost-url)))
@@ -430,12 +437,14 @@ The links are of the form ::split::."
 "	return theUrl & \"::split::\" & theName & \"\n\"\n"
 "end tell\n")))
 
+;;;###autoload
 (defun org-mac-safari-get-frontmost-url ()
   (interactive)
   (message "Applescript: Getting Safari url...")
   (org-mac-paste-applescript-links 
(org-as-mac-safari-get-frontmost-url)))
 
+;;;###autoload
 (defun org-mac-safari-insert-frontmost-url ()
   (interactive)
   (insert (org-mac-safari-get-frontmost-url)))
@@ -461,11 +470,13 @@ The links are of the form ::split::."
 "	return theLinkList as string\n"
 "end tell")))
 
+;;;###autoload
 (defun org-mac-together-get-selected ()
   (interactive)
   (message "Applescript: Getting Togther items...")
   (org-mac-paste-applescript-links (as-get-selected-together-items)))
 
+;;;###autoload
 (defun org-mac-together-insert-selected ()
   (interactive)
   (insert (org-mac-together-get-selected)))
@@ -486,11 +497,13 @@ The links are of the form ::split::."
 " return links as string\n"
 "end tell\n")))
 
+;;;###autoload
 (defun org-mac-finder-item-get-selected ()
   (interactive)
   (message "Applescript: Getting Finder items...")
   (org-mac-paste-applescript-links (as-get-selected-finder-items)))
 
+;;;###autoload
 (defun org-mac-finder-insert-selected ()
   (interactive)
   (insert (org-mac-finder-item-get-selected)))
@@ -516,11 +529,13 @@ The links are of the form ::split::."
 "	return links as string\n"
 "end tell\n")))
 
+;;;###autoload
 (defun org-mac-addressbook-item-get-selected ()
   (interactive)
   (message "Applescript: Getting Address Book items...")
   (org-mac-paste-applescript-links (as-get-selected-addressbook-items)))
 
+;;;###autoload
 (defun org-mac-addressbook-insert-selected ()
   (interactive)
   (insert (org-mac-addressbook-item-get-selected)))
@@ -572,11 +587,13 @@ The links are of the form ::split::."
 "end tell\n"
 "return theLink as string\n")))
 
+;;;###autoload
 (defun org-mac-skim-get-page ()
   (interactive)
   (message "Applescript: Getting Skim page link...")
   (org-mac-paste-applescript-links (as-get-skim-page-link)))
 
+;;;###autoload
 (defun org-mac-skim-insert-page ()
   (interactive)
   (insert (org-mac

Re: [O] Bug: No 'make uninstall' [9.0 (release_9.0 @ /home/xcy/src/org-mode/lisp/)]

2016-11-06 Thread Chunyang Xu
"make clean-install" does what I want.  Thanks.

On Mon, Nov 7, 2016 at 6:09 AM, Nicolas Goaziou <m...@nicolasgoaziou.fr> wrote:
> Hello,
>
> Chunyang Xu <xuchunyang...@gmail.com> writes:
>
>> I just install Org into /usr/local/share via
>> 'make && sudo make install', then I realize that I don't
>> need this and want to uninstall, but there is no uninstall rule. I am
>> going to delete these files and update infodir manually, which is not
>> very easy.
>>
>> Is it possible to provide a uninstall rule?
>
> There is "make clean-install". It might do what you are looking for.
>
> Regards,
>
> --
> Nicolas Goaziou



[O] Bug: No 'make uninstall' [9.0 (release_9.0 @ /home/xcy/src/org-mode/lisp/)]

2016-11-06 Thread Chunyang Xu
I just install Org into /usr/local/share via
'make && sudo make install', then I realize that I don't
need this and want to uninstall, but there is no uninstall rule. I am
going to delete these files and update infodir manually, which is not
very easy.

Is it possible to provide a uninstall rule?



Re: [O] Provide rsync access to Org ELPA

2016-07-03 Thread Chunyang Xu
On Sun, Jul 3, 2016 at 12:24 AM, Achim Gratz <strom...@nexgo.de> wrote:
> Chunyang Xu writes:
>> rsync access would allow people to efficiently mirror Org ELPA
>> [http://orgmode.org/elpa/]. Please provide rsync access to it.
>
> Git transport is more efficient than rsync.

All files we need to sync is under http://orgmode.org/elpa/, did you
suggest these files belong to a git repo?

I don't build elpa packages locally from org-mode git repo is because
I don't know if it's possible and how, and downloading them directly
through HTTP is easy. And comparing to HTTP, rsync is easier and more
efficient. As far as I know, setting up a rsync daemon is easy.

>
> Regards,
> Achim.
> --
> +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
>
> Wavetables for the Terratec KOMPLEXER:
> http://Synth.Stromeko.net/Downloads.html#KomplexerWaves
>
>



[O] Provide rsync access to Org ELPA

2016-07-02 Thread Chunyang Xu
Hello all,

rsync access would allow people to efficiently mirror Org ELPA
[http://orgmode.org/elpa/]. Please provide rsync access to it.

Thanks.

Chunyang



[O] [PATCH] org-capture: Adapt user-error for aborting by user

2016-05-01 Thread Chunyang Xu

Hi,

Sometimes I turn on lisp debugger with M-x toggle-debug-on-error for
some reason, then aborting org-capture with 'q' or 'C-g' enters the
debugger, which is annoying. I think `user-error' is better than `error'
in this case.

>From 9d950e96c48b8e1a0dad779cdf34a4f8a76621db Mon Sep 17 00:00:00 2001
From: Chunyang Xu <xuchunyan...@gmail.com>
Date: Sun, 1 May 2016 12:47:14 +0800
Subject: [PATCH] org-capture: Adapt user-error for aborting by user

When `org-capture` is aborted by user with 'q' or 'C-g', `user-error' is
better than `error' to use to exit.
---
 lisp/org-capture.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 008f0a6..34a6817 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -590,7 +590,7 @@ of the day at point (if any) or the current HH:MM time."
((equal entry "C")
 	(customize-variable 'org-capture-templates))
((equal entry "q")
-	(error "Abort"))
+	(user-error "Abort"))
(t
 	(org-capture-set-plist entry)
 	(org-capture-get-template)
@@ -1504,7 +1504,7 @@ only the bare key is returned."
 	(setq pressed (char-to-string (read-char-exclusive
 	  (when (equal pressed "\C-g")
 	(kill-buffer buffer)
-	(error "Abort"))
+	(user-error "Abort"))
 	  (when (and (not (assoc pressed table))
 		 (not (member pressed des-keys))
 		 (assoc pressed specials))
-- 
2.8.0