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

2017-08-23 Thread Jay Kamat
Hi!

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

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

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

# My Title


## My Subtitle

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

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

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

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

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

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

-Jay

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

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

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

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

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



[O] Questions about using macro replacement

2017-08-23 Thread Joon Ro
Hi,

I have several questions about macro replacement usage.

1. I saw people using {{{n}}} macros, which looks very useful, but I could not 
find it in current documentation about macro replacement 
(http://orgmode.org/manual/Macro-replacement.html). Is this only available in 
developmental version?

2. I was wondering if it is possible use macro expansion for :EXPORT_FILE_NAME: 
property of a subtree?

3. Is it possible to create a file link which uses macro? I would like to 
create a link to the exported pdf file dynamically. For example, if the value 
of :EXPORT_FILE_NAME: is exported, how would I create a link which 
automatically link to exported.pdf?

Any help would be greatly appreciated. Thank you!
Joon



Re: [O] counter macro in dates?

2017-08-23 Thread Adam Porter
Kaushal Modi  writes:

> +1 for tiny :)
>
> When I discovered it, I went a bit overboard and wrote a helper fn
> (modi/tiny-helper in here[1]) so that I don't have to remember the
> tiny syntax. I still use tiny from time to time.
>
> [1]: 
> https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files/setup-tiny.el

That's very cool.  Do you think Oleh would add it to Tiny?




Re: [O] merging subtrees (in a syllabus)

2017-08-23 Thread Matt Price
On Wed, Aug 23, 2017 at 4:55 PM, Kaushal Modi 
wrote:

> On Tue, Aug 22, 2017 at 4:10 PM Matt Price  wrote:
>
>> And then I'd run some elisp that mashes them all up together, and give
>> that to the students, since I think that'll make it easier for them to read.
>>
>> Anyone on the list have any ideas?
>>
>
> How about using plain old #+INCLUDE:
>
> Hmm, Interesting. It's not quite as flexible as I'd like -- what I'd most
prefer to do is to move the discussion topics and labs around arbitrarily
and then have org print things out for me nice and cleanly.  I'm not sure
but maybe something more like this (ends up being a little ugly with all
the crazy counter macros):


* outline
** Week 1
#+INCLUDE: "~/test.org::#topic1"
#+INCLUDE: "~/test.org::#lab1"
* labs :noexport:
*** lab zero 1
:PROPERTIES:
:CUSTOM_ID: lab{{{n(labs)}}}
:END:
* topics  :noexport:
*** topic oh oh one
:PROPERTIES:
:CUSTOM_ID: topic{{{n(topics)}}}
:END:

I'd prefer to have macros in the "Week" headlines and  the #+INCLUDE
statements but macros don't expand in INCLUDES, unfortunately.  This is OK
but still not super-elegant.  Still, definitley better than nothing!



> --
> I don't have a good idea on how to implement the date thing, but I see
> that others have provided some input.
>

I came up with an acceptable solution, bu it's not very sophisticated --
see the other thread...


> --
>
> Kaushal Modi
>


Re: [O] [RFC] Remove Org Struct mode

2017-08-23 Thread Michael Brand
Hi Rasmus

On Wed, Aug 23, 2017 at 9:17 PM, Rasmus  wrote:

> FWIW, I use similar patterns,
>
> ;; outline-regexp: ";;\\*+\\|\\`"
> ;; orgstruct-heading-prefix-regexp: ";;\\*+\\|\\`"

Thank you, I will try that out.

Michael



Re: [O] counter macro in dates?

2017-08-23 Thread Kaushal Modi
On Wed, Aug 23, 2017 at 2:31 AM Adam Porter  wrote:

>
> Apologies to the list for practically spamming this recently, but it
> seems directly relevant:
>
> https://github.com/abo-abo/tiny


+1 for tiny :)

When I discovered it, I went a bit overboard and wrote a helper fn
(modi/tiny-helper in here[1]) so that I don't have to remember the tiny
syntax. I still use tiny from time to time.

[1]:
https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files/setup-tiny.el
-- 

Kaushal Modi


Re: [O] org-protocol: deal with broken links on windows

2017-08-23 Thread Nikolay Kudryavtsev
I've recently set up org-protocol as well and while I can confirm that 
it prepends the full executable path, I don't get the extra "/" and 
org-protocol works fine. And your link worked fine, except that I had to 
obviously change the template name. From what I understand the addition  
of that "/" is extremely weird, since protocol just passes the whole 
string to the command.


What version of org are you using? I'm currently using org-9.0.9 
installed from a zip.


And to be sure maybe you should try something like:

emacsclientw.exe 
"org-protocol:/capture?template=w=http%3A%2F%2Fjira%2Fbrowse%2FSDST-705=SOMETHING="


--
Best Regards,
Nikolay Kudryavtsev




Re: [O] [RFC] Remove Org Struct mode

2017-08-23 Thread Michael Brand
Hi Adam

Thank you for all the explanations that I will study and try later.
Especially the origami package looks very useful to me.

Michael



Re: [O] merging subtrees (in a syllabus)

2017-08-23 Thread Kaushal Modi
On Tue, Aug 22, 2017 at 4:10 PM Matt Price  wrote:

> And then I'd run some elisp that mashes them all up together, and give
> that to the students, since I think that'll make it easier for them to read.
>
> Anyone on the list have any ideas?
>

How about using plain old #+INCLUDE:

Example made up from your examples:

= a.org (for exporting) =
* Outline
** <2017-09-12 Tue> (Week {{{n}}}) Hacking History in the Himalaya
#+INCLUDE: "b.org::#hacking-history-in-the-himalaya-intro" :only-contents t
#+INCLUDE: "b.org::#hacking-history-in-the-himalaya-background"
*** Lab 01: Getting Started
#+INCLUDE: "b.org::#lab-getting-started" :only-contents t
** <2017-09-19 Tue> (Week {{{n}}}) Language of the Web
#+INCLUDE: "b.org::#the-language-of-the-web-intro" :only-contents t
#+INCLUDE: "b.org::#the-language-of-the-web-readings"
*** Lab 02: Understanding HTML
#+INCLUDE: "b.org::#lab-understanding-html" :only-contents t
=

= b.org (for your content development) =
* Discussion Topics
** Hacking History in the Himalaya
*** Intro
:PROPERTIES:
:CUSTOM_ID: hacking-history-in-the-himalaya-intro
:END:
Why we should write history, why everyone should do it, and why that means
we
need the Web.  Hacker cultures, collaborative learning, knowledge sharing,
non-expert culture. And a few words about the world's third-tallest
mountain.
*** Background
:PROPERTIES:
:CUSTOM_ID: hacking-history-in-the-himalaya-background
:END:
- [[
http://www.journalofamericanhistory.org/issues/952/interchange/index.html][JAH
- The Promise of Digital History]]
- [[
http://writinghistory.trincoll.edu/revisioning/tanaka-2012-spring/][Pasts
in a Digital Age]]
** The Language of the Web
*** Intro
:PROPERTIES:
:CUSTOM_ID: the-language-of-the-web-intro
:END:
The Web is written in a language called HTML, with some help from other
lanugages called CSS and Javascript. The nonlinear and interactive
properties of
these languages afford new possibilities for storytelling. We explore how
the
Internet works, and what that means for historical narrative.
*** Readings
:PROPERTIES:
:CUSTOM_ID: the-language-of-the-web-readings
:END:
- Vannevar Bush, "[[
http://www.theatlantic.com/magazine/archive/1969/12/as-we-may-think/3881/][As
We May Think]]"
- Tim Berners-Lee, /Weaving the Web/
[[file:readings/berners-lee-weaving-web.pdf][Ch. 2,4]].
- Edward L. Ayers, "[[http://www.vcdh.virginia.edu/Ayers.OAH.html][History
in Hypertext]]"
- Rus Shuler, "[[
http://www.theshulers.com/whitepapers/internet_whitepaper/index.html][How
Does the Internet Work?]]"
* Labs
** Getting Started
:PROPERTIES:
:CUSTOM_ID: lab-getting-started
:END:
- HTML and Markdown
- Some Tools: Github, Dropbox, Atom Text Editor
- About Our Partners
** Understanding HTML
:PROPERTIES:
:CUSTOM_ID: lab-understanding-html
:END:
*Resources:* [[http://jsbin.com/#html,live][JSBin online HTML/Javascript
editor]]; [[http://codeacademy.net][codeacademy courses]]; [[
http://en.wikipedia.org/wiki/HTML][on
Wikipedia]]; [[http://www.w3.org/MarkUp/Guide/][w3 guide]]; also cf. Zotero
Bibliography

--

Because the course readings and hte lab are often separate, it can be
difficult
and confusing to maintain the course outline in its final form. Id like to
be
able, instead, to maintain the labs and readings separately, and /merge/
them to
produce the final document.  So I'd start with something like this:
=



If it also comes with a thought about how to generate an org date objet
> form an initial seed and a session number, that's be fabulous too.
>

I don't have a good idea on how to implement the date thing, but I see that
others have provided some input.
-- 

Kaushal Modi


[O] org-protocol: deal with broken links on windows

2017-08-23 Thread Ingo Lohmar
Dear all,

It appears that org-capture (with the no-frills, no-extensions method of
adding a registry entry for org-protocol) using new-style links is not
working correctly on Windows (tested with recent Firefoxes as well as
the Chromium derivative Iridium).

What happens is that the browser binary with full path is prepended to
the protocol, and an extra "/" is added before the URL query string.
That is, what *should* read

  
org-protocol:/capture?template=y=http%3A%2F%2Fjira%2Fbrowse%2FSDST-705=SOMETHING

is actually passed as 

  c:/Program 
Files/Iridium/58.0.0.0/org-protocol:/capture/?template=y=http%3A%2F%2Fjira%2Fbrowse%2FSDST-705=SOMETHING

as the FNAME argument to `org-protocol-check-filename-for-protocol'.  I
have no idea what brought about this crazy change, but I've long ago
stopped trying to understand Windows' ways --- nowadays I just lobby
against using it.

Anyway, I've successfully (regular use for several weeks) patched this
with an advice:

>--<

(defun adv/sanitize-broken-windows-link (args)
  (let ((fname (car args)))
(cons
 (if (string-match "^[a-z]:/[-a-zA-Z0-9 
/._]+/\\(org-protocol:/[^/\\?]*\\)/\\(\\?.*\\)$" fname)
 (concat (match-string 1 fname) (match-string 2 fname))
   fname)
 (cdr args
(advice-add #'org-protocol-check-filename-for-protocol :filter-args 
#'adv/sanitize-broken-windows-link)

>--<

I only use this on the Windows machine, where FNAME reliably has the
above form for me (probably better ONLY use it when (eq system-type
'windows-nt)).  Also, the regexp is probably too unspecific even on
Windows.  Could we still add this or an improved transformation of FNAME
to `org-protocol-check-filename-for-protocol' (assuming there's no
better way)?

Thank you!

Ingo



Re: [O] [RFC] Remove Org Struct mode

2017-08-23 Thread Rasmus
Michael Brand  writes:

> orgstruct-mode supports it with orgstruct-heading-prefix-regexp set to
> for example " *;;;* ".

FWIW, I use similar patterns,

;; outline-regexp: ";;\\*+\\|\\`"
;; orgstruct-heading-prefix-regexp: ";;\\*+\\|\\`"

Rasmus

-- 
This is the kind of tedious nonsense up with which I will not put




Re: [O] Old org.el ending up in current tar packages?

2017-08-23 Thread Achim Gratz
Adam Porter writes:
> It seems that org.el in org-20170821.tar is out of date.  Sharon Kimble
> noticed that something was wrong, and after much digging, we found that
> org-clock.el has been updated to have calls to
> org-time-string-to-seconds with 2 arguments, but the function definition
> in org.el only takes 1 argument.
>
> This is very strange, because the addition of the extra arg to
> org-time-string-to-seconds was made back on July 7, and that
> introduced

That change is only on master, so whatever trouble you are seeing in the
ELPA tarball is unrelated to that change.

> a bug which was fixed in org-clock.el on August 5, yet the tarball from
> August 21 has the pre-July 7 org-time-string-to-seconds function.

That fix was introduced on maint and merged to master, which seems to be
in error since the bug was in master only.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada




Re: [O] dynamic date arithmetic in a macro or otherwise (simulating a "date counter")?

2017-08-23 Thread Matt Price
On Tue, Aug 22, 2017 at 8:14 PM, Sacha Chua  wrote:

> org-clone-subtree-with-time-shift might be a good starting point, too. It
> could be interesting to be able to replace dates within text and
> priorities. Good luck!
>

Interesting, I didn't know about `org-clone-subtree-with-time-shjift`.
thank you.

So, cloning isn't necessarily what I'm looking for; I'm often working with
documents that need to be largely reused with modifications. That means
that abo-abo's tiny isn't quite right for me, either.  So I've written the
following; it still feels really clumsy but it seems to work for now! It's
loosely based on some code that Jon Kitchin wrote for me on this list about
2 years ago (!!). Here it is:

#+MACRO: ts (eval (get-ts+7))


#+BEGIN_SRC emacs-lisp
(defun get-ts+7 ()
(interactive)
(let ((base-date (save-excursion
 (re-search-backward
  (org-re-timestamp 'all))
 (match-string 0)))
  (result nil))
  (with-temp-buffer
(org-mode)
(insert base-date )
(backward-char)
(org-timestamp-change 7 'day)
(end-of-buffer)
(insert "  ")
(end-of-buffer)
(setq result (save-excursion
   (re-search-backward
(org-re-timestamp 'all))
   (match-string 0
  result))
#+END_SRC

There's no error-checking, but basically you just insert the date of the
first weekly meeting and all the other dates update themselves
automatically on export.  It's pretty cool.  One next step would be to
allow more complex repetition cycles (e.g., to repeat eveyr tuesday and
thursday, or monday Wednesday Friday, etc.).

So now my headlines all just look like this:

** Week {{{n}}} ({{{ts}}}): Topic

Still working on that tree merge idea, will check back in on that other
thread if I get anywhere with it.

Thanks to both Adam and Sacha for the help! I'd love to hear any other
suggestions people might have.

Matt


[O] bitbucket issues org-sync

2017-08-23 Thread Uwe Brauer
Hi


I just learned there exist
https://github.com/arbox/org-sync

which imports and exports issues from github bb and others to emacs org
mode. Unfortunately for me the import works but not the export. I
already asked the author, but did anybody here try out that package?

Thanks

Uwe Brauer 




Re: [O] [RFC] Remove Org Struct mode

2017-08-23 Thread Adam Porter
Michael Brand  writes:

Hi Michael,

> First thank you for taking over maintenance of outshine.el from
> Thorsten Jolitz.

Well, I figured it was the least I could do, since he's put so much
effort into outshine, outorg, and navi-mode over the years.  Be advised,
although I am now the maintainer, I only comprehend a tiny fraction of
them; I learn more about them when I need to fix something, which so far
has hardly happened.  :)

> How can I collapse block-indented comments like a or b in the following?:
>
> ;; * Org
> (defun foo ()
>   ;; ** a
>   (bar)
>   ;; ** b
>   (beer))
> ;; * Calc
>
> orgstruct-mode supports it with orgstruct-heading-prefix-regexp set to
> for example " *;;;* ".

I don't think this is possible, or at least not easily.  The
outline-regexp variable says:

Regular expression to match the beginning of a heading.
Any line whose beginning matches this regexp is considered to start a heading.
Note that Outline mode only checks this regexp at the start of a line,
so the regexp need not (and usually does not) start with ‘^’.

So I think you would need to modify outline-mode to do this.

However, there are other ways to fold text besides
outline/outline-minor-mode/outshine.  You could probably do it fairly
easily with the origami package.

Or you could do what I do: I modify outline-regexp and outline-level so
that the asterisks aren't even necessary.  Instead, the heading level is
set by how many semicolons there are, e.g.:

;; Regular comment
;;; Heading level 1
 Heading level 2
...

Then any comment that starts with 3 or more semicolons is indented to
the left edge and becomes a collapsible heading, regardless of the
indentation of the code under it.

#+BEGIN_SRC elisp
(defun ap/el-outline-level ()
  (or
   ;; Commented outline heading
   (and (string-match (rx
   (* space)
   (group (one-or-more (syntax comment-start)))
   (one-or-more space))
  (match-string 0))
(- (match-end 0) (match-beginning 0) 1))

   ;; Lisp def heading
   ;; Add 8 (the highest standard outline level) to every keyword
   ;; heading
   (+ 8 (- (match-end 0) (match-beginning 0)

(defun ap/el-mode-outline-hook ()
  (setq outline-level 'ap/el-outline-level)
  (setq outline-regexp "\\(;;[;]\\{1,8\\} \\|\\((defun\\)\\)"))
  
(add-hook 'emacs-lisp-mode-hook 'ap/el-mode-outline-hook)
#+END_SRC

It works well for me, and it doesn't even require outshine IIRC, just
outline-minor-mode.  I've tried to make this work in other languages
too, like using the number of # characters for the outline level in
shell scripts, but I failed miserably, so I use outshine for other
languages.  It's easier in elisp since Emacs already treats
triple-semicolon comments as headings.

> A bit less important for me: How can I turn off syntax highlighting of
> headings, respectively generally in outshine.el?

Well, the first thing that comes to mind is to unset the properties of
the outline-level faces, but I'm not sure if you can do that per-buffer.
So you might try removing the outline-font-lock-keywords or
outline-font-lock-faces.

Hope this helps.

Adam




[O] Old org.el ending up in current tar packages?

2017-08-23 Thread Adam Porter
It seems that org.el in org-20170821.tar is out of date.  Sharon Kimble
noticed that something was wrong, and after much digging, we found that
org-clock.el has been updated to have calls to
org-time-string-to-seconds with 2 arguments, but the function definition
in org.el only takes 1 argument.

This is very strange, because the addition of the extra arg to
org-time-string-to-seconds was made back on July 7, and that introduced
a bug which was fixed in org-clock.el on August 5, yet the tarball from
August 21 has the pre-July 7 org-time-string-to-seconds function.

See
https://github.com/Fuco1/org-clock-budget/issues/5#issuecomment-324331793
for more details.




Re: [O] [RFC] Remove Org Struct mode

2017-08-23 Thread Michael Brand
Hi Adam

First thank you for taking over maintenance of outshine.el from Thorsten Jolitz.

On Wed, Aug 23, 2017 at 1:33 PM, Adam Porter  wrote:
> Rasmus  writes:
>
>> I also would like to see a minor-mode for Org-like cycling when using
>> outline-minor-mode, as I use this feature in init.el.
>
> Outshine provides this feature.  In my init file, I have headers like:
>
>  Org
>
> And when I press TAB with point on that line, it collapses everything
> between it and the next header.

How can I collapse block-indented comments like a or b in the following?:

;; * Org
(defun foo ()
  ;; ** a
  (bar)
  ;; ** b
  (beer))
;; * Calc

orgstruct-mode supports it with orgstruct-heading-prefix-regexp set to
for example " *;;;* ".

A bit less important for me: How can I turn off syntax highlighting of
headings, respectively generally in outshine.el?

Michael



Re: [O] [RFC] Remove Org Struct mode

2017-08-23 Thread Adam Porter
Rasmus  writes:

> I also would like to see a minor-mode for Org-like cycling when using
> outline-minor-mode, as I use this feature in init.el.

Outshine provides this feature.  In my init file, I have headers like:

 Org

And when I press TAB with point on that line, it collapses everything
between it and the next header.




Re: [O] [RFC] Remove Org Struct mode

2017-08-23 Thread Rasmus
Hi Nicolas,

Thanks for bringing this up.

> I would like to remove Org Struct minor mode from Org code base. Here is
> the rationale:

Ugh, I use it in init.el and for emails, but it doesn’t work great in
message-mode anyway.  I miss list handling.  Supposedly, you can get Emacs
to handle lists, but I never got it working.

I have looked at the org-struct code at some occasions, and it looks like
voodoo.  As such, I support the removal of org-struct.

I would like to see a minor-mode for handling lists as well (for emails
and plainer text than Org).  While it sounds like an interesting task to
look into simplifying the relevant parts of org-list.el, I don’t think I
will be able to find the time to do this.

I also would like to see a minor-mode for Org-like cycling when using
outline-minor-mode, as I use this feature in init.el.

Regards,
Rasmus

-- 
When in doubt, do it!




[O] Date ranges displayed in the agenda

2017-08-23 Thread Manuel Wiesinger
Hi,

when a headline starts with a date range, in the agenda it is displayed
as part of the headline . When a headline starts with an normal date,
the date is not displayed. For is example the following

* <2017-08-23 Wed>--<2017-08-24 Thu> Test range
* <2017-08-23 Wed> Test date

is displayed like this:

Wednesday  23 August 2017
  testing:(1/2):  <2017-08-23 Wed>--<2017-08-24 Thu> Test range
  testing: Test date
Thursday   24 August 2017
  testing:(2/2):  <2017-08-23 Wed>--<2017-08-24 Thu> Test range

Personally, to me as rather new user, this feels inconsistent. Is it
expected behaviour or a bug?

I experienced this with Org mode version 9.0.9 and 8.2.10. To make sure
it's not configuration I checked with emacs -q.

Manuel



Re: [O] [PATCH] org-agenda: Add 'none setting for org-agenda-overriding-header

2017-08-23 Thread Nicolas Goaziou
Adam Porter  writes:

> Here are the patches.  Please let me know if any other changes are
> needed.

Thank you! Comments follow.

> +(defmacro org-agenda--insert-overriding-header ( default)

There is no "" in `defmacro'.

It should be (default).

> +  "Insert header into agenda view depending on value of 
> `org-agenda-overriding-header'.
> +If the empty string, don't insert a header.  If any other string,
> +insert it as a header.  If nil, insert DEFAULT, which should
> +evaluate to a string."
> +  (declare (debug ( form)))

It needs to be updated according to the above.

> + ;; Format week number span
> + (cond ((< (- d2 d1) 350)
> +(if (= w1 w2)
> +(format " (W%02d)" w1)
> +  (format " (W%02d-W%02d)" w1 w2)))
> +   (t ""))

  (cond ((<= 350 (- d2 d1)) "")
((= w1 w2) (format " (W%02d)" w1))
(t (format " (W%02d-W%02d)" w1 w2)))

> - (let ((n 0) s)
> -   (mapc (lambda (x)
> -   (setq s (format "(%d)%s" (setq n (1+ n)) x))
> -   (if (> (+ (current-column) (string-width s) 1) 
> (frame-width))
> -   (insert "\n "))
> -   (insert " " s))
> - kwds))
> + (cl-loop for keyword in kwds
> +  and num from 1
> +  for string = (format "(%d)%s" num keyword)
> +  when (> (+ (current-column) (string-width string) 
> 1)
> +  (window-width))
> +  do (insert "\n ")
> +  do (insert " " string))

Ouch. Why `cl-loop' over `dolist'? Also it looks wrong since the last
`do' is not always executed? (or is it?).

I know there is more than one way to skin a cat, but I'd rather use
a straightforward one:

  (let ((n 0))
(dolist (k kwds)
  (let ((s (format "(%d)%s" (cl-incf n) k)))
(when (> (+ (current-column) (string-width s) 1) (frame-width))
  (insert "\n "))
(insert " " s


Regards,



Re: [O] [PATCH] org-agenda: Add 'none setting for org-agenda-overriding-header

2017-08-23 Thread Nicolas Goaziou
Hello,

Adam Porter  writes:

> If you would prefer the  approach, that would mean doing the actual
> insertion into the agenda buffer in the macro call rather than the macro
> expansion.  I thought it would be better to separate the actual
> insertion by abstracting it behind the macro.

I don't understand. There no difference of evaluation between (default)
and ( default).

Anyway, I'm fine with a single S-exp in the macro.

See may comments about the patches.

Regards,

-- 
Nicolas Goaziou



Re: [O] Capture w/ timestamp does not include current timestamp

2017-08-23 Thread Nicolas Goaziou
Hello,

Ken Mankoff  writes:

> A capture template with %^T or %^U will prompt for date and time, but
> if I hit ENTER without manually typing a time, the present time (shown
> in the prompt) is dropped, and only a date is used in the capture.

Fixed. Thank you.

Regards,

-- 
Nicolas Goaziou



Re: [O] counter macro in dates?

2017-08-23 Thread Adam Porter
Matt Price  writes:

> I'd love to be able generate dates dynamically using the {{{n}}} org
> macro, or some other mechanism. I don't immediately see how that would
> be possible but maybe someone can guide me. I'd want to do something
> equivalent to this pseudo-elisp:
>
> (let ((base-date 2017-09-05))
> (+ base-date (* 7 {{{n}}}))
>
> I haven't looked into how date objects are parsed in org-mode, though,
> so I have no idea how hard it would be to actually implement something
> like this.

Apologies to the list for practically spamming this recently, but it
seems directly relevant:

https://github.com/abo-abo/tiny

It has built-in support for Org dates with its %(date) function.
Apparently it can be used like this:

m\n8| TODO Learning from Data Week %(+ x 2) \nSCHEDULED: <%(date "Oct 7" (* 
x 7))> DEADLINE: <%(date "Oct 14" (* x 7))>

Which results in:

 TODO Learning from Data Week 2
SCHEDULED: <2013-10-07 Mon> DEADLINE: <2013-10-14 Mon>
 TODO Learning from Data Week 3
SCHEDULED: <2013-10-14 Mon> DEADLINE: <2013-10-21 Mon>
[...]




Re: [O] merging subtrees (in a syllabus)

2017-08-23 Thread Adam Porter
Hi Matt,

One potentially crazy idea would be to store each lab/discussion entry
in a named "#+BEGIN_SRC org" block, and use Babel <> to merge
them in a final noweb SRC block.  Seems a bit recursive, but I guess you
could edit each org block with org-edit-special and escape the nesting.

Another possibility would be to leave them as they are now, but to use
sparse trees in combination with tags or properties to only display lab
or discussion entries.

Also, you may find org-tree-to-indirect-buffer useful.  I have the
impression that not many Org users are aware of it or how
powerful--might I even say, liberating--it is.  You can essentially edit
each subtree of your document as a separate document in its own buffer,
while behind the scenes it's all taking place in the source buffer.  If
you're interested in this, I could provide some more details and some
support functions that make it more useful.

> If it also comes with a thought about how to generate an org date
> objet form an initial seed and a session number, that's be fabulous
> too.

I just discovered this yesterday, and it seems relevant:

https://github.com/abo-abo/tiny

Apparently it can be used like this:

m\n8| TODO Learning from Data Week %(+ x 2) \nSCHEDULED: <%(date "Oct 7" (* 
x 7))> DEADLINE: <%(date "Oct 14" (* x 7))>

Which results in:

 TODO Learning from Data Week 2
SCHEDULED: <2013-10-07 Mon> DEADLINE: <2013-10-14 Mon>
 TODO Learning from Data Week 3
SCHEDULED: <2013-10-14 Mon> DEADLINE: <2013-10-21 Mon>
[...]

Hope this helps!

Adam




[O] Capture w/ timestamp does not include current timestamp

2017-08-23 Thread Ken Mankoff
Hi List,

I'm not sure if this is a bug or not - it seems to be, but it has been 
discussed on the list[1] (and elswhere[2]) and not fixed, and I wonder if that 
is because nobody explicitly called it out as a bug. At a minimum, I think it 
is a documentation bug.

A capture template with %^T or %^U will prompt for date and time, but if I hit 
ENTER without manually typing a time, the present time (shown in the prompt) is 
dropped, and only a date is used in the capture.

This is different behavior than, for example =org-time-stamp= or 
=org-time-stamp-inactive= run with a prefix argument (e.g. "C-u C-c C-.").

Without a time prompt (i.e. %^t or %^u), I can still manually enter a time and 
it works. So the only benefit of %^T or %^U is that the current time is 
displayed in the prompt, but I still have to manually type it out? This seems 
inefficient, hence I think this is a bug.

If the behavior is correct, the following doc strings should probably be 
updated:

%t  Time stamp, date only.  The time stamp is the current time,
except when called from agendas with ‘M-x org-agenda-capture’ or
with ‘org-capture-use-agenda-date’ set.
%T  Time stamp as above, with date and time.
%u, %U  Like the above, but inactive time stamps.

Regards,

  Ken Mankoff

Org mode version 9.0.9 (9.0.9-88-g251f88-elpaplus @ 
/Users/mankoff/.emacs.d/elpa/org-plus-contrib-20170821/)

[1] https://lists.gnu.org/archive/html/emacs-orgmode/2016-02/msg00323.html
[2] https://emacs.stackexchange.com/questions/24368/