[O] adapted org-flag-drawer to hide newlines of consecutive drawers to save lines

2013-11-12 Thread Gregor Kappler
Often several consecutive drawers follow the headline in my setup.
Maybe this code to hide newlines after drawers is of some use.

When drawers are hidden this wastes three lines of screen real estate
: * heading
: :LOGBOOK:...
: :CLOCK:...
: :PROPERTIES:...
per line.

I adapted org-flag-drawer to hide the newlines as well if another drawer
is following:
: * heading
: :LOGBOOK:...:CLOCK:...:PROPERTIES:...

This lead to a much denser editing experience.

Maybe this is not the best way to do this.  But this trick caused no
troubles for me during the last months.  All the best!

Gregor

#+BEGIN_SRC emacs-lisp
  (defun org-flag-drawer (flag)
When FLAG is non-nil, hide the drawer we are within, 
 including the newline at end of a drawer, 
 yet only if another drawer is following.  
 If FLAG is nil, make drawer it visible.
(save-excursion
  (beginning-of-line 1)
  (when (looking-at ^[ \t]*:[a-zA-Z][a-zA-Z0-9]*:)
(let ((b (match-end 0))
(selective-display-ellipses nil))
(if (re-search-forward
 ^[ \t]*:END:
 (save-excursion (outline-next-heading) (point)) t)
(outline-flag-region b (save-excursion 
 (forward-line) 
 (if (looking-at org-drawer-regexp) 
 (point-at-bol)
   (match-end 0)))
 flag)
  (error :END: line missing at position %s in buffer %s b 
(buffer-name)))

#+END_SRC

Refererences
-- org.el::org-cycle-hide-drawers

-- 



[O] [PATCH] org babel execution and new exporter

2013-02-14 Thread Gregor Kappler
Hi,

the new exporter currently does not respect `org-export-babel-evaluate' and 
evaluates babel src blocks always on export.  I did the tiniest change to ox.el 
as in the attached patch.
(This is my first patch sent - I hope it works and helps...).

Best regards,  Gregor

From a955c54f3ecda02b70933f6b98b8043a4f40d634 Mon Sep 17 00:00:00 2001
From: Gregor Kappler gregor@alcedo.(none)
Date: Thu, 14 Feb 2013 18:12:39 +0100
Subject: [PATCH] Export: Prevent babel src blocks from being evaluated
 if org-export-babel-evaluate is nil

* lisp/ox.el (org-export-as): Make sure org-export-babel-evaluate is not nil before calling `org-export-execute-babel-code'.

TINYCHANGE
---
 lisp/ox.el |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index 049dcc5..1ce900b 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -2810,7 +2810,10 @@ Return code as a string.
 	 ;; added some new ones.
 	 (org-macro-initialize-templates)
 	 (org-macro-replace-all org-macro-templates)
-	 (org-export-execute-babel-code)
+
+	 (when org-export-babel-evaluate
+	   (org-export-execute-babel-code))
+
 	 ;; Update radio targets since keyword inclusion might have
 	 ;; added some more.
 	 (org-update-radio-target-regexp)
-- 
1.7.10.4



-- 
Dr. Gregor Kappler

Fakultät für Psychologie 
Institut für Angewandte Psychologie: Gesundheit,
Entwicklung, Förderung
Universität Wien
Liebiggasse 5
A-1010 Wien

http://www.univie.ac.at/Psychologie
tel: +43 1 4277 47276


Re: [O] [New exporter] custom emphasis in org-emphasis-alist

2013-02-14 Thread Gregor Kappler
))
  (font-lock-prepend-text-property (match-beginning 2) (match-end 2)
   'face
   (nth 1 a))
  (and (nth 4 a)
   (org-remove-flyspell-overlays-in
(match-beginning 0) (match-end 0)))
  (add-text-properties (match-beginning 2) (match-end 2)
   '(font-lock-multiline t org-emphasis t))
  (when org-hide-emphasis-markers
(add-text-properties (match-end 4) (match-beginning 5)
 '(invisible org-link))
(add-text-properties (match-beginning 3) (match-end 3)
 '(invisible org-link)
(backward-char 1))
  rtn))
  
  (font-lock-add-keywords
   'org-mode '(gk-org-do-emphasis-faces))
#+END_SRC

Maybe the duplication of code could be prevented by including functions 
`org-set-emph-re' and `org-do-emphasis-faces' with dynamical scoping?


Nicolas Goaziou n.goaz...@gmail.com writes:

 Hello,

 Gregor Kappler g.kapp...@gmx.net writes:

 I am currently migrating my system and contribute my first stop:
 custom emphasis characters that I use extensively:
 - ! is used for exclamations,
 - ? for questions, and
 - # for in-text comments that I do not want exported.

 Emphasis characters are now hard-coded. You cannot change them, though,
 you can change how each back-end interprets them.

 We are solidifying Org syntax for parsing purposes. Allowing variable
 markup is asking for trouble. The plan is to make `org-emphasis-alist'
 a defconst.

 On the other hand, you may be able to parse custom markup with the help
 of a filter:

 #+begin_src emacs-lisp
 (defun my-special-markup (text backend info)
   (when (and (org-export-derived-backend-p backend 'html)
  (string-match \\([  ('\{]\\|^\\)\\(\\([?!#]\\)\\([^
 ,\']\\|[^
 ,\'].*?\\(?:
 .*?\\)\\{0,1\\}[^ 
 ,\']\\)\\3\\)\\([-   .,:!?;'\)}\\]\\|$\\)
text))
 (format (cond ((equal (match-string 3 text) ?)
span class=\org-question\%s/span)
   ((equal (match-string 3 text) #) !--%s--)
   (t span class=\org-exclamation\%s/span))
 (match-string 4 text
 (add-to-list 'org-export-filter-plain-text-functions 'my-special-markup)
 #+end_src


 Regards,

 -- 
 Nicolas Goaziou




[O] [New exporter] custom emphasis in org-emphasis-alist

2013-02-09 Thread Gregor Kappler
))
(contents-begin (match-beginning 4))
(contents-end (match-end 4))
(post-blank (progn (goto-char (match-end 2))
   (skip-chars-forward  \t)))
(end (point)))
(list 'emph-exclamation
  (list :begin begin
:end end
:contents-begin contents-begin
:contents-end contents-end
:post-blank post-blank)


  (defun org-element-emph-exclamation-interpreter (italic contents)
Interpret ITALIC object as Org syntax.
  CONTENTS is the contents of the object.
(format ?%s? contents))

  (defun org-element-emph-question-parser ()
Parse question object at point.

  Return a list whose CAR is `italic' and CDR is a plist with
  `:begin', `:end', `:contents-begin' and `:contents-end' and
  `:post-blank' keywords.

  Assume point is at the first # marker.
(save-excursion
  (unless (bolp) (backward-char 1))
  (looking-at org-emph-re)
  (message %s (match-string 4))
  (let ((begin (match-beginning 2))
(contents-begin (match-beginning 4))
(contents-end (match-end 4))
(post-blank (progn (goto-char (match-end 2))
   (skip-chars-forward  \t)))
(end (point)))
(list 'emph-question
  (list :begin begin
:end end
:contents-begin contents-begin
:contents-end contents-end
:post-blank post-blank)

  (defun org-element-emph-question-interpreter (italic contents)
Interpret ITALIC object as Org syntax.
  CONTENTS is the contents of the object.
(format ?%s? contents))
#+END_SRC
(Considering that I only changed the defun name and emph-comment, to me this 
seems a lot of duplicate code.  I am a mere elisp novice without knowledge of 
macros - but would this not be a case to use macros or similar in order to ease 
things?)

Stealing from org-html-italic 
#+BEGIN_SRC emacs-lisp
  (add-to-list 'org-html-text-markup-alist '(emph-comment . ))
  (add-to-list 'org-html-text-markup-alist '(emph-exclamation . span 
class=\org-exclamation\%s/span))
  (add-to-list 'org-html-text-markup-alist '(emph-question . span 
class=\org-question\%s/span))

  (defun my-emph-comment (text contents info)
Transcode a comment emphasis element from Org to latex.
 CONTENTS is nil.  INFO is a plist used as a communication
 channel.
(message comment %s contents)
(format (or (cdr (assq 'emph-comment org-html-text-markup-alist)) %s) 
contents))

  (defun my-emph-exclamation (text contents info)
Transcode a comment emphasis element from Org to latex.
 CONTENTS is nil.  INFO is a plist used as a communication
 channel.
(message exclamation %s contents)
(format (or (cdr (assq 'emph-exclamation org-html-text-markup-alist)) %s) 
contents))

  (defun my-emph-question (text contents info)
Transcode a comment emphasis element from Org to latex.
 CONTENTS is nil.  INFO is a plist used as a communication
 channel.
;;(fux)
(message question %s contents)
(format (or (cdr (assq 'emph-question org-html-text-markup-alist)) %s) 
contents))

  (org-export-define-derived-backend my-html html 
:translate-alist ((emph-comment . my-emph-comment)
  (emph-exclamation . my-emph-exclamation)
  (emph-question . my-emph-question)))
#+END_SRC
(again, this seems a lot of duplicate code...)

With this change, contents always was passed nil...  
So I digged further into org-element.el - and finally by experimenting found 
that adding my new elements to
#+BEGIN_SRC emacs-lisp
  (defconst org-element-recursive-objects
'(emph-question emph-exclamation emph-comment bold italic link subscript 
radio-target strike-through superscript
   table-cell underline)
List of recursive object types.)
#+END_SRC
resulted in a (partly) working solution.  Yet, bold and italic occur quite 
often hard-coded in org-element.el.

-- 
Dr. Gregor Kappler

Fakultät für Psychologie 
Institut für Angewandte Psychologie: Gesundheit,
Entwicklung, Förderung
Universität Wien
Liebiggasse 5
A-1010 Wien

http://www.univie.ac.at/Psychologie
tel: +43 1 4277 47276



Re: [O] Best way to set up Org mode with MobileOrg over Dropbox

2011-11-03 Thread Gregor Kappler
Hi Nikolai,

 As I can hardly be the only person with two computers, a mobile, and a
 desire to keep my org-agenda-files in sync between these three
 computers, I’ll pose this question here: How do you have this set up?

I am using git to sync several laptops and Desktop computers.

Every 5 minutes a cronjob runs a shell script that automatically runs
=git pull= -- and =git add= on org files as well files listed in the
=.gitcroncommit= file.  The commit message is comprised of the filenames
of all changed files as well as a prefix for detection in git logs
(cron autocommit, parameterized) and the hostname.

The auto commit is performed only if
 - no files have been staged manually.
 - git is in the auto branch (where mine is always). This prevents
   cluttering the git history of the master branch.

When I change computers I run
[[http://www.neilvandyke.org/revbufs/revbufs.el][revbufs]] and can thus
quite seamlessly switch computers and just work on.

I know, tracking of text changes in 5 min intervals is obsessive.  But
it eases agenda clocking reviews tremendously.  I use git log for
displaying changes during an entry in the agenda.

I do not use MobileOrg because, when I last checked, the Android app
was not able to handle all my org files (it would need some fiddling
on what exactly I want mobile) and seemed to lack functionality
compared to the iphones.  Maybe I will give it another shot shortly.

I guess when you have synced org files across all your emacs instances,
pushing and pulling to mobileorg from any at (nearly) all times is possible.

I am glad to share the code, but it needs some cleanups and some stuff
is first emacs-lisp steps, clumsy and irresponsible.

Best,  

Gregor



Re: [Orgmode] org-git-link does not support locational information within file

2011-02-15 Thread Gregor Kappler
Hi Bastien,

Thanks for your answer. I was surprised and glad to hear so much interest in 
my particular problem.

On Fri, 11 Feb 2011 18:17:58 +0100, Bastien bastien.gue...@wikimedia.fr wrote:
   2. use git versioned files transparently, i.e. org-git-store-link
  should support search (org-ids and text files) in linked git
  revisions of files.
 
 I've look into this.  We could code things to add a search string:
 
   [[git:~/my.org::master@{2011-02-07}::Org code]]
  ^^
 
 ... but I'm reluctant to change the general syntax of links, even 
 if that's just for git links.

It might be better to stick to org-mode's convention of storing the location 
within the file after ::, a convention your current syntax is not adhering 
to.
I think you could stay consistent with the current general syntax of orgmode by 
switching from

[[git:~/my.org::master@{2011-02-11}::Org code]]

to

[[git:~/my.org@master{2011-02-11}::Org code]]
or 
[[git:~/my.org?master{2011-02-11}::Org code]]

This would fully break existing links.
Achim Gratz contributed some good points about changing the git-link syntax and 
made a more founded proposal for a changed syntax though. Achim seems to focus 
strongly on machine readability. For me, I like to be able to read links easily.


[[git:repository or file?revision information::location in file]]
revision information can be
- a date+time value (for me, time is important here)
- a SHA
- HEAD

 
   3. define an interactive function that can update the revision
  information of a link at mark to the current branch head of the
  file (so I can update all links to new FS folder structure.)
 
 You mean update
 
   [[git:~/my.org::master@{2011-02-07}::Org code]]
 
 to 
 
   [[git:~/my.org::master@{2011-02-11}::Org code]]
 
 ?
 
 Can you provide an explicit example?

Let the function be of name org-git-link-update-to-head.
I will adhere to the syntax in your post. 
I guess all scenarios can be made explicit by two conditions:

1. The file is still of the same name. Calling org-git-link-update-to-head on 

   [[git:~/my.org::master@{2011-02-11}::Org code]]

   would change the link to

   [[git:~/my.org::master@{2011-02-15}::Org code]]

   (today being the 15th)

2. more interesting is the case that the file was moved by e.g by

   git mv my.org your.org

   Then optimally git would be queried for the actual location of a newer 
version in HEAD (if unique). 
   (I am actually not sure how to do this with git, but should be viable)

   The link should be rewritten by org-git-link-update-to-head to
   [[git:~/your.org::master@{2011-02-15}::Org code]]


   This file might have been edited meanwhile by e.g. 

   echo * annoying tail heading  your.org  git add your.org  git commit 
-m 

   Still the new link should become
   [[git:~/your.org::master@{2011-02-14}::Org code]]

If HEAD would be added to the possible revision definition, 
org-git-link-update-to-head cannot identify the file after moving. On the other 
hand, having this function one would not want to point to head.

Another possibility would be not to rewrite links but to resolve the
current revision as outlined on the fly in org-open-at-point.

  I am still lame at elisp - so my implementation skills are
  limited. With the great work in org-git-link all backend stuff seems
  there, only needing more glue. Any hints how to achieve this would be
  very welcome!
 
 org-git-link.el is quite readable, and I'd welcome ideas on how to
 extend it to fulfill your wishes without extending Org's link syntax 
 too much...

I try to learn elisp bit by bit. Found a good tutorial finally.
I got busy times around me - need to constrain fiddle-time.


Cheers and thanks,

Gregor

-- 
--

Dr. Gregor Kappler

Fakultät für Psychologie 
Institut für Entwicklungspsychologie und 
Psychologische Diagnostik
http://www.univie.ac.at/Psychologie

Universität Wien
Liebiggasse 5
A-1010 Wien
mail: gregor.kapp...@univie.ac.at
tel: +43 1 4277 47866

___
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


Re: [Orgmode] org-git-link does not support locational information within file

2011-02-15 Thread Gregor Kappler
Hi Leo,

 However, I think the bigger problem with org-git-link in its current
 incarnation is that it forces me to use git:// links for all files
 under version control, which is NOT what I want to do 90% of the time.
  I have a quick hack to deal with this -- namely, commenting out
 
 ;; (add-hook 'org-store-link-functions 'org-git-store-link t)
 
 and using a separate keybinding for storing git links using the
 following function:
 
 (defun org-git-store-link-interactively (arg)
   Store git link to current file.
   (interactive P)
   (let ((org-store-link-functions (cons 'org-git-store-link
 org-store-link-functions)))
 (call-interactively 'org-store-link arg)
 ))

Thanks a lot for this!

 
 
 In addition, I'm not crazy about using the branch@{date} format for
 storing links by default, so I hacked something that uses SHA1
 instead...  I could post a patch if anyone is curious.
I would be interested, and I think SHA1 should be supported as it is so
common with git.

Cheers,
Gregor

-- 
--

Dr. Gregor Kappler

Fakultät für Psychologie 
Institut für Entwicklungspsychologie und 
Psychologische Diagnostik
http://www.univie.ac.at/Psychologie

Universität Wien
Liebiggasse 5
A-1010 Wien
mail: gregor.kapp...@univie.ac.at
tel: +43 1 4277 47866

___
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] org-git-link does not support locational information within file

2011-02-04 Thread Gregor Kappler
Hi org-moders,

I started using orgmode a while ago - and it revoluzionized my
workflow.  I could not keep up with my work without it!  Thanks for
the most versatile tool I ever used and still learn!

I recently found out about org-git-link 
(http://orgmode.org/worg/org-contrib/org-git-link.html), 
and realized it would be near perfect for my research usecase:

** Use Case: Project workflow with moving files, linked to in orgmode
1. Often projects do not arrive with a defined structure: In the
   initial phase I might get several data files and other documents -
   with little to no long-term specification.  Often it is unclear
   whether the files will evolve into some bigger coauthoring project
   involving data analyzes.
2. Consequently, in the initial phase of a project, my file management
   often is messy.  Only within my org files the structure is kept
   clean, respectively is evolving into an appropriate structure.  (I
   heavily use orgmode linking of files and mails.)  Also, (nearly)
   all files are kept in git.
3. I might be tidying file system folders several times during a
   project.
   1. This breaks links.
   2. I thought storing links to revisions of files would solve broken
  links, as links to moved files can be recovered with git.

I guess this might be a scenario some fellow org-moders are facing?

** Shortcomings of git-link in current org HEAD
Yet, org-git-link currently is too greedy for my daily use:
 1. they kill org-links for org headings, if the org files are
versioned in a git repository (and all of mine are!) and
 2. they kill in-file-search information for versioned non-org files.

** My ugly hack
My intermediate solution is to remove/add the git-link hook as
appropriate with
(add-hook 'org-store-link-functions 'org-git-store-link)
(remove-hook 'org-store-link-functions 'org-git-store-link)

** Proposal of a better solution
I think a better solution for me would be:
 1. use org-git-store-link.
 2. use git versioned files transparently, i.e. org-git-store-link
should support search (org-ids and text files) in linked git
revisions of files.
 3. define an interactive function that can update the revision
information of a link at mark to the current branch head of the
file (so I can update all links to new FS folder structure.)


I am still lame at elisp - so my implementation skills are
limited. With the great work in org-git-link all backend stuff seems
there, only needing more glue. Any hints how to achieve this would be
very welcome!


Thanks, Gregor


-- 
--

Dr. Gregor Kappler

Fakultät für Psychologie 
Institut für Entwicklungspsychologie und 
Psychologische Diagnostik
http://www.univie.ac.at/Psychologie

Universität Wien
Liebiggasse 5
A-1010 Wien
mail: gregor.kapp...@univie.ac.at
tel: +43 1 4277 47866

___
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