Re: [O] overlay showing computed value of macro?

2018-11-23 Thread Matt Price
OH man, I know this is a lot of replies to my own thread.  Sorry for the
noise. I just wanted to point out something I somehow failed to see as I
was pretending to cook Thanksgiving dinner while working on this project
(!!) -- my code does just fine producing overlays, which might be useful to
some people, but it does not really help with my own need, which is to
calculate timestamp values based on the position of the macro call in the
buffer.  That's because I'm using a function that searches backwards for
previous timestames, and the overlays are of course *not part of the buffer
string*, so they don't get picked up by regexp-search-backward.

To fix this I replaced my original function with a group of functions that
searches the buffer string *and* the overlays, looking for a timestamp
regep.  For the overlays, I endedu p writing a recursive function cause I
oculdn't think howelse to do it.

This is all much more verbose than my original function and I think pretty
inelegant but I would be interested to hear what others htink.

Here's the original function, which doesn't look for overlays:

(defun get-ts+7 (&optional weekly-times)
  "Return a string of the form <%Y-%m-d %a> where the date
elements are 7 days later than the (n - WEEKLY-TIMES timestamp)
in the buffer. That is, if WEEKLY-TIMES is nil or 1, return a
date one week later than the *PREVIOUS* timestamp. If
WEEKLY-TIMES is 2, return a time one week later than the
*SECOND-TO-LAST* timestamp above the previous location.

If there are not enough timestamps, right now it returns the last
found timestamp. "
  (interactive)
  (setq weekly-times (or weekly-times 1))
  (defun ts-search ()
(save-match-data
  (goto-char (re-search-backward
  (org-re-timestamp 'all) nil t))
  (let ((thismatch  (match-string 0)))
(message "match: %s" thismatch)
thismatch)))
  (let* (r
 (base-date (save-excursion
 (cl-dotimes (time weekly-times r)
   (condition-case nil
   (progn (setq  r (or (ts-search) r))
  (message "r is %s" r))
 (error
  (message "Drat, there were %s timestamps, using
the last one I found."
   (if (= 0 time) "no" time))
  (return r))

(result nil))
(message "base-time is %s" base-date)
(if base-date
(format-time-string "<%Y-%m-%d %a>"
(time-add
 (date-to-time base-date) (days-to-time (1+
7
  "NO PREVIOUS TIMESTAMP") ))
-

and here are the several functions I felt I needed to solve the problem of
searching in 2 dimmensions:


(defun ts-search-both ()
  (save-match-data
(let* ((bufts
(save-match-data
  (set-match-data nil)
  (save-excursion
(re-search-backward
 (org-re-timestamp 'all) nil t)
(if (match-beginning 0)
`(,(match-beginning 0) ,(match-string 0))
  nil
   (ovts (save-match-data (save-excursion  (ts-search-ov)
  (cond
   ((and bufts ovts)
(if (> (car bufts) (car ovts))
(goto-char (car bufts))
(cadr bufts)
  (cadr ovts)))
   (bufts
(goto-char (car bufts))
(cadr bufts))
   (ovts
(goto-char (car ovts))
(cadr ovts))
   (t
(goto-char (point-min)) nil)
   )
  )))

(defun ts-search-ov ()
  (let* ((ovend   (previous-single-char-property-change (point)
'macro-ov-p))
 (ovs (overlays-at ovend))
 (m  (cl-loop for o in ovs
  if (string-match (org-re-timestamp 'all) (overlay-get
o 'before-string))
  ;;(goto-char (overlay-start o))
  return (match-string 0 (overlay-get o
'before-string)
(cond
 (m `(,(point) ,m))
 ((>= (point-min) ovend )
  (goto-char ovend)
  nil)
 (t
  (goto-char ovend)
  (ts-search-ov))
  )))

(defun get-ts+7-inc-ov (&optional weekly-times)
  "Return a string of the form <%Y-%m-d %a> where the date
elements are 7 days later than the (n - WEEKLY-TIMES timestamp)
in the buffer. That is, if WEEKLY-TIMES is nil or 1, return a
date one week later than the *PREVIOUS* timestamp. If
WEEKLY-TIMES is 2, return a time one week later than the
*SECOND-TO-LAST* timestamp above the previous location.

If there are not enough timestamps, right now it returns the last
found timestamp. "
  (interactive)
  (setq weekly-times (or weekly-times 1))

  (let* (r
 (base-date (save-excursion
 (cl-dotimes (time weekly-times r)
   (condition-case nil
   (let ((s (ts-search-both)))
 (if s
 (setq r s)
   

Re: [O] overlay showing computed value of macro?

2018-11-23 Thread Eric S Fraga
Matt,

you might like to have a look at how the n() macro was implemented as it
has some similar goals.  Check out org-macro-initialize-templates and
org-macro--counter-increment.

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.14-1035-gfeb442



Re: [O] overlay showing computed value of macro?

2018-11-23 Thread Matt Price
On Fri, Nov 23, 2018 at 4:32 AM Eric S Fraga  wrote:

> Matt,
>
> you might like to have a look at how the n() macro was implemented as it
> has some similar goals.  Check out org-macro-initialize-templates and
> org-macro--counter-increment.
>

ah.  no stupid searching backwards through the buffer.  just track
everyting in a variable.

that... is smarter.


> --
> Eric S Fraga via Emacs 27.0.50, Org release_9.1.14-1035-gfeb442
>


Re: [O] Change default value of org-refile-use-outline-path?

2018-11-23 Thread Thomas Shannon
I totally understand this point of view.  But I have to tell you that I found 
the refile command to be totally useless when I first started using org-mode.  
It was almost a year before I figured out that this variable had to be 
customized to make it useful.

Yes, this is totally my fault for not reading the manual.  But there was a lot 
to learn and it was a long time before I got around to reading that section.  
Once I tried it and it didn’t do anything I really wanted it to do, it fell off 
my radar as I concentrated on other things.  I’m sure I’m not the only one.

Tom S.

> On Nov 22, 2018, at 12:11 PM, Colin Baxter  wrote:
> 
>> Eric Abrahamsen  writes:
> 
>> Hello, I wonder if there'd be any interest in changing the default
>> value of `org-refile-use-outline-path' to something other than
>> nil? I can't imagine the nil default would be anyone's preference
>> (at least not anyone with more than a handful of headings in a
>> single file). How about 'file as a more user-friendly default?
> 
>> Eric
> 
> Please don't change default values. Users cam always customise the
> variable - I have it set to `file'.
> 




Re: [O] overlay showing computed value of macro?

2018-11-23 Thread Eric S Fraga
On Friday, 23 Nov 2018 at 07:49, Matt Price wrote:
> ah.  no stupid searching backwards through the buffer.  just track
> everyting in a variable.
>
> that... is smarter.

I hadn't looked to see how it was done but I do know that I can usually
learn something from what Nicolas has done!

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.14-1035-gfeb442



[O] [PATCH] don't always restore previous window configuration?

2018-11-23 Thread Matt Price
OH man, that was a little harder than I thought it would be. Does `make
test` randomly checkout a new branch or something?

This patch adds a new long-winded variable `org-src-restore-window-config`,
t by default, which if set to `nil` will inhibit restoration of previous
window config in `org-edit-src-exit`.
I'm afraid I don't really understand the tests and I learn so slowly that I
don't have time to keep trying today.  But hopefully this simple patch is
adequate. I also wrote a changelog entry in my git commit msg, which is
here:

Make restoration of window config optional on exit from src buffer

* org-srce.el (org-src-restore-window-config, org-exit-from-src): New
  variable org-src-restore-window-config allows user to opt out of
  restoring window config when exiting from source buffer with
  org-exit-from-src.




On Fri, Nov 23, 2018 at 1:31 AM Eric S Fraga  wrote:

> On Thursday, 22 Nov 2018 at 14:09, Matt Price wrote:
> > SO far this is working for me but I wondered whether other people would
> > similarly want to change this behaviour and I should put together a
> proper
> > proposal & patch?
>
> Yes, please.  This is becoming more and more necessary as monitors get
> larger.  I am using a very wide (and very nice) 38" monitor at work.  My
> window configuration within a single frame can get quite
> complex.  Having org (and other tools) change this configuration can be
> quite annoying.
>
> --
> Eric S Fraga via Emacs 27.0.50, Org release_9.1.14-1035-gfeb442
>
From 7adeca638eff962770874078822e2a3d23430b2b Mon Sep 17 00:00:00 2001
From: Matt Price 
Date: Fri, 23 Nov 2018 09:16:40 -0500
Subject: [PATCH] Make restoration of window config optional on exit from src
 buffer

* org-srce.el (org-src-restore-window-config, org-exit-from-src): New
  variable org-src-rewtore-window-config allows user to opt out of
  restoring windor config when exiting from source buffer with
  org-exit-from-src.
---
 lisp/org-src.el | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 12163156f..386bad413 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -166,6 +166,14 @@ other-frameUse `switch-to-buffer-other-frame' to display edit buffer.
 	  (const other-window)
 	  (const reorganize-frame)))
 
+(defcustom org-src-restore-saved-window-config t
+  "Whether to restore windows to previous configuration.
+When non-nil (default), on exit from a source buffer, org will
+try to restore the window configuration that was active when
+the source buffer was created."
+  :group 'org-edit-structure
+  :type 'boolean)
+
 (defvar org-src-mode-hook nil
   "Hook run after Org switched a source code snippet to its Emacs mode.
 \\
@@ -1173,8 +1181,8 @@ Throw an error if there is no such buffer."
 ;; Clean up left-over markers and restore window configuration.
 (set-marker beg nil)
 (set-marker end nil)
-(when org-src--saved-temp-window-config
-  (set-window-configuration org-src--saved-temp-window-config)
+(when (and  org-src--saved-temp-window-config org-src-restore-saved-window-config) 
+	  (set-window-configuration org-src--saved-temp-window-config)
   (setq org-src--saved-temp-window-config nil
 
 
-- 
2.19.1



Re: [O] Change default value of org-refile-use-outline-path?

2018-11-23 Thread Samuel Wales
i will be ok with whatever anybody decides about the default, but fwiw
i use nil, which is the default in maint.



[O] Standard Format for Org Outlines?

2018-11-23 Thread David Masterson
Probably a dumb question, but is there a standard format for Org
outlines. I'm particularly wondering about the use of blank lines. I
prefer to have blank lines before my headings for readability, but I
think a lot of other people work without the blank lines.  I recently
ran into a case with BeOrg where it, in fact, removed the blank lines
when it synced my change back to my original file.  That led me to think
what is the standard format for an Org outline.  Should I expect the
tools to adjust to me or should I adjust to them?
--
David



Re: [O] Request on modification of org-element.el

2018-11-23 Thread Qiang Fang
Hello Nicolas,
The complete diff is:

$ ~/src$ git clone https://code.orgmode.org/bzg/org-mode.git
$ cd org-mode
$ git merge origin/wip-cite

Auto-merging testing/lisp/test-org-element.el
Auto-merging lisp/org-element.el
CONFLICT (content): Merge conflict in lisp/org-element.el
Automatic merge failed; fix conflicts and then commit the result.

$ git diff
diff --cc lisp/org-element.el
index cdb574e17,f7498fbd1..0
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@@ -307,12 -322,11 +322,20 @@@ Don't modify it, set `org-element-affil
(strike-through ,@standard-set)
(subscript ,@standard-set)
(superscript ,@standard-set)
++<<< HEAD
 +  ;; Ignore inline babel call and inline source block as formulas
 +  ;; are possible.  Also ignore line breaks and statistics
 +  ;; cookies.
 +  (table-cell bold code entity export-snippet footnote-reference italic
 +latex-fragment link macro radio-target strike-through
 +subscript superscript target timestamp underline verbatim)
++===
+   ;; Ignore inline babel call and inline src block as formulas are
+   ;; possible.  Also ignore line breaks and statistics cookies.
+   (table-cell ,@(append '(export-snippet footnote-reference link macro
+radio-target target timestamp)
+   minimal-set))
++>>> origin/wip-cite
(table-row table-cell)
(underline ,@standard-set)
(verse-block ,@standard-set)))



On Fri, Nov 23, 2018 at 2:32 PM Nicolas Goaziou 
wrote:

> Hello,
>
> Qiang Fang  writes:
>
> > I am a user of kjambunathan's org-mode-ox-odt. The odt exporter needs
> some
> > changed in the upstream org mode. Can you please kindly review the
> > request?
>
> You need to pull again "wip-cite" branch. It was rebased against master
> yesterday. So was "wip-cite-awe".
>
> Regards,
>
> --
> Nicolas Goaziou
>


Re: [O] Request on modification of org-element.el

2018-11-23 Thread Qiang Fang
It's in the "wip-cite" branch. And you can try kjambunathan's odt exporter
with the following setting.

The ODT and JabRef exporters can now be with Emacs Package Mananger's M-x
list-packages. The package is available at
https://raw.githubusercontent.com/kjambunathan/org-mode-ox-odt/master/elpa/.
See below for a typical configuration.

(custom-set-variables
 '(package-archives
   (quote
(("gnu" . "https://elpa.gnu.org/packages/";)
 ("ox-odt" .
"https://raw.githubusercontent.com/kjambunathan/org-mode-ox-odt/master/elpa/";)

When you install ox-odt from the above archive, it will upgrade your Org to
9.1.14, if needed. Once you have installed the ox-odt package and restart
your Emacs. Run M-x locate-library RET org and M-x locate-library RET ox-odt
 and ensure that you see something along the following lines.

Library is file ~/.emacs.d/elpa/org-9.1.14/org.elc
Library is file ~/.emacs.d/elpa/ox-odt-9.1.14.145/ox-odt.elc

After you export an Org file to ODT, look at your *Messages* buffer and
ensure that the ODT exporter *uses` style and schema files from the ELPA
package.


On Fri, Nov 23, 2018 at 2:42 PM Eric S Fraga  wrote:

> On Friday, 23 Nov 2018 at 08:51, Qiang Fang wrote:
> > Hello everyone,
> >
> > I am a user of kjambunathan's org-mode-ox-odt. The odt exporter needs
> some
> > changed in the upstream org mode. Can you please kindly review the
> request?
>
> Out of curiosity, what is the effect of this change specifically?  What
> is minimal-set referenced in the code you suggest?  I cannot find any
> such variable.
>
> --
> Eric S Fraga via Emacs 27.0.50, Org release_9.1.14-1035-gfeb442
>


[O] Bug: Link given to gnuplot-mode is out of date [9.1.9 (release_9.1.9-65-g5e4542 @ /nix/store/x7b40y4pxp69h343akhaj4fb9fspacdq-emacs-26.1.50/share/emacs/26.1.50/lisp/org/)]

2018-11-23 Thread Gemini Lasswell
In the "Requirements" section of ob-gnuplot.el's header comment, the
link given for gnuplot-mode no longer works.  The same broken link is
also present in org-manual.org.

Since gnuplot-mode is available on MELPA, I think the most helpful
advice for people trying to set up org-babel-gnuplot would be to install
it from there.

Emacs  : GNU Emacs 26.1.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2018-10-11
Package: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ 
/nix/store/x7b40y4pxp69h343akhaj4fb9fspacdq-emacs-26.1.50/share/emacs/26.1.50/lisp/org/)



[O] Bug: org export table.el [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.1/lisp/org/)]

2018-11-23 Thread Ulrich G. Wortmann
Dear All,

the following problem occurs reproducibly with  GNU Emacs 26.1 (see below
for details), even when starting emacs with -Q

If I use a table in my org file and convert that table to table.el the
caption is not exported into either the HTML or Latex File. Export to ASCII
works as expected. If I convert the table back to org-table format, the
Latex and HTML export of the caption work as expected. As a side note, any
other #+ expressions (e.g., Latex-Attr, Labels etc) won't be exported
either if the table is in table.el format

Expected behavior: #+CAPTION:  is being exported regardless what table
format has been selected.

#+CAPTION: Test caption on top of table.el
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+
| 6 | 7 | 8 |
+---+---+---+

Cheers

Uli

Emacs  : GNU Emacs 26.1 (build 1, x86_64-suse-linux-gnu, GTK+ Version
3.24.1)
Package: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @
/usr/share/emacs/26.1/lisp/org/)

current state:
==
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
 org-src-mode-configure-edit-buffer)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-html-format-inlinetask-function
'org-html-format-inlinetask-default-function
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 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)
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-bibtex-headline-format-function #[257 "\300 \236A\207" [:title] 3
"\n\n(fn ENTRY)"]
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe
  org-babel-header-arg-expand)
 org-ascii-format-drawer-function #[771 " \207" [] 4 "\n\n(fn NAME CONTENTS
WIDTH)"]
 org-occur-hook '(org-first-headline-recenter)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
  org-cycle-show-empty-lines
  org-optimize-window-after-visibility-change)
 org-speed-command-hook '(org-speed-command-activate
  org-babel-speed-command-activate)
 org-odt-format-inlinetask-function
'org-odt-format-inlinetask-default-function
 org-confirm-shell-link-function 'yes-or-no-p
 org-link-parameters '(("id" :follow org-id-open)
   ("rmail" :follow org-rmail-open :store
org-rmail-store-link)
   ("mhe" :follow org-mhe-open :store org-mhe-store-link)
   ("irc" :follow org-irc-visit :store org-irc-store-link)
   ("info" :follow org-info-open :export org-info-export
:store org-info-store-link)
   ("gnus" :follow org-gnus-open :store
org-gnus-store-link)
   ("docview" :follow org-docview-open :export
org-docview-export :store org-docview-store-link)
   ("bibtex" :follow org-bibtex-open :store
org-bibtex-store-link)
   ("bbdb" :follow org-bbdb-open :export org-bbdb-export
:complete org-bbdb-complete-link :store
org-bbdb-store-link)
   ("w3m" :store org-w3m-store-link) ("file+sys")
   ("file+emacs") ("doi" :follow org--open-doi-link)
   ("elisp" :follow org--open-elisp-link)
   ("file" :complete org-file-complete-link)
   ("ftp" :follow
(lambda (path) (browse-url (concat "ftp:" path
   ("help" :follow org--open-help-link)
   ("http" :follow
(lambda (path) (browse-url (concat "http:" path
   ("https" :follow
(lambda (path) (browse-url (concat "https:" path
   ("mailto" :follow
(lambda (path) (browse-url (concat "mailto:"; path
   ("news" :follow
(lambda (path) (browse-url (concat "news:"; path
   ("shell" :follow org--open-shell-link))
 org-latex-format-headline-function
'org-latex-format-headline-default-function
 org-latex-format-inlinetask-function
'org-latex-format-inlinetask-default-function
 org-html-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-html-format-headline-function
'org-html-format-headline-default-function
 )
-- 

Ulrich Wortmann 416 978 7084

Associate Chair Undergraduate Affairs

Department of Earth Sciences

University of Toronto
22 Russel St., Toronto, ON, Canada, M5S 3B1