Heading won't unfold on TAB if last line has just spaces, with empty line preceding.

2020-10-13 Thread Giovanni Moretti
There's something weird with headings that can cause unfolding to fail. Headings can 
be folded with TAB refuse to unfold - they need Shift-TAB to see the contents. This 
is scary as it looks like content has been accidentally deleted whereas it's really 
just hidden.


The TAB-cycling worked as expected in Org 9.1.9 for the following example but fails 
in 9.4.


The example below illustrates the difficulties:

 * Block 1 - you can delete X to leave two empty lines and TAB on "Block 1" (or 
1a)
   cycles as expected - GOOD!

But if the last line isn't empty but has spaces:

 * Block 2 - deleting X (leaving empty line) and then Z to leave the last line 
with
   just a space (one or more) and heading will fold on TAB /but won't unfold/.
   Shift-Tab is needed.
 * Block 3 - the same symptoms as Block 2 but has a subtree to show
   "Folded/Children/Subtree" when Tab-cycling on level one heading.

Cheers
Giovanni

===

* Block 1 - OK
Block 1 text

** Block 1a heading
Block 1a content
X
X
* BAD BLOCK 2 - Delete X & Z, then TAB WON'T UNFOLD
Block 2 content
X
 Z
* BAD BLOCK 3 - TAB WON'T UNFOLD
  Block 2 content

** BAD BLOCK 3a
   Block 3a content
X
 Z
* Block 4 - OK
The end





Org-publish: how do I access user-defined keywords in html-preamble function?

2019-12-29 Thread Giovanni Moretti
I'm working on a blog published via org-publish but one things got me stumped:
accessing user defined keywords while publishing to HTML:

Each post is in an orgmode file, and has a simple structure. E.g. one post 
starts with:

#+title: Fix for Sparkfun Arduino Pro Micro
#+date: <2009-03-05 13:55>
#+filetags: Arduino
#+category: electronics
#+draft: true

I want to access the last two keywords values when publishing but despite lots 
of
searching, can't find out how:

Part of my publish-project-alist:

(setq org-publish-project-alist
  `(
 ("blog-posts"
 :base-directory   "~/projects/3-blog/"
 :base-extension   "org"
 :recursive    t
   --- lots omitted
 :html-preamble  *my-blog-page-preamble*
 )

and /my-blog-page-preamble/ function is:

(defun *my-blog-page-preamble* (arg)
  (with-temp-buffer
    (insert-file-contents my-blog-page-preamble-file)   ; Insert preamble 
from file
    (concat (buffer-string)
   (format "Tags: %s"  (car (plist-get arg :filetags)))  *;* 
*<< WORKS*
   (format "Category: %s " (car (plist-get arg :category))) *;<< 
returns nil*
   (format "Draft: %s" (car (plist-get arg :draft))*;<< 
returns nil*

I can access/the values of :title/ or /:filetags/ and other predefined keywords 
but
not ones I define myself.

My keywords are being passed to the preamble-function as displaying 'arg' shows:

--LOTS OMITTED--#2 (keyword (:key DATE :value <2009-03-05 13:55> :begin 81 
:end
108 :post-blank 0 :post-affiliated 81 :parent #4)) (keyword (:key CATEGORY 
:value
electronics :begin 108 :end 132 :post-blank 0 :post-affiliated 108 :parent 
#4))
(keyword (:key FILETAGS :value Arduino :begin 132 :end 152 :post-blank 0
:post-affiliated 132 :parent #4)) (keyword (:key DRAFT :value true :begin 
152
:end 166 :post-blank 0 :post-affiliated 152 :parent #4)) -- LOTS MORE

I tried capitalizing -- (plist-get arg :CATEGORY) -- but that returns /nil/ too.

Given that /(plist-get arg :category)/ and /(plist-get arg :draft)/ don't 
return the
expected values, what's the correct way to access the values of /#+category:/ 
and
user-defined keywords such as /#+draft:/ keywords?

Many thanks
Giovanni*
*




[O] Bug (or at least a trap) in exporting #+begin_src blocks

2014-02-23 Thread Giovanni Moretti
I've just solved a puzzle finding out why Python src blocks that exported 
happily last year don't now. I'm using them for class tutorials and a of about 
fifteen Python fragments, a couple of the blocks would expand in-situ (C-c C-c) 
but when exported were treated as normal text.


I narrowed it down using the following file
==
#+options: num:nil toc:nil
** Try 1

#+BEGIN_SRC python :results output :exports both
print hi
#+END_SRC

#+RESULTS:
: hi

** Try 2

#+BEGIN_SRC python :results output :exports both
print Fred
#+END_SRC python

#+RESULTS:
: Fred


Both of the src blocks can be isolated and edited in its own buffer using 
org-babel-expand-src-block - C-c C-v C-v) and both get run correctly if you C-c 
C-c inside them, as shown by the #+RESULTS blocks, however on export, the second 
one is treated as normal text .


Puzzlingly, a hex-dump showed the #+BEGIN_SRC lines were identical - then I 
noticed that the #+END line was wrong. I'd written #+END_SRC python instead of 
just #+END_SRC.


It seems like the parser for the src blocks is now stricter that it was last 
year.

Could I ask that an error message be generated for this? While not strictly a 
bug, it's an insidious trap given that the in-buffer expansion (C-c C-c) runs 
and inserts the results  as expected.


I've also had similar problems with

#+BEGIN_SRC python :output results :exports both
print hi
#+END_SRC

which looks ok, and the :output results makes sense when you read it, but 
should be :results output. From memory, this also worked in-buffer but would 
silently fail on export.


Orgmode + Babel is excellent for writing Python tutorial worksheets - so thank 
you - your work is much appreciated.


Cheers
Giovanni
--

==
Dr Giovanni Moretti | School of Engineering and Advanced Technology
Senior Lecturer | Massey University, Palmerston North, New Zealand
Computer Science| Ph +64-6-3505799x84134 Fax +64-6-3502259 - ZL2GX
==
http://seat.massey.ac.nz/morettig.more...@massey.ac.nz




Re: [O] How to activate pre.src in org-babel html output? Can only get class=example

2012-02-19 Thread Giovanni Moretti

Hi Eric


 My guess is that during export you get a message along the lines of
 htmlize is required for export.  Try explicitly loading htmlize.el
 (in the contrib/lisp directory of org) and then re-exporting ...


You're spot on - importing htmlize.el did the trick. However, before importing 
it, there weren't any error messages about it being missing. All would work 
happily, but the source block didn't have the additional src and src-python tags.


To me, this seems like a bug or at least not ideal, as the src tag and the 
src-language tag are related to the HTML export of #+begin_src block, not on 
*how* the HTML is styled (i.e. by the user or htmlize).


For those searching the mailing list later:

; For pretty-printed formatted source code on HTML export,
; load htmlize.el in init.el or the emacs config file

(load-file ~/.emacs.d/orgmode/contrib/lisp/htmlize.el)

I've got the orgmode source in the .emacs.d directory so I can pull updates 
using git, otherwise look for contrib/lisp/htmlize.el in the main Emacs directory.


With htmlize.el loaded, exporting:
,
| #+begin_src python :results output :exports both
| print Pi = , 355/113.0
| #+end_src python
`

Results in the src block having the src and src-python CSS tags:
,
|pre  class=src src-python
|span  style=color: #a020f0;print/span
|span  style=color: #8b2252;Pi =/span, 355/113.0
|/pre
|
|
|pre  class=example
| Pi =  3.14159292035
|/pre
`

with an automatically added little Python flag box on the Python src block.

Some custom CSS can be used to make the src and output a little more distinct. A 
simple way is it place these lines at the top of the file:


#+style:style  pre.src  {background-color: #DD;}/style
#+style:style  .example {background-color: #CC;}/style

However, you have to be consistent about using #+begin_src blocks rather than 
just a colon or using begin_example at the beginning of lines for src fragments 
that don't output anything, otherwise Python src they'll come out with the 
output colouring. The keyboard shortcut ( s tab) for getting a 
#+begin_src---#+end_src block is handy here.


Although the example above relates to #+begin_src python blocks, the fix should 
work with other languages.


Cheers and thanks
Giovanni

==
Dr Giovanni Moretti | School of Engineering and Advanced Technology
Senior Lecturer | Massey University, Palmerston North, New Zealand
Computer Science| Ph +64-6-3505799x2474  Fax +64-6-3502259 - ZL2GX
==
http://seat.massey.ac.nz/morettig.more...@massey.ac.nz



[O] How to activate pre.src in org-babel html output? Can only get class=example

2012-02-12 Thread Giovanni Moretti
Using org-babel, I'm wanting to output Python fragments along with the resultant 
output to HTML.


That bit's easy, and the following works as expected:

   #+options: toc:nil num:nil
   * Using Python interactively
   Any commands typed into the console executed immediately.

   #+begin_src python :results output :exports both
   print 355/113

   print 17/2
   print 17/2.0
   #+end_src python

However, although I find references to various styling mechanisms (e.g 
*pre.src*) in the orgmode documentation, I can't find any way to get any more 
CSS selectors on both the src and output blocks. The only one that ever appears 
is example as shown here:


   pre class=exampleprint 355/113
   print 17/2
   print 17/2.0
   /pre
   pre class=example
  3
  8
  8.5
   /pre
   /div

If I can find out how to make pre.src appear (hopefully only on the source 
block) , then I can change the background colours or fonts to make the output 
visibly distinct from the source code.


The full HTML output I get is at 
http://dl.dropbox.com/u/2671560/org-py-babel.html contains lots of CSS 
selectors, and I can easily include my my own using #+STYLE lines, but I need 
some way to differentiate the two blocks.


I'm using Emacs 23.1.50.1 and the lastest orgmode  commit 
b5082974c83a3a4838db86025edce857b11e5847 (Fri Feb 3 15:18:05 2012 +0100)


Any tips?

Thanks
Giovanni

--
==
Dr Giovanni Moretti | School of Engineering and Advanced Technology
Senior Lecturer | Massey University, Palmerston North, New Zealand
Computer Science| Ph +64-6-3505799x2474  Fax +64-6-3502259 - ZL2GX
==
http://seat.massey.ac.nz/morettig.more...@massey.ac.nz




Re: [Orgmode] Re: Bug: subtree export fails with src block

2010-10-03 Thread Giovanni Moretti
I'm just starting with Babel and have been puzzled about why one file
worked and another didn't.

I have been playing in a new file without any headers at all (no lines
starting with '*') and while I could execute the code in the buffer,
exporting to HTML always failed with:

   No such file: c:/org/babel-python-test.org::

When searching, I found this thread and wondered if the heading were
important. It turns out they are. In the block below, exporting to HTML
fails if the first line isn't a heading.

This seems like a clue ...

Cheers and thanks
Giovanni

PS: the BOTH option for :export is hard to find - only :export none is in
the intro page.

===
* Python Babel test

Now let's see what happens:

#+begin_src python :results output :exports both
print Babel
limits = [1,2,3,4,5,6,7,8,9,10]

for i in limits:
  print Hello * i
#+end_src python



___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Vertical line anomaly between Example block and lines starting with a colon

2010-06-06 Thread Giovanni Moretti
My first post to this list - thanks Dominik and all, your efforts are 
much appreciated.


I'm working up a presentation on orgmode for a local club and needed to 
prefix it with a brief emacs overview, and so included this:


#+BEGIN_EXAMPLE
  ctrl-P (previous line)
   |
   |
Ctrl-A   Ctrl-B  o  Ctrl-F   Ctrl-E
 Col 1  back char  !   fwd charEOL
   !
  ctrl-N (next line)
#+END_EXAMPLE

:   ctrl-P (previous line)
:|
:|
: Ctrl-A   Ctrl-B  o  Ctrl-F   Ctrl-E
: Col 1   back char  |   fwd charEOL
:|
:   ctrl-N (next line)

I'm using Orgmode v6.36c and when exporting to HTML (and LaTex Beamer), 
the two lines containing the single vertical bar immediately below the 
ctrl-P line in the #+EXAMPLE block vanish, whereas using the alternate 
colon at the beginning of the line notation, the rendering is as expected.


Interestingly, enabling the +n option (#+BEGIN_EXAMPLE +n) causes the 
missing lines (lines 2  3) to reappear.


I don't think it's supposed to do this ...

Cheers
Giovanni


___
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode