[O] Use headings in sitemap

2016-09-28 Thread Thibault Marin

Hi list,

I would like to generate a sitemap for a published website and use it to extract
the last few entries in a specific folder to put on the main page.

The site structure looks like:
.
├── index.org
├── posts
│   ├── A.org
│   ├── B.org
│   └── C.org
├── misc
│   ├── page.org
│   └── other-page.org
└── sitemap.org

In index.org, I would have:
#+begin_src org
#+INCLUDE: sitemap.org::*posts :lines "-10" :only-contents t
#+end_src
to include links to the 10 most recent pages in =posts= (I use
:sitemap-sort-files anti-chronologically in the project setup).  If I am not
missing anything, this requires the sitemap.org file to have a =posts= heading,
but the `org-publish-org-sitemap' function only produces a list of pages.

If there is no better way to get this to work, I would like to propose a patch
to `org-publish-org-sitemap' to produce headings in the sitemap file when a new
parameter is passed and non-nil.  The attached patch is my first attempt at it,
it works for my tests.

I would be interested to hear people's opinion on this:
- Is there a better way to achieve what I want?
- Is the proposed patch acceptable?  Any comments would be appreciated.

Thanks in advance.
thibault

>From a9ae0ecc623d2794475f3481765c637447f1ab24 Mon Sep 17 00:00:00 2001
From: thibault 
Date: Wed, 28 Sep 2016 22:47:48 -0500
Subject: [PATCH] ox-publish.el: Option to use headings instead of list in
 sitemap

* list/ox-publish.el (org-publish-org-sitemap): Add an optional
parameter allowing generation of a sitemap composed of headings
instead of list items.
---
 lisp/ox-publish.el | 39 ---
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index 14c93b2..ceb0673 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -716,15 +716,17 @@ If `:auto-sitemap' is set, publish the sitemap too.  If
 	  ((functionp fun) (funcall fun project-plist
   (org-publish-write-cache-file
 
-(defun org-publish-org-sitemap (project  sitemap-filename)
+(defun org-publish-org-sitemap
+(project  sitemap-filename use-headings)
   "Create a sitemap of pages in set defined by PROJECT.
 Optionally set the filename of the sitemap with SITEMAP-FILENAME.
-Default for SITEMAP-FILENAME is `sitemap.org'."
+Default for SITEMAP-FILENAME is `sitemap.org'.  When USE-HEADINGS
+is nil (default), the sitemap produced is a list, otherwise it
+uses headings."
   (let* ((project-plist (cdr project))
 	 (dir (file-name-as-directory
 	   (plist-get project-plist :base-directory)))
 	 (localdir (file-name-directory dir))
-	 (indent-str (make-string 2 ?\ ))
 	 (exclude-regexp (plist-get project-plist :exclude))
 	 (files (nreverse
 		 (org-publish-get-base-files project exclude-regexp)))
@@ -736,7 +738,18 @@ Default for SITEMAP-FILENAME is `sitemap.org'."
 	 (sitemap-sans-extension
 	  (plist-get project-plist :sitemap-sans-extension))
 	 (visiting (find-buffer-visiting sitemap-filename))
-	 file sitemap-buffer)
+	 file sitemap-buffer
+	 (entry-string
+	  (if use-headings
+	  `((indent . ,(make-string 1 ?*))
+		(char-space . " "))
+	  `((indent . ,(make-string 2 ?\ ))
+		(char-space . " + "
+	 (entry-string-indent (cdr (assq 'indent entry-string)))
+	 (entry-string-char (string-to-char
+			 (substring entry-string-indent 0 1)))
+	 (entry-string-indent-char (cdr (assq 'char-space entry-string)))
+	 (indent-str entry-string-indent))
 (with-current-buffer
 	(let ((org-inhibit-startup t))
 	  (setq sitemap-buffer
@@ -758,7 +771,7 @@ Default for SITEMAP-FILENAME is `sitemap.org'."
  (file-name-directory link)))
 	  (unless (string= localdir oldlocal)
 		(if (string= localdir dir)
-		(setq indent-str (make-string 2 ?\ ))
+		(setq indent-str entry-string-indent)
 		  (let ((subdirs
 			 (split-string
 			  (directory-file-name
@@ -767,16 +780,18 @@ Default for SITEMAP-FILENAME is `sitemap.org'."
 			(subdir "")
 			(old-subdirs (split-string
   (file-relative-name oldlocal dir) "/")))
-		(setq indent-str (make-string 2 ?\ ))
+		(setq indent-str entry-string-indent)
 		(while (string= (car old-subdirs) (car subdirs))
-		  (setq indent-str (concat indent-str (make-string 2 ?\ )))
+		  (setq indent-str (concat indent-str entry-string-indent))
 		  (pop old-subdirs)
 		  (pop subdirs))
 		(dolist (d subdirs)
 		  (setq subdir (concat subdir d "/"))
-		  (insert (concat indent-str " + " d "\n"))
+		  (insert (concat indent-str entry-string-indent-char d "\n"))
 		  (setq indent-str (make-string
-	(+ (length indent-str) 2) ?\ )))
+	(+ (length indent-str)
+	   (length entry-string-indent))
+	entry-string-char)))
 	;; This is common to 'flat and 'tree
 	(let ((entry
 		   (org-publish-format-file-entry
@@ -784,12 +799,14 @@ Default for SITEMAP-FILENAME is `sitemap.org'."
 		  (regexp 

Re: [O] Cask-initialize messes up org table manipulation commands

2016-09-28 Thread Adam Porter
Heikki Lehvaslaiho  writes:

> The cell content disappears but to my surprise the cursor jumped out
> of the table! Trying with different tables, it came clear that the
> cursor always jumped one line down and left of the table). (Under the
> left border if you have a box cursor.) That should not happen!

This may not be much help, because I'm still using Org 8.2.4, but I
tried and was unable to reproduce this; the cursor remains in the table.

> The final twist to this story is that if I start emacs, create an org
> buffer with a table, and run org-table-cut-region key combination
> first before evaling the init.el content, the cursor behaviour does
> not change even after cask has been initialized!

You said you bisected your init file; I assume you used the bug-hunter
package?  If by chance you did it manually instead, I would recommend
doing it again with bug-hunter; maybe you made a tiny mistake that threw
the whole thing off.  :)

Since it doesn't happen with "emacs -Q", I guess it must be someting in
your config.  (Though you might test with "emacs -q" also--there is a
difference.)

I don't use Cask, so I can't help you much there.  What follows is what
may be considered an unhelpful suggestion, but it's the best idea I
have: switch from Cask/Pallet to use-package; it may give you
finer-grained control over your init file, and bisecting may work
better.  I don't know remember how Cask works exactly, but if
cask-initialize "monolithically" loads all the packages you have
configured, I'm guessing you won't be able to bisect within it to figure
out which package is causing the problem.

Hope this helps.




Re: [O] SyncOrg mention in Org manual ?

2016-09-28 Thread Eric Abrahamsen
Benoît Coste  writes:

> Hi,
>
> Last week I published SyncOrg, a fork of MobileOrg for Android. It is
> an open-source app for reading org notes from your Android phone
> (sources are on GitHub). It still needs work but is already up and
> running. The main differences with MobileOrg are a modern UI, the fact
> that it uses Git for synchronization and that it no longer needs emacs
> at all to run.

Sounds great! Will look forward to playing with it. For extra FOSS
points, you could consider putting it in Fdroid repos, too!

Eric




Re: [O] Count words under subtrees

2016-09-28 Thread Adam Porter
Forgive the triple-posting; one of these days I'll learn to wait a bit
longer before sharing.  Anyway, this updated function will avoid
counting the words in drawers and keyword-time lines
(e.g. "SCHEDULED:").

Let me know if you find anything else it needs to handle.  Skipping
source blocks is an idea, but it would be more complex.  This is
probably good enough for most uses.  :)

#+BEGIN_SRC elisp
  (defun org-count-words-in-subtree ()
"Count words in current node and child nodes, excluding heading
  text."
(interactive)
(save-excursion
  (save-restriction
(widen)
(message "%s words in subtree"
 (-sum (org-map-entries (lambda ()
  (outline-back-to-heading)
  (forward-line 1)
  (while (or (looking-at 
org-keyword-time-regexp)
 (org-in-drawer-p))
(forward-line 1))
  (count-words (point)
   (progn
 
(outline-end-of-subtree)
 (point
nil 'tree))
#+END_SRC




Re: [O] Bug: Feature request: more automatic updating of cookies [8.3.6 (8.3.6-4-g4835be-elpaplus @ /home/jorge/.emacs.d/elpa/org-plus-contrib-20160926/)]

2016-09-28 Thread Adam Porter
Jorge  writes:

> I request the feature of Org automatically updating cookies when using
> structure editing commands such as C-c C-x C-w, C-c C-x C-y, ,
>  and friends.  This could be governed by a user option.
>
> The point is that C-u C-c # (to update cookies in the entire buffer) takes
> long enough that I only call it a few times per week.  This means that cookies
> can get out of sync.  Then I try to remember manually invoking C-c # on the
> relevant line every time it goes out of sync, but I sometimes omit it.

Yeah, I have wished for this myself.  It would probably work without too
much overhead to advise the outline-manipulating functions to call
org-update-statistics-cookies afterward.  There might be a few other
functions to advise also to get more complete coverage.




Re: [O] SyncOrg mention in Org manual ?

2016-09-28 Thread Adam Porter
Probably the first place to put it would be on Worg.  :)




Re: [O] Count words under subtrees

2016-09-28 Thread Adam Porter
You might find this useful as well:

#+BEGIN_SRC elisp
(defun count-words-in-subtree-or-region ()
(interactive)
(call-interactively (if (region-active-p)
'count-words-region
  'count-words-in-subtree)))
#+END_SRC

I bound that to M-= in org-mode to replace the default count-words, so
now one command does both.  :)




Re: [O] Count words under subtrees

2016-09-28 Thread Adam Porter
I think this should do it:

#+BEGIN_SRC elisp
  (defun count-words-in-subtree ()
"Count words in current node and child nodes, excluding heading
  text."
(interactive)
(save-excursion
  (save-restriction
(widen)
(message "%s words"
 (-sum (org-map-entries (lambda ()
  (outline-back-to-heading)
  (forward-line 1)
  (count-words (point)
   (progn
 
(outline-end-of-subtree)
 (point
nil 'tree))
#+END_SRC

I haven't tested it extensively, but it seems to work correctly,
counting the current node and any child nodes, but not going into
sibling nodes.  I've been thinking about doing this for a while now, so
thanks for reminding me!  :)

Oh, and it uses the dash.el library, which most Emacs users should
have...




[O] SyncOrg mention in Org manual ?

2016-09-28 Thread Benoît Coste
Hi,

Last week I published SyncOrg
, a fork
of MobileOrg for Android. It is an open-source app for reading org notes
from your Android phone (sources are on GitHub
). It still needs work but is already up
and running. The main differences with MobileOrg are a modern UI, the fact
that it uses Git for synchronization and that it no longer needs emacs at
all to run.

Someone on reddit proposed that it should me mentioned it the org manual,
so here I am. I'll be happy to provide some documentation about it if the
idea gets approved.

Regards,
Benoît


Re: [O] inlinetask with :noexport: seems to be exported?

2016-09-28 Thread Eric S Fraga
On Wednesday, 28 Sep 2016 at 14:03, Rainer M Krug wrote:
> Hi
>
> I wanted to define some inlinetask (works - love it) but want to keep
> most of them in the org file and not export them. Adding :noexport: does
> not work.

What version of org?  It works fine for me with a fairly recent (but not
up to date, maybe a week old) version.

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.1.50.1, Org release_8.3.6-1149-g582233



Re: [O] bug with special entities and (setq org-catch-invisible-edits t)?

2016-09-28 Thread Kaushal Modi
On Wed, Sep 28, 2016 at 3:06 PM John Kitchin 
wrote:

> Hi all,
>
> If I have (setq org-catch-invisible-edits t) and run
> (org-toggle-pretty-entities), then I get an error if I type: F_{A} and
> try to continue typing.
>
> user-error: Edit in invisible region aborted, repeat to confirm with text
> visible
>
> If I set that variable to nil, it works fine, and it also works fine for
> F_A.
>
> This is with:
> Org-mode version 8.3.5 (8.3.5-1-g589e96-elpaplus @
> /Users/jkitchin/vc/jkitchin-github/scimax/elpa/org-plus-contrib-20160822/)
>
>
> Is that a bug, or expected?
>

I would like to know the solution to this too! I faced this just last week.

A workaround was to do "C-q Space" after "F_{A}" instead of just "Space".

I am using almost the latest build of org master branch (updated and built
yesterday).
-- 

Kaushal Modi


[O] bug with special entities and (setq org-catch-invisible-edits t)?

2016-09-28 Thread John Kitchin
Hi all,

If I have (setq org-catch-invisible-edits t) and run
(org-toggle-pretty-entities), then I get an error if I type: F_{A} and
try to continue typing.

user-error: Edit in invisible region aborted, repeat to confirm with text 
visible

If I set that variable to nil, it works fine, and it also works fine for
F_A.

This is with:
Org-mode version 8.3.5 (8.3.5-1-g589e96-elpaplus @ 
/Users/jkitchin/vc/jkitchin-github/scimax/elpa/org-plus-contrib-20160822/)


Is that a bug, or expected?

Thanks,



-- 
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



[O] Bug: org-refile, org-archive-subtree and footnotes [8.3.6 (8.3.6-4-g4835be-elpaplus @ /home/jorge/.emacs.d/elpa/org-plus-contrib-20160926/)]

2016-09-28 Thread Jorge
Start Emacs with an empty init file and make the following customizations:

- org-log-refile :: 'time
- org-refile-targets :: (("/tmp/b.org" :maxlevel . 1))
- org-refile-use-outline-path :: 'file

Create an Org buffer named a.org with the following content:
--8<---cut here---start->8---
* My pets
** Rex
   Given to me by Theresa.[fn:1]
* Footnotes

[fn:1] A work colleague.
--8<---cut here---end--->8---

Create an Org file named /tmp/b.org with the following content:
--8<---cut here---start->8---
* Her pets
--8<---cut here---end--->8---

In buffer a.org, with point in Rex, type:
C-c C-w b.org/Her pets/ 
M-x org-lint

org-lint complains:
 4 high  No reference for footnote definition [fn:1]

A similar problem occurs if the entry is archived with org-archive-subtree.  I
expected Org to automatically detect the footnote inconsistency, without me
manually invoking org-lint.  Even better would be to fix it, e.g. offer to move
the footnote definition if there are no other references in the current buffer.

Now move to the Footnotes section and refile it to b.org (top level).
Then on b.org invoke M-x org-lint.  It complains:
 5 high  Extraneous elements in footnote section
I expected either org-refile to omit the timestamp when refiling the footnotes
section (to placate org-lint) or org-lint not to complain about the timestamp.

Thank you.  Regards.

Emacs  : GNU Emacs 25.1.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.18.9)
 of 2016-09-18
Package: Org-mode version 8.3.6 (8.3.6-4-g4835be-elpaplus @
/home/jorge/.emacs.d/elpa/org-plus-contrib-20160926/)

current state:
==
(setq
 org-tab-first-hook '(org-hide-block-toggle-maybe
 org-babel-hide-result-toggle-maybe
 org-babel-header-arg-expand)
 org-speed-command-hook '(org-speed-command-default-hook
 org-babel-speed-command-hook)
 org-occur-hook '(org-first-headline-recenter)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-html-format-drawer-function '(lambda (name contents)
  contents)
 org-latex-format-inlinetask-function
'org-latex-format-inlinetask-default-function
 org-confirm-shell-link-function 'yes-or-no-p
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-latex-format-headline-function 'org-latex-format-headline-default-function
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-latex-format-drawer-function '(lambda (name contents)
   contents)
 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 '(#[nil "\300\301\302\303\304$\207"
  [org-add-hook change-major-mode-hook
   org-show-block-all append local]
  5]
#[nil "\300\301\302\303\304$\207"
  [org-add-hook change-major-mode-hook
   org-babel-show-result-all append local]
  5]
org-babel-result-hide-spec
org-babel-hide-all-hashes org-eldoc-load)
 org-refile-targets '(("/tmp/b.org" :maxlevel . 1))
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-ascii-format-drawer-function '(lambda
   (name contents width)
   contents)
 org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point
 org-babel-execute-safely-maybe)
 org-refile-use-outline-path 'file
 org-cycle-hook '(org-cycle-hide-archived-subtrees
 org-cycle-hide-drawers
 org-cycle-show-empty-lines
 org-optimize-window-after-visibility-change)
 org-log-refile 'time
 org-confirm-elisp-link-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-html-format-headline-function 'org-html-format-headline-default-function
 org-html-format-inlinetask-function
'org-html-format-inlinetask-default-function
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 )

-- 
• I am Brazilian.  I hope my English is correct and I welcome corrections.
• Please adopt free formats like PDF, ODF, Org, LaTeX, Opus, WebM and 7z.
• Free (as in free speech) software for Android: https://f-droid.org/



[O] strange fontification problem with octave src block

2016-09-28 Thread Eric S Fraga
I have a strange problem (which is only a minor annoyance so not deal
breaking): the fontification of src blocks differs from what it looks
like when editing the src block.

See attached image and, specifically, the "The" immediately after the
single quote in the first line.  It is correctly coloured in the edit
window but not in the original org file (whether being edited or not).

Any ideas?

Thanks,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.1.50.1, Org release_8.3.6-1149-g582233


Re: [O] How to report more than two dozen small problems with Org's documentation?

2016-09-28 Thread Nicolas Goaziou
Hello,

Jorge  writes:

> Hello.  I have noted a number (more than two dozen) of small problems with
> Org's documentation.  For example, the docstring of org-cut-special mentions
> `org-table-copy' where the correct would be `org-table-cut-region'.

This one was fixed recently.

> Should I report one bug for all the documentation problems, or one bug for 
> each
> affected manual section or docstring, or something else?

It is enough to report them all in one single message.

Thank you!


Regards,

-- 
Nicolas Goaziou



Re: [O] inlinetask with :noexport: seems to be exported?

2016-09-28 Thread Nicolas Goaziou
Hello,

Rainer M Krug  writes:

> I wanted to define some inlinetask (works - love it) but want to keep
> most of them in the org file and not export them. Adding :noexport: does
> not work.

FWIW, I cannot reproduce it. I tested with the following document, after
evaluating (require 'org-inlinetask).

--8<---cut here---start->8---
* Foo

Foo

*** Begin :noexport:
Bar
*** END
--8<---cut here---end--->8---


Regards,

-- 
Nicolas Goaziou



[O] inlinetask with :noexport: seems to be exported?

2016-09-28 Thread Rainer M Krug
Hi

I wanted to define some inlinetask (works - love it) but want to keep
most of them in the org file and not export them. Adding :noexport: does
not work.

Is there a way of not exporting selected inlinetasks?

Thanks

Rainer


-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982


signature.asc
Description: PGP signature


[O] How to report more than two dozen small problems with Org's documentation?

2016-09-28 Thread Jorge
Hello.  I have noted a number (more than two dozen) of small problems with
Org's documentation.  For example, the docstring of org-cut-special mentions
`org-table-copy' where the correct would be `org-table-cut-region'.

Should I report one bug for all the documentation problems, or one bug for each
affected manual section or docstring, or something else?

Regards

-- 
• I am Brazilian.  I hope my English is correct and I welcome corrections.
• Please adopt free formats like PDF, ODF, Org, LaTeX, Opus, WebM and 7z.
• Free (as in free speech) software for Android: https://f-droid.org/