Re: Working out what face is used

2020-01-08 Thread Norman Walsh
Norman Walsh  writes:
> In this case, I can’t put the cursor on the text. I’ve made a quick
> skim of org-sticky-header.el and don’t see any obvious use of a
> specific face. So I’m a bit stumped.

FWIW, I made a rainbow out of the background colors and worked out
what face it was, but I am still curious if there was a more direct
approach.

Be seeing you,
  norm

-- 
Norman Walsh  | Four things come not back: the spoken
http://nwalsh.com/| word, the sped arrow, time past, the
  | neglected opportunity.--Omar Ibnal-Halif


signature.asc
Description: PGP signature


Working out what face is used

2020-01-08 Thread Norman Walsh
Hello,

This is a tangentially Org-related question. If I enable
org-sticky-headers, it works just fine. I get, for example, at the top
of the buffer:

  ** Top level heading / Second level heading

Which is correct. But “ / ” and the rest of the line after “Second
level heading” are in some unknown face. It has an odd gray background
and appears to be underlined in white.

For ordinary text in a buffer, I can put my cursor on the text and use
“C-u x =” to see what face is being used.

In this case, I can’t put the cursor on the text. I’ve made a quick
skim of org-sticky-header.el and don’t see any obvious use of a
specific face. So I’m a bit stumped.

Be seeing you,
  norm

-- 
Norman Walsh  | The future belongs to those who believe
http://nwalsh.com/| in the beauty of their dreams.--Eleanor
  | Roosevelt


signature.asc
Description: PGP signature


Re: Confused about src vs example and LaTeX export

2020-01-06 Thread Norman Walsh
"Fraga, Eric"  writes:
> On Sunday,  5 Jan 2020 at 10:53, Norman Walsh wrote:
>> In the simple case, both EXAMPLE and SRC export as {verbatim}
>> environments; that’s fine as a default. In the second case, the
>> ATTR_LATEX request for the {lstlisting} environment works on EXAMPLE
>> but appears to be ignored on SRC.
>
> Not for me.  I have lstlisting for both cases.

The trick turned out to be

  (setq org-latex-listings t)

I’ve written up a few more remarks here:

https://so.nwalsh.com/2020/01/05-latex

Be seeing you,
      norm

-- 
Norman Walsh  | People tend to feel strongest about
http://nwalsh.com/| those things they understand the least.


signature.asc
Description: PGP signature


Re: Inline references in noweb?

2020-01-05 Thread Norman Walsh
John Kitchin  writes:
> In order to engage the flux capacitor, you must set the
>   chronometer dial to src_emacs-lisp[:noweb yes :exports 
> results]{"<>"}
> {{{results(=Jan 5\, 2020=)}}}.

Ah, thank you. That was one level of indirection further than I got!

Be seeing you,
      norm

-- 
Norman Walsh  | 'I have done that,' says my memory. 'I
http://nwalsh.com/| cannot have done that'—says my pride,
  | and remains adamant. At last—memory
  | yields.--Nietzsche


signature.asc
Description: PGP signature


Confused about src vs example and LaTeX export

2020-01-05 Thread Norman Walsh
Hello again,

I’m confused about the distinction between BEGIN_EXAMPLE and BEGIN_SRC
and LaTeX export. I tend to use BEGIN_SRC more often because I’m
taking advantage of Babel output.

Consider this file:

#+TITLE: Test Org File

This is an example.

* Simple environments

#+BEGIN_EXAMPLE emacs-lisp
(+ 3 4)
#+END_EXAMPLE

#+BEGIN_SRC emacs-lisp
(+ 3 4)
#+END_SRC

* LaTeX attributes

#+ATTR_LATEX: :environment lstlisting
#+BEGIN_EXAMPLE emacs-lisp
(+ 3 4)
#+END_EXAMPLE

#+ATTR_LATEX: :environment lstlisting
#+BEGIN_SRC emacs-lisp
(+ 3 4)
#+END_SRC

In the simple case, both EXAMPLE and SRC export as {verbatim}
environments; that’s fine as a default. In the second case, the
ATTR_LATEX request for the {lstlisting} environment works on EXAMPLE
but appears to be ignored on SRC.

To confound me further, setting org-latex-custom-lang-environments
doesn’t seem to have any effect in either case.

  (setq org-latex-custom-lang-environments
 '((emacs-lisp "lstlisting")))

I’m not sure what I’m overlooking.

Be seeing you,
  norm

-- 
Norman Walsh  | There has never been a perfect
http://nwalsh.com/| government, because men have passions;
  | and if they did not have passions,
  | there would be no need for
  | government.--Voltaire


signature.asc
Description: PGP signature


Inline references in noweb?

2020-01-05 Thread Norman Walsh
Hello,

I’ve read through most of the docs that turn up with the obvious web
searches and I haven’t been able to figure this out. However, it seems
like it should be possible…

I’m quite pleased with how babel and noweb can be used to write
“literate programs” for configuration files and scripts.

Cross references between code blocks with <> work
just fine. What I’d like, but can’t work out, is how to refer to, for
example, a configuration value inline. Something like this:

  In order to engage the flux capacitor, you must set the
  chronometer dial to ~<>~.

  #+begin_src conf :noweb yes
  date: <>
  #+end_src

I don’t care how or where “required_date” is defined, I just want the
ability to refer to it in the documentation and in code blocks.

Have I overlooked something obvious?

Be seeing you,
      norm

-- 
Norman Walsh  | The stone fell on the pitcher? Woe to
http://nwalsh.com/| the pitcher. The pitcher fell on the
  | stone? Woe to the pitcher.--Rabbinic
  | Saying


signature.asc
Description: PGP signature


Wholesale changes to LaTeX headers

2019-12-31 Thread Norman Walsh
Hi,

I want to make wholesale changes to the LaTeX preamble exported from
Org mode. I want to put \RequirePackage and \PassOptionsToPackage
calls before the \documentclass, I want to write a specific set of
macros after the \documentclass, I want to craft a couple of
\renewcommands, etc.

Where should I begin?

Be seeing you,
  norm

-- 
Norman Walsh  | The stone fell on the pitcher? Woe to
http://nwalsh.com/| the pitcher. The pitcher fell on the
  | stone? Woe to the pitcher.--Rabbinic
  | Saying


signature.asc
Description: PGP signature


Re: “Literate” python?

2019-11-29 Thread Norman Walsh
Diego Zamboni  writes:
> Hi Norm,
>
> As George said, the trick in this case is to use the =:noweb= and
> =:noweb-ref= headers. The change is minimal from the script you
> sent:

Thanks. With your help (and Barry’s and George’s), I got over the
initial hurdles. I wrote about it here:
https://so.nwalsh.com/2019/11/29/t2

> If I may do a bit of self-promotion, feel free to check out my
> "Literate Config" booklet, which I published just a few days ago
> (available for free) and which contains some more tips for doing
> literate programming: https://leanpub.com/lit-config/read

Purchased. Authors gotta get paid. :-)

Be seeing you,
          norm

-- 
Norman Walsh  | The First Amendment is often
http://nwalsh.com/| inconvenient. But that is besides the
  | point. Inconvenience does not absolve
  | the government of its obligation to
  | tolerate speech.--Justice Anthony
  | Kennedy, in 91-155


signature.asc
Description: PGP signature


Re: “Literate” python?

2019-11-29 Thread Norman Walsh
George Mauer  writes:
> I've used noweb references to actually assemble what will be tangled
> all at once. See how I did it here.

Thanks.

> Also I'm pretty sure there's no :weave header arg...at least I
> haven't seen it used and can't find it documented anywhere.

No, that was just me guessing. Thanks for the pointers.

Be seeing you,
  norm

-- 
Norman Walsh  | A child becomes an adult when he
http://nwalsh.com/| realizes he has a right not only to be
  | right but also to be wrong.--Thomas
  | Szasz


signature.asc
Description: PGP signature


Re: “Literate” python?

2019-11-29 Thread Norman Walsh
"Berry, Charles"  writes:

> A couple of things might help.
>
> First, use the :noweb-ref argument to mark each of the code blocks
> you wish to tangle.
[…]
> The remaining problem (as you will see) is the indentation. Fix this
> by adding the `-i' flag to the penultimate code block, viz.
[…]
> See 12.6 Literal Examples and 15.10 Noweb Reference Syntax in the manual.

Thank you. I had failed to locate the relevant manual sections. Those
changes did appear to resolve the issues and I’ll study the docs with
a little more care!

Be seeing you,
      norm

-- 
Norman Walsh  | To enjoy yourself and make others enjoy
http://nwalsh.com/| themselves, without harming yourself or
  | any other; that, to my mind, is the
  | whole of ethics.--Chamfort


signature.asc
Description: PGP signature


“Literate” python?

2019-11-29 Thread Norman Walsh
Hi,

I’ve seen a couple of pointers recently to using Org mode and tangle
to write more literate Emacs configurations. I use Org+babel all the
time to write “interactive” documents, so I thought I’d try out tangle
from Org.

I didn’t want to start with something as comlicated as my Emacs
config :-) so I figured I’d kick the tires with a small python
program. That did not end well.

Consider:

#+TITLE: Python literate programming
#+OPTIONS: html-postamble:nil

It starts off as a completely standard Python3 program.

---%<--
#+BEGIN_SRC python :tangle yes :weave no
#!/usr/bin/env python3

#+END_SRC

It defines ~a~.

#+BEGIN_SRC python :tangle yes
def a():
print("a")


#+END_SRC

And ~b~.

#+BEGIN_SRC python :tangle yes
def b():
print("b")


#+END_SRC

Now ~c~ is a little more complicated:

#+BEGIN_SRC python :tangle yes
def c():
   print("c")
#+END_SRC

Not only does ~c~ print “c”, it calls ~a()~ and ~b()~.

#+BEGIN_SRC python :tangle yes
   b()
   a()
#+END_SRC

Finally, make it importable. Not that you’d want to.

#+BEGIN_SRC python :tangle yes
if __name__ == "__main__":
main()
#+END_SRC
--->%--

That’s the script. It weaves into HTML more-or-less ok (there’s a
weird black box at the front of indented lines, but I can come back to
that later).

It’s a complete mess when tangled.

The extra blank lines between functions (to make pylint happy with
some PEP guideline) have disappeared. I guess I could live with that,
but the complete failure to preserve indention in the penultimate code
block is a show stopper:

#!/usr/bin/env python3

def a():
print("a")

def b():
print("b")

def c():
   print("c")

b()
a()

if __name__ == "__main__":
main()

(Also, why is there an extra blank line before the incorrectly
indented block?)

Is this user error on my part somehow? I suppose I could write my own
version of tangle, though I’m not clear if the whitespace is lost in
the tangle function or in the Org mode data model.

Thoughts?

        Be seeing you,
  norm

-- 
Norman Walsh  | We discover in ourselves what others
http://nwalsh.com/| hide from us, and we recognize in
  | others what we hide from
  | ourselves.--Vauvenargues


signature.asc
Description: PGP signature


[O] Org-contacts and extra spaces

2019-09-24 Thread Norman Walsh
Hi,

If I complete an email address with org-contacts, I get extra spaces
after the email address:

  To: Jane Doe _ _ _ _[cursor]

Is this just me? Before I go digging for a solution, has anyone else
encountered and fixed this?

Be seeing you,
  norm

-- 
Norman Walsh  | The Future is something which everyone
http://nwalsh.com/| reaches at the rate of sixty minutes an
  | hour, whatever he does, whoever he
  | is.--C. S. Lewis


signature.asc
Description: PGP signature


Re: [O] Extending ob-plantuml keywords

2019-09-09 Thread Norman Walsh
> On a casual inspection, it appears that ob-plantuml hardcodes the
> plantuml keywords @startuml/@enduml around the source block.

On closer inspection, I see that Org Mode 9.2.6 supports alternate
@start/@end pairs in plantuml. Rather than using a keyword on
#+BEGIN_SRC, it simply checks for @start… at the beginning of the
body.

That’s good enough, I think.

Be seeing you,
  norm

-- 
Norman Walsh  | Four things come not back: the spoken
http://nwalsh.com/| word, the sped arrow, time past, the
  | neglected opportunity.--Omar Ibnal-Halif


signature.asc
Description: PGP signature


[O] Extending ob-plantuml keywords

2019-09-08 Thread Norman Walsh
Hi,

On a casual inspection, it appears that ob-plantuml hardcodes the
plantuml keywords @startuml/@enduml around the source block.

There are at least a couple of other keywords that can be used
(@startsalt and @startmindmap).

I’m tempted to hack at obj-plantuml a bit to support keyword selection
somehow. Before I do that, has anyone else already done it?

Be seeing you,
  norm

-- 
Norman Walsh  | There has never been a perfect
http://nwalsh.com/| government, because men have passions;
  | and if they did not have passions,
  | there would be no need for
  | government.--Voltaire


signature.asc
Description: PGP signature


Re: [O] Proposal for new document-level syntax

2019-06-02 Thread Norman Walsh
Gustav Wikström  writes:
>   I propose a "document" element in org-element, a property-drawer on
>   document-level, a setting-drawer on document-level and
>   property-keywords (slightly different than what already exist). And
>   would like your comments regarding that!

When I started searching for ways to put arbitrary metadata on org
documents, I was very surprised to find that there didn’t appear to be
support for a top-level properties drawer. This seems like a good idea
to me.

Be seeing you,
      norm

-- 
Norman Walsh  | If you are losing your leisure, look
http://nwalsh.com/| out! You may be losing your
  | soul.--Logan Pearsall Smith


signature.asc
Description: PGP signature


Re: [O] Porting Apple Calendars to org-mode

2019-05-02 Thread Norman Walsh
Mohamed Wael Khobalatte  writes:
> Hi guys, I posted a question to the Emacs StackExchange
> (https://emacs.stackexchange.com/questions/50137/show-apple-calendar-events-in-org-mode),
> but I believe it's better asked here. Does anyone know how I can get
> my Apple calendar to show up in org-mode as readonly (preferably)?

Coincidentally, I just went through this exercise myself.

I fixed a couple of issues in icalevents[1] and then worked out how to
get the calendar details from database that the Mac actually uses to
track the calendars. I wrote icaldiary[2] to extract events from my
calendar(s) and create an emacs “diary” file which Org reads quite
happily.

> I had no luck with org-mac-iCal. Only one calendar (the Birthdays
> calendar) shows up, eventhough all other calendars are *checked*, as
> the documentation from that package requires. It is also rather old,
> so not sure if it works anymore?

Yeah, I found the same problem. I think that Apple stopped storing the
active calendar data in the plist files that org-mac-iCal checks. They
moved it into the cache which they store with sqlite3.

Hoping this is helpful…

Be seeing you,
  norm

[1] https://github.com/ndw/icalevents
[2] https://gist.github.com/ndw/e76a3dad862989deb0cb74b3e2b557b4

-- 
Norman Walsh  | Throughout history the world has been
http://nwalsh.com/| laid waste to ensure the triumph of
  | conceptions that are now as dead as the
  | men that died for them.--Henry De
  | Montherlant


signature.asc
Description: PGP signature


[O] Supporting Exchange calendars in org-mac-iCal.el

2019-02-22 Thread Norman Walsh
Hi folks,

I don’t know if anyone else is using org-mac-iCal[*], but I find it
useful. (I find it convenient to have calendar appointments in my
agenda view.)

In the course of setting it up, I discovered that it didn’t support
Exchange calendars. And it had a regexp that didn’t match versions of
MacOS post 10.8.

I’ve fixed both of those issues, at least to the extent that they seem
to work for me. I sent email to the named author, Christopher
Suckling, but didn’t get a reply. (Hello Christopher, if you’re out
there!)

If anyone is interested, I can see about finding a place to put my
patch.

Be seeing you,
  norm

[*] https://orgmode.org/worg/org-contrib/org-mac-iCal.html

-- 
Norman Walsh  | I often marvel that while each man
http://nwalsh.com/| loves himself more than anyone else, he
  | sets less value on his own estimate
  | than on the opinions of others.--Marcus
  | Aurelius


signature.asc
Description: PGP signature


[O] Error in org-element-parse-buffer?

2019-02-19 Thread Norman Walsh
Hi,

I’ve just noticed that org-element-parse-buffer loses whitespace
sometimes.

Consider this org-mode file:

This is a *bold* word.

What org-element-parse-buffer returns is:

(org-data nil (section (:begin 1 :end 24 :contents-begin 1 :contents-end 24
:post-blank 0 :post-affiliated 1 :parent #0) (paragraph (:begin 1 :end 24
:contents-begin 1 :contents-end 24 :post-blank 0 :post-affiliated 1 :parent 
#1)
#("This is a " 0 10 (:parent #2))
(bold (:begin 11 :end 18 :contents-begin 12 :contents-end 16
   :post-blank 1 :parent #2) #("bold" 0 4 (:parent #3)))
#("word." 0 6 (:parent #2)

Note that the whitespace between “bold” and “word.” has been lost.
Well, possibly it’s recoverable from the various begin/end positions,
I can’t quite decide although (1) it doesn’t seem obviously to be the
case and (2) it’d be *way* more convenient if the space was in the
data structure as text. I guess it’d have to be either a single space
between them, or at the beginning of “ word.”.

Or do I misunderstand something about the data structure?

Be seeing you,
      norm

-- 
Norman Walsh  | The cure for boredom is curiousity.
http://nwalsh.com/| There is no cure for curiosity.--Ellen
  | Parr


signature.asc
Description: PGP signature


[O] org-to-xml, v0.0.1

2019-02-19 Thread Norman Walsh
Hello,

Years ago, literally, I asked about converting an org-mode file to XML.

I finally got around to writing it. Probably very badly. Comments,
etc. most welcome.

https://github.com/ndw/org-to-xml

Be seeing you,
  norm

-- 
Norman Walsh  | It is well to remember that the entire
http://nwalsh.com/| universe, with one trifling exception,
  | is composed of others.--John Andrew
  | Holmes


signature.asc
Description: PGP signature


Re: [O] Making DocBook xml books from org mode?

2016-10-02 Thread Norman Walsh
Joost Kremers <joostkrem...@fastmail.fm> writes:
> There's also a `docbook' writer,
> which has been part of Pandoc much longer and which outputs to (I
> assume) DocBook v4. So I suspect you either need to upgrade your Pandoc
> or make sure ox-pandoc sets the output format to `docbook'.

Depending on what your down-stream processing is like, you could
just go with V4 DocBook from org and then convert that to V5 with
the upgrade stylesheet.

Be seeing you,
      norm

-- 
Norman Walsh <n...@nwalsh.com> | There is no monument dedicated to the
http://nwalsh.com/| memory of a committee.--Lester J.
  | Pourciau


signature.asc
Description: PGP signature


[O] XML dump of org file?

2016-09-21 Thread Norman Walsh
Hi,

There are various export filters, but I’d like one that just does a
complete, raw dump of the internal memory structure[*]. I could start
with something like the HTML export and work backwards to output other
tag names, but it seems like it should be possible to just dump the
data structure.

My brief couple-of-hours foray into this was unsuccessful. I ran
aground in various places where I couldn’t really grok the structure
well enough to deduce what to output. And possibly where my elisp
coding skills are a little weak.

Before I spend another few evenings poking it with a sharp stick, does
anyone have some code that walks the data structure in a way that will
make it easier? (Or has someone else, *gasp*, solved this exact
problem? :-))

Be seeing you,
  norm

[*] I have really good XML tools for querying, transforming, and
otherwise manipulating the data. I want to start with as near to
perfect fidelity as I can. I don’t have any short term plans to try to
go the other way, but I might eventually.

-- 
Norman Walsh <n...@nwalsh.com> | When we are tired, we are attacked by
http://nwalsh.com/| ideas we conquered long ago.--Nietzsche


signature.asc
Description: PGP signature


[O] Editing/evaluation of code blocks

2016-05-05 Thread Norman Walsh
Hello,

I’ve started using Org Mode more frequently and I thought it would be
fun to extend org-babel support to evaluate XQuery, JavaScript, and
SPARQL code blocks by sending them off to MarkLogic server.

I was right, it was fun :-)

If I type C-c C-c in this block:

#+begin_src marklogic :var startDate="2017-04-19T12:34:57"
  xquery version "1.0-ml";

  declare default function namespace "http://www.w3.org/2005/xpath-functions;;

  declare option xdmp:mapping "false";

  declare variable $startDate external;

  let $date   := $startDate cast as xs:dateTime
  let $diff   := current-dateTime() - $date
  return
current-dateTime() - $date
#+end_src

I get back a result!

#+RESULTS:
: -P348DT10H59M31.387138S

Win!

But C-c ' fails because “marklogic-mode” isn’t the mode for editing
XQuery. There’s an xquery-mode for that.

I found org-src-lang-modes which allows me to make ‘marklogic’ use
xquery-mode, except that that’s wrong when I’m editing JavaScript
or SPARQL. :-(

Is there some way, in the source block itself, to specify
*independently* the mode that should be used to edit and the language
package that should be used for evaluation?

Guessing not, I considered refactoring the code to support ‘xquery’,
‘javascript’, and ‘sparql’ languages.

That would be fine, but I presume there are (or will eventually be)
other backends for evaluating these languages. Maybe the answer then
is simply not to load two different ones at the same time, but that
doesn’t seem very satisfying.

Am I overlooking something?

Suggestions most welcome.

Be seeing you,
      norm

-- 
Norman Walsh <n...@nwalsh.com> | We are what we repeatedly do.
http://nwalsh.com/| Excellence, then, is not an act, but a
  | habit.--Aristotle


signature.asc
Description: PGP signature


[O] org-contacts, multi-line properties, postal addresses

2013-11-13 Thread Norman Walsh
Hello world,

I'm just taking another look at org-contacts. I wonder what the best
practice is for dealing with multi-line properties like postal
addresses.

I can just make them part of the entry, of course, not in a property,
but that seems oddly different from the other properites.

Have I overlooked something obvious?

Be seeing you,
  norm

-- 
Norman Walsh n...@nwalsh.com | A man may fulfill the object of his
http://nwalsh.com/| existence by asking a question he
  | cannot answer, and attempting a task he
  | cannot achieve.--Oliver Wendell Holmes


signature.asc
Description: PGP signature