[Orgmode] Integrating ctags org mode (patch)

2009-12-14 Thread Paul Sexton
Hi,

I have managed to get exuberant ctags working with org mode. This means that
plain links [[like this]], instead of defaulting to plain text search when no
match is found in the current file, now look for a matching tag like this in
all your *.org files, and jumps there. 

This means your org files all now seamlessly talk to each other and interlink.
You can split that monolithic file up into smaller files and the plain links
still work. You can throw a plain link to a topic you know exists in another
file, without having to worry about the format of special inter-file links,
whether you got the directory right, and so on.

Steps:

1. First you need a small patch to org.el. This is necessary because AFAIK there
is no easy way to customise or advise org's behaviour when opening a plain link.
The patch is at the end of this post. 

2. Next you need to get exuberant ctags from http://ctags.sourceforge.net/
There is a windows executable there (a zip file). Many linux distributions have
'ctags-exuberant' as an installable package in their repositories.

If you are using windows, extract the ctags.zip file into a directory somewhere,
eg C:\emacs23\ctags

3. Now make a new file called .ctags in your HOME directory. If you are not sure
where this is, evaluate (getenv HOME) in the emacs scratch buffer.

Put the following 3 lines into this file, then save it:

--langdef=orgmode
--langmap=orgmode:.org
--regex-orgmode=/([^]+)/\1/d,definition/

The last line is a regular expression that defines what a tag is in orgmode. If
you don't like my definition based on angle brackets, or you want to add other
destinations as tags, just alter the bit between the first two /...slashes.../

4. Paste the following into your .emacs file:

(defvar home-dir /home/paul/) ; replace with your home dir

(defun operating-system ()
  (case system-type
((windows-nt cygwin) 'windows)
(darwin 'macos)
(otherwise 'unix)))

(defvar path-to-ctags 
  (case (operating-system)
(windows c:/emacs/ctags/ctags.exe)  ; or whereever you extracted it
(unix /usr/bin/ctags-exuberant)); wherever it went
  Path to the CTAGS executable.)

(defun create-tags (dir-name)
  Create tags file.
  (interactive DBase directory: )
  (shell-command
   (format %s --options=%s/.ctags -f %s/TAGS -e -R %s/*
   path-to-ctags home-dir dir-name dir-name)))

(global-set-key (kbd M-kp-multiply) 'pop-tag-mark)

(defadvice find-tag (before set-org-mark-before-finding-tag
activate compile)
  Before trying to find a tag, save our current position on org mark ring.
  (save-excursion
(if (org-mode-p)
(org-mark-ring-push

5. Now run create-tags:

M-x create-tags ENTER /path/to/org/files/ ENTER

create-tags searches all subdirectories as well, and will also create tags for
all source code files that if finds (*.c, *.lisp, *.el, etc). All these tags
will go in one big TAGS file, located in the base directory that you specify
as an argument to create-tags. Thus, if you have any large source trees in
subdirectories, create-tags may pause for a few seconds.

6. Check that the file 'TAGS' is in the right place and is not an empty file.

Tags is now ready to use. See below for usage. The first time you try and find
a tag, you will be asked which tags file to use. The right answer is the file
named TAGS which you created with create-tags.
To avoid being asked this every time you restart emacs, try putting this in your
.emacs:

(add-hook 'org-mode-hook
 (lambda () (visit-tags-table /path/to/TAGSfile) 

Tags are defined in the .ctags file as any text in double angle brackets.
(triple angle brackets work too)

When you click on a link [[foo]] and org cannot find a matching foo in
the current buffer, the tags facility will take over. The file TAGS is examined
to see if the tags facility knows about foo in any other files. If it
does, the matching file will be opened and the cursor will jump to the position
of foo in that file.

Important commands:
* M-. 
  Press to enter a tag name (default is a string extracted from the
  current cursor position) and then try  jump there. No autocompletion yet.
* C-M-. 
  as above, but search term is a regular expression
* M-x tags-search
  Also searches for a regexp, but searches through the *entire text* of
  all the files that the tags facility knows about. Jumps to the first match.
  Then, press M-, to jump to each successive match.
* M-* go back from a tag jump. (note: if you jumped from an org-mode buffer,
  your previous position will also have been saved on the org mark ring).

Tags mode has no way of knowing when you create new tags. So, any new link
targets you make after running create-tags will not be in the 'TAGS' file  so
will be unknown to the tags facility. For new tags to make it into the TAGS
file, you need to re-run (create-tags path) to refresh the file.

You also might want to put (create-tags /path/to/org/files) in your .emacs or
even ctags-exuberant -e 

[Orgmode] Re: Integrating ctags org mode (patch)

2009-12-15 Thread Paul Sexton
Carsten Dominik carsten.dominik at gmail.com writes:

 
 Hi Paul,
 
 I like this very much.  But I would like to change the implementation  
 so that
 there will be a hook.  Then people can do different things, including  
 matching tags in source code files etc.
 
 Would you be interested to turn your way of doing things into a little  
 add-on
 that people could load?  I realize that it would be a very small file  
 because the heavy lifting is done by the tags creating file and Emacs  
 ctags searches.  But it would keep the way open for other ideas.
 
 If you agree I will make a new hook and interface for this.
 
 I would be very interested to include the new module (if you write it)
 at least as a contributed package, or, if you are willing
 to sign the papers with the FSF, in the core.
 


I'm glad you like it. I would be happy for it to be included in the core.

Re your followup to this post: I have written a function which takes a tag name
and returns the file where it is found:


(defun get-filename-for-tag (tag)
  TAG is a string. Search the active TAGS file for a matching tag,
and if found, return a list containing the filename, line number, and
buffer position where the tag is found.
  (unless tags-file-name
(visit-tags-file-buffer))
  (with-current-buffer (get-file-buffer tags-file-name)
(beginning-of-buffer)
(cond
 ;; In the following line, the special characters on either side of
 ;; the %s should be ASCII 127 (^?) and ASCII 1 (^A)
 ((re-search-forward (format ^.*%s\\([0-9]+\\),\\([0-9]+\\)$
 (regexp-quote tag)) nil t)
  (let ((line (string-to-number (match-string 1)))
(pos (string-to-number (match-string 2
(cond
 ((re-search-backward \n\\(.*\\),[0-9]+\n)
  (list (match-string 1) line pos))
 (t  ; can't find a file name preceding the matched tag??
  (error Malformed TAGS file: %s (buffer-name))
  (t  ; tag not found
   nil





___
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] Re: Integrating ctags org mode (patch)

2009-12-15 Thread Paul Sexton
Also I realised there was a misplaced parenthesis in the (if (y-or-n-p...
clause. Corrected patch follows.

BEGIN PATCH for org.el (delete this line)
8349,8369c8349,8350
{ (condition-case nil (eval cmd)
{   ;; ORG-TAGS
{   (error
{(progn
{  (widen)
{  (condition-case nil (eval cmd)
{(error
{ ;; No matching link found anywhere in this file
{ ;; See if we can find a tag
{ ;; If so, jump to it
{(condition-case nil (find-tag path)
{  (error
{   (cond
{(org-make-new-topics-for-missing-links-p
{ (if (y-or-n-p
{  (format Topic `%S' not found; append to current
buffer?
{  path))
{ (org-append-new-topic path nil)))
{(t
{ (error No match found
{  
---
}   (condition-case nil (eval cmd)
} (error (progn (widen) (eval cmd))
8592,8595d8572
{  ;; ORG-TAGS
{  ((not org-open-link-defaults-to-normal-string-search-p)
{   ;; We don't want to search for a plain text match.
{   (error No match.))
8651,8682d8627
{ 
{ 
{ ;; ORG-TAGS
{ 
{ (defvar org-open-link-defaults-to-normal-string-search-p nil
{   Behaviour when attempting to open a 'thisfile' hyperlink for which no
{ EXACT match can be found (i.e. no match in angled brackets, etc).
{ If true (default), exhibit normal org behaviour of doing a search for a string
{ matching the link name.
{ If nil, abort the attempt to open the link.)
{ 
{ 
{ (defvar org-make-new-topics-for-missing-links-p nil
{   If true, when attempting to follow a 'plain' hyperlink for which no precise
{ match is found, offer to append a top-level heading with the same name as the
{ hyperlink, to the end of the buffer.)
{ 
{ 
{ (defun org-append-new-topic (word)
{   (interactive s)
{   (widen)
{   (end-of-buffer)
{   (newline 2)
{   (insert (format * %s word))  ;  to make radio word
{   (backward-char 4)
{   ;;(org-update-radio-target-regexp)
{   (end-of-line)
{   (newline 2)
{   (next-line 2))
{ 
{ 
{ 
END PATCH (delete this line)







___
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] Re: Integrating ctags org mode (patch)

2009-12-15 Thread Paul Sexton
Sorry guys, I seem to be spamming this topic, but I just fixed another problem
-- properties on the link string were causing problems with find-tag, which
expected a propertyless string.

Fixed patch follows.

BEGIN PATCH for org.el (delete this line)
8349,8369c8349,8350
{ (condition-case nil (eval cmd)
{   ;; ORG-TAGS
{   (error
{(progn
{  (widen)
{  (condition-case nil (eval cmd)
{(error
{ ;; No matching link found anywhere in this file
{ ;; See if we can find a tag
{;; If so, jump to it
{(let ((linktext path))
{  (set-text-properties 0 (length linktext)
{   nil linktext)
{  (condition-case nil (find-tag linktext)
{(error
{ (cond
{  (org-make-new-topics-for-missing-links-p
{   (if (y-or-n-p
{(format Topic `%S' not found; append to
current buffer?
{linktext))
{   (org-append-new-topic linktext nil)))
{  (t
{   (error No match found)
{ 
{  
---
}   (condition-case nil (eval cmd)
} (error (progn (widen) (eval cmd))
8592,8595d8572
{  ;; ORG-TAGS
{  ((not org-open-link-defaults-to-normal-string-search-p)
{   ;; We don't want to search for a plain text match.
{   (error No match.))
8651,8682d8627
{ 
{ 
{ ;; ORG-TAGS
{ 
{ (defvar org-open-link-defaults-to-normal-string-search-p nil
{   Behaviour when attempting to open a 'thisfile' hyperlink for which no
{ EXACT match can be found (i.e. no match in angled brackets, etc).
{ If true (default), exhibit normal org behaviour of doing a search for a string
{ matching the link name.
{ If nil, abort the attempt to open the link.)
{ 
{ 
{ (defvar org-make-new-topics-for-missing-links-p nil
{   If true, when attempting to follow a 'plain' hyperlink for which no precise
{ match is found, offer to append a top-level heading with the same name as the
{ hyperlink, to the end of the buffer.)
{ 
{ 
{ (defun org-append-new-topic (word)
{   (interactive s)
{   (widen)
{   (end-of-buffer)
{   (newline 2)
{   (insert (format * %s word))  ;  to make radio word
{   (backward-char 4)
{   ;;(org-update-radio-target-regexp)
{   (end-of-line)
{   (newline 2)
{   (next-line 2))
{ 
{ 
{ 
END PATCH (delete this line)






___
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] Re: OrgmodeWiki Support

2009-12-18 Thread Paul Sexton
Carsten Dominik carsten.dominik at gmail.com writes:
[snip]
 
 I think it would be useful to discuss this proposal first in a broader  
 sense.
 Let me try to make a start.
 
 A few days ago, Paul Sexton submitted his proposal for simple
 file-to-file links based on etags.
 
 He wanted to make [[sometext]] be a link to sometext where
 the target definition sometext can be in a different file.
 Furthermore, his proposal uses an external program to do the
 indexing of the tags, and following the links uses the etags
 code shipped with Emacs.
 
 Finally, Paul's proposal also contains a way to automatically
 create new topics when a link is called that does not yet have
 a target.
 
 Now we are talking about WikiWords, or CamelCase links.  Here the
 idea is that any such mixed-case word automatically is treated as a  
 link.
 Traditionally these links to a separate file with name given by the
 link text directly.  But I suppose it could also got to a target
 somewhere in a file?
 
 For a couple of reasons it seems to me that it would be useful
 to look at these proposals together.  For one thing, I am not
 a huge fan of the zillions of files that will be created when using
 the one-file-per-word approach.  Since Org-mode is outline based, it
 seem to make a lot of sense to have many topics per file.
 
 One way to move into this direction would be to still use etags
 to index the possible targets, and then to turn specific words
 (like CamelCase words) directly into links without the need to
 surround them with [[...]].
 
 But of course, we could also have an implementation as Adam
 proposes it, with CamelCase words linking to files, and
 then [[target]] linking to targets.
 
 Can we discuss this for a bit?
 
 - Carsten


Hi Carsten,

In the other thread, you say you have implemented a hook whose function(s) are
run when attempting to open a link. From your description it sounds like the
hook is run FIRST, and org's default behaviour only happens if the hook
functions don't override it. 

However, both the link-to-file-of-same-name proposal and my etags functionality
would be more easily implemented with a hook function that is called only when
org can't find a specific target for [[plain link]]. At the moment org defaults
to performing a full-text search for plain link. Both the wikiwords and the
etags behaviours need to happen instead of that default behaviour, but neither
needs to override the rest of org's link-opening behaviour. 

Re the WikiWords idea -- this could be done in 2 independent parts:
1. Option to tell org to interpret all CamelCase words as plain links (this
might be behaviour that some people want by itself)
2. Function, called when org can't find target for plain link, that tries to
open and visit a file with the same name as the link.

I think a hook to change the default behaviour of org when it can't find an
explicit target for a plain link is a very good idea and would probably lead to
other useful stuff. Personally I don't find the default behaviour of full-text
search to be useful.

Paul

P.S. My wishlist includes using a different colour to fontify links whose
targets don't exist (a la wikipedia with its undefined links in red). Can be
done, but not sure how to do it efficiently.










___
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-ctags released

2009-12-23 Thread Paul Sexton
Hi,
I have rewritten org-ctags, a package which allows org mode to use Emacs tags
to seamlessly navigate to link targets in other org files (as well as source
code files etc). See below for more of an explanation.

The patch to org.el now creates a hook, as suggested by Carsten. Basically, if a
[[plain link]] is not found in the current file, then each function in the list
'org-missing-link-functions' is tried in turn. Each of these functions takes one
argument (the link as a string eg plain link) and must return non-nil if it
has successfully handled the link, nil otherwise. The default behaviour is to
call a new function, 'org-string-search', which does what org used to do in this
situation (just search for the string as plain text).

org-ctags.el and the patch can be obtained from a repository at:

http://bitbucket.org/eeeickythump/org-ctags/

Further documentation, from org-ctags.el:

Synopsis


Allows org-mode to make use of the Emacs `etags' system. Defines tag
destinations in org-mode files as any text between double angled
brackets. This allows the tags-generation program `exuberant ctags' to
parse these files and create tag tables that record where these
destinations are found. Plain [[links]] in org mode files which do not have
matching destinations within the same file will then be interpreted as
links to these 'tagged' destinations, allowing seamless navigation between
multiple org-mode files. Topics can be created in any org mode file and
will always be found by plain links from other files. Other file types
recognised by ctags (source code files, latex files, etc) will also be
available as destinations for plain links, and similarly, org-mode links
will be available as tags from source files. Finally, the function
`org-ctags/find-tag-interactive' lets you choose any known tag, using
autocompletion, and quickly jump to it.

Installation


1. Install Emacs and org mode!
2. Put org-ctags.el somewhere in your emacs load path.
3. Apply the patch org-el-patch.txt to org.el. The command to do this
under Linux/Unix is:
   patch orgmode/lisp/org.el org-el-patch.txt 
4. Download and install Exuberant ctags -- http://ctags.sourceforge.net/;
5. Edit your .emacs file (see next section) and load emacs.

To put in your init file (.emacs):
==

I assume you already have org mode installed.

   (add-to-list 'load-path /path/to/org-ctags)
   (require 'org-ctags)
   (push /your/org/directory/ tags-table-list)
   (setq org-ctags/path-to-ctags /path/to/ctags/executable)
   ;; The sequence below first tries to find link as a tag, then
   ;; offers to rebuild the TAGS file before trying again, then finally
   ;; offers to append a topic * link to the end of current buffer.
   (setq org-missing-link-functions
'(org-ctags/find-tag
  org-ctags/ask-rebuild-tags-file-then-find-tag
  org-ctags/ask-append-topic))
   ;; Other functions you can put in the above list are:
   ;;   org-ctags/ask-visit-buffer-or-file -- for a link link, visits the
   ;; file link.org (optionally creating it if it doesn't exist)
   ;;   org-string-search -- the default (old) org behaviour
   (define-key org-mode-map \C-o 'org-ctags/find-tag-interactive) 
   (org-ctags/enable)



Usage
=

When you click on a link [[foo]] and org cannot find a matching foo
in the current buffer, the tags facility will take over. The file TAGS in
the active directory is examined to see if the tags facility knows about
foo in any other files. If it does, the matching file will be opened
and the cursor will jump to the position of foo in that file.

User-visible functions:
- `org-ctags/find-tag-interactive': type a tag (plain link) name and visit
  it. With autocompletion. Bound to ctrl-O in the above setup.
- All the etags functions should work. These include:

 M-.`find-tag' -- finds the tag at point

 C-M-.  find-tag based on regular expression

 M-x tags-search RET -- like C-M-. but searches through ENTIRE TEXT
of ALL the files referenced in the TAGS file. A quick way to
search through an entire 'project'.

 M-*go back from a tag jump. Like `org-mark-ring-goto'.
You may need to bind this key yourself with (eg)
(global-set-key (kbd M-kp-multiply) 'pop-tag-mark)

 (see etags chapter in Emacs manual for more)


Keeping the TAGS file up to date


Tags mode has no way of knowing that you have created new tags by typing in
your org-mode buffer.  New tags make it into the TAGS file in 3 ways:

1. You re-run (org-ctags/create-tags directory) to rebuild the file.
2. You put the function `org-ctags/ask-rebuild-tags-file-then-find-tag' in
   your `org-missing-link-functions' list, as is done in the setup
   above. This will cause the TAGS file to be rebuilt whenever a link
   cannot be found. This may be slow with large file collections however.
3. You run the following from the 

[Orgmode] Re: Org-ctags released

2009-12-24 Thread Paul Sexton
Happy Xmas everyone.

I have updated org-ctags to use an existing hook which has recently been added
to the development version of org-mode by Carsten. So now, no patch is needed.

I have also fixed a couple of bugs.

Latest version can be downloaded at:
http://bitbucket.org/eeeickythump/org-ctags/

Paul




___
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] Programmers, use org to write your doc strings...

2010-03-02 Thread Paul Sexton
Hi

I think org is a good platform for writing documentation for
source code.  The babel module is one approach, but it presumes
that org is the dominant major mode, and the actual source code
is divided into snippets here and there.

I wanted to look into another way of doing it: the source  code's
mode is dominant, with snippets of org mode here and there. Babel
in reverse if you will.

I have used mmm-mode, which is part of nXhtml mode, which  you
can download at:

http://ourcomments.org/cgi-bin/emacsw32-dl-latest.pl

I have managed to get it working for common lisp. Users of  other
programming languages should easily be able to achieve the same
effect by modifying the elisp code below.

In a lisp buffer, documentation strings use org mode as their
major mode, while the rest of the file uses lisp-mode. All the
fontification works, as does formatting of bulleted lists
etc. Hyperlink overlays don't work (you see [[the whole][link]]
rather than the short form), but the links themselves work.

We define a docstring as:
1. A string which emacs has fontified using the font lock 
   docstring face
2. A string that comes after '(:documentation '
3. A string whose first three characters are ### 

MMM-mode sometimes seems to need a bit of a poke to recognise new
docstrings.  If it's not recognising things that it should, press
ctrl-` to refresh it.

My motivation is that I have written a doxygen-like program for
common lisp, called CLOD, whose output is an org mode file. You
can use org mode markup in common lisp docstrings, and the markup
will be understood when the docstrings are read by CLOD. Now, I
can edit those docstrings within the lisp source file and get all
org's fontification, at formatting of bulleted lists, hyperlinks,
etc. All without leaving emacs.

Paul


-contents of .emacs follows---


(add-to-list 'load-path /path/to/mmm-mode))
(require 'mmm-auto)
(setq mmm-global-mode 'maybe)
(mmm-add-mode-ext-class 'lisp-mode  nil  'org-submode)
(mmm-add-mode-ext-class 'slime-mode  nil  'org-submode)
;; The above, using major mode symbols, didn't seem to work for 
;; me so I also added these line (regexp uses same format as 
;; major-mode-alist):
(mmm-add-mode-ext-class nil  \\.lisp$  'org-submode)
(mmm-add-mode-ext-class nil  \\.asd$  'org-submode)
(setq mmm-submode-decoration-level 2)

;; This prevents transient loss of fontification on first
;; calling `mmm-ify-by-class'
(defadvice mmm-ify-by-class (after refontify-after-mmm 
 activate compile)
  (font-lock-fontify-buffer))

;; bind control-backquote to refresh MMM-mode in current buffer.
(global-set-key [?\C-`] (lambda () (interactive)
  (mmm-ify-by-class 'org-submode)))

;; And the definition of 'org-submode
(mmm-add-group 'org-submode
   '((org-submode1
  :submode org-mode
  ;; This face supplies a background colour for org
  ;; parts of the buffer. Customizable.
  :face mmm-declaration-submode-face
  :front \
  :back [^\\]\
  :back-offset 1
  :front-verify check-docstring-match
  :end-not-begin t)
 (org-submode-2
  :submode org-mode
  :face mmm-declaration-submode-face
  ;; Match '(:documentation ...)' docstrings
  :front (:documentation[\t\n ]+\
  :back [^\\]\
  :back-offset 1
  :end-not-begin t)))

(defun face-at (pos)
  (save-excursion
(goto-char pos)
(face-at-point)))


(defun check-docstring-match ()
  (interactive)
  (let ((beg (match-beginning 0))
(end (match-end 0)))
  (cond
   ;; Docstring if emacs has fontified it in 'docstring' face
   ((eql (face-at end) 'font-lock-doc-face)
t)
   ;; Docstring if the first three characters after the opening
   ;; quote are ###
   ((string= (buffer-substring end (+ 3 end)) ###)
t)
   (t
nil






___
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] Active, fontified org hyperlinks in any major mode

2010-03-11 Thread Paul Sexton
To activate and correctly fontify org [[hyperlinks]] in any
major mode, add the following to your .emacs:

(defun orgl-do-font-lock (add-or-remove)
  Add or remove font-lock rules for org hyperlinks.
  (funcall add-or-remove nil '((org-activate-bracket-links (0 'org-link t)


(defun orgl-enable ()
  Enable fontification of org-style hyperlinks in the current buffer.
  (interactive)
  ;; The following variable has to be bound to a string, or opening links
  ;; will not work.
  ;; There is probably a more elegant solution.
  (unless org-todo-line-tags-regexp
(set (make-local-variable 'org-todo-line-tags-regexp)
 DSFSFSFSF_UTTER_NONSENSE_TAG_SDSDFSFDF))
  (orgl-do-font-lock 'font-lock-add-keywords)
  (font-lock-fontify-buffer))


(defun orgl-disable ()
  Disable fontification of org-style hyperlinks in the current buffer.
  (interactive)
  (remove-text-properties
 (point-min) (point-max)
   '(mouse-face t keymap t org-linked-text t
invisible t intangible t
org-no-flyspell t))
  (orgl-do-font-lock 'font-lock-remove-keywords)
  (font-lock-fontify-buffer))


;; Change lisp-mode-hook to whatever you want
(add-hook 'lisp-mode-hook 'orgl-enable)


I was amazed at how easy this was. The most obvious use for me is to put
[[hyperlinks]] in source code comments. The link behaves the same as in org 
mode, i.e. by default it looks for a matching target, then searches for
the text of the link starting from the top of the buffer.

Useful extensions would be:
- Figure out how to force hiding of the [[ ... ]] brackets. They disappear 
  only if the text is in the 'default' face.
- Fontification of targets to make them stand out would be useful
- Figure out how to define special link types outside org mode proper.
  eg in an emacs lisp file it would be good if the link [[defun:my-function]]
  would jump to a (defun my-function  toplevel form.

Paul







___
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


[O] Markdown export (using org-export-generic)

2011-08-16 Thread Paul Sexton
Wes Hardaker's org-export-generic (in worg) does a pretty good job of 
exporting to markdown syntax. The following works (use C-c C-e g to 
run the exporter):

(require 'org-export-generic)
(org-set-generic-type
 markdown 
 '(:file-suffix .markdown
   :key-binding ?M
   :title-formatTitle: %s\n
   :date-format Date: %s\n
   :toc-export  nil
   :author-export   t
   :tags-export nil
   :drawers-export  nil
   :date-export t
   :timestamps-export  t
   :priorities-export  nil
   :todo-keywords-export t
   :body-line-fixed-format \t%s\n
   ;:body-list-prefix \n
   :body-list-format - %s
   :body-list-suffix \n
   :header-prefix (  ###    #  ## )
   :body-section-header-prefix (  ###    #  ## )
   :body-section-header-format %s\n
   :body-section-header-suffix (?= ?- )
   :body-header-section-numbers nil
   :body-header-section-number-format %s) 
   :body-line-format %s\n
   :body-newline-paragraph \n
   :bold-format **%s**
   :italic-format _%s_
   :verbatim-format `%s`
   :code-format `%s`
   :body-line-wrap   75
   ))

There are some defects however, which an't really be fixed without altering
the exporter code. The main ones are:

1. Nested lists don't seem to be supported.

2. Tables come out as:

col 1col 2
---+---
 1   2
 3   4

But need to look like this:

|col 1  | col 2 |
|---|---|
| 1 |  2|
| 3 |  4|

3. Links are not exported correctly.

A link [[http://www.google.com][like this]] comes out as

A link [like this]
...
[like this]: http://www.google.com

But need to look either like:

A link [like this][1]
...
[1]: http://www.google.com

Or like:

A link [like this](http://www.google.com)

Paul





Re: [O] Markdown export (using org-export-generic)

2011-08-17 Thread Paul Sexton
Jambunathan K kjambunathan at gmail.com writes:
 May be you could cook something up with org-lparse? The file is in
 contrib dir and org-xhtml and ord-odt make use of it.

Thanks, it looks interesting, but I can't find any documentation?







Re: [O] Bug? in the latest revision of org

2011-10-27 Thread Paul Sexton
Marcelo de Moraes Serpa celoserpa at gmail.com writes:

 
 Hey list,Just updated to the latest rev. of org in git. When I try to press 
ret just in the beginning of a headline in order to move it one line below, 
I'm getting this error message:: Wrong type argument: listp, org-level-1Any 
ideas?Marcelo.

Yes, it's a bug - I was just about to post about it myself.

The problem is in the recent change to the 'org-return' function in org.el.
(commit de8cd8ee41543bb0548af1cdc7fa7a8168321677 on 26 Oct).

The original code was:

   ((and org-return-follows-link
 (eq (get-text-property (point) 'face) 'org-link))

The commit changed it to:

   ((and org-return-follows-link
 (or (eq (get-text-property (point) 'face) 'org-link)
 (memq 'org-link (get-text-property (point) 'face

But this breaks if there is a single face at point that is not org-link, 
because in that case the text property at point will not be a list, 
and this will cause an error when it is given as the second argument 
to memq.

The code needs to change to something like:

   ((and org-return-follows-link
 (let ((tprop (get-text-property (point) 'face)))
   (or (eq tprop 'org-link)
   (and (listp tprop) (memq 'org-link tprop)

Paul.






[Orgmode] org-babel: Bugs with inline src_* blocks

2011-02-14 Thread Paul Sexton
I am experiencing a couple of significant bugs with inline src blocks in 
org-babel -- ie blocks of the form src_LANG{EXPRESSION}. I am using the
development version of org, checked out a few days ago. 

Pressing C-c C-c with the cursor on such a block is supposed to evaluate it and 
echo the result to the minibuffer. However in recent versions of org (the last 
3 months or so) this behaviour has become broken, at least for me.

The following is an example file.

--start---
#+BABEL: :session s1 :exports value latex :results raw

#+BEGIN_SRC R :results none :exports none 
1+2+3
#+END_SRC

src_R{1+1}
--end

Pressing C-c C-c with the cursor on the inline block produces the error:

  'R' is not recognized as an internal or external command,
  operable program or batch file.

This happens even if the session named s1 is already running. However, if I
first evaluate the BEGIN_SRC ... END_SRC block, using
org-babel-execute-src-block, and then reattempt to evaluate the inline block, it
will work. If I then press C-c C-c on the '#+BABEL:' line at the start of the
file, the inline block goes back to producing the error.

The second, and more aggravating, error is do with the consequences of
evaluating inline blocks. Formerly the result would be echoed in the 
minibuffer, and the document itself would not be altered. Now org has taken to 
inserting the result after the block, the same behaviour as a non-inline block. 
The header arguments used for this insertion seem to carry over either from the 
previous non-inline block, or possibly the global settings (BABEL: line). 

So for example, if I press C-c C-c on the src_R{1+1} above, I get:

---
src_R{1+1} #+BEGIN_LaTeX
2#+END_LaTeX

---

I want inline code blocks to replace themselves with their result when 
exporting the document to latex etc. I *never* want them to paste their results
into the document while editing - that is what non-inline blocks are for.

Is this change in behaviour intentional? If so is there a setting that will
revert to the old behaviour?

Paul





___
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] Context-sensitive word count in org mode (elisp)

2011-02-15 Thread Paul Sexton
I am trying to reduce the word count in a document I am writing. The
existing word count functionality for emacs is surprisingly lacking.
I wanted a word count function for org mode which excluded tables and 
comments, and ended up writing one myself. 

If this function is called with a region highlighted, it counts the words in
the region. Otherwise it counts words in the whole buffer.

It ignores commented lines and tables. LaTeX-style macros such as 
\foo{bar,baz} are counted as 1 word, as a compromise (more often than not 
they should count as 0, but they do sometimes expand to 1 or more words
in the final document). 

Limitations:
- Does not ignore BEGIN_SRC/END_SRC or inline src_* blocks (babel).
  Should be easy enough to add however.
- There is probably a better way of identifying latex macros
  than my 'latex-macro-regexp' below.
- Ignores all org links. I couldn't figure out how to extract description
  text from links, but I didn't look very hard.

Improvements welcome.

Paul



(defun in-comment-p ()
  Return non-nil if point is in a comment.
  (if (or (null comment-start-skip)
  (eq (preceding-char) ?\r))
  nil
(save-excursion
  (let ((pos (point)))
(re-search-backward ^\\|\r nil t)
(or (looking-at comment-start-skip)
(re-search-forward comment-start-skip pos t))

(defun in-org-table-p ()
  Return non-nil if point is in an org-mode table.
  (if (or (not (boundp 'org-table-any-line-regexp))
  (null org-table-any-line-regexp)
  (eq (preceding-char) ?\r))
  nil
(save-excursion
  (let ((pos (point)))
(re-search-backward ^\\|\r nil t)
(looking-at org-table-any-line-regexp)


(defvar latex-macro-regexp [A-Za-z]+\\(\\[[^]]*\\]\\|\\){\\([^}]*\\)})


(defun org-word-count (beg end)
  (interactive r)
  (unless mark-active
(setf beg (point-min)
  end (point-max)))
  (let ((wc 0))
(save-excursion
  (goto-char beg)
  (while ( (point) end)
(re-search-forward \\w+\\W*)
(cond
 ((or (in-comment-p) (in-org-table-p))
  nil)
 ((looking-at org-any-link-re)
  (goto-char (match-end 0)))
 ((save-excursion
(backward-char)
(looking-at latex-macro-regexp))
  (goto-char (match-end 0))
  (setf wc (+ 2 wc)))
 (t
  (incf wc)
(message (format %d words in %s. wc
 (if mark-active region buffer)



___
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] Re: Context-sensitive word count in org mode (elisp)

2011-02-16 Thread Paul Sexton
Christian Moe mail at christianmoe.com writes:

 
 Forgot to add the code.
 
 #+begin_src emacs-lisp
;; Adapted from code posted by Paul Sexton 2011-02-16 Wed 4:51am
;; - Everything now contained in one function
;; - Will count correct number of words inside Latex macro
 
(defun org-word-count (beg end)
(interactive r)
(unless mark-active
  (setf beg (point-min)
 end (point-max)))
(let ((wc 0)
   (latex-macro-regexp [A-Za-z]+\\(\\[[^]]*\\]\\| 
 \\){\\([^}]*\\)}))   ; CHANGED
  (save-excursion
(goto-char beg)
(while ( (point) end)
  (re-search-forward \\w+\\W*)
  (cond
   ((or (org-in-commented-line) (org-at-table-p)) ; CHANGED
nil)
   ((looking-at org-any-link-re)
(goto-char (match-end 0)))
   ((save-excursion
  (backward-char)
  (looking-at latex-macro-regexp))
(goto-char (match-beginning 2))  ; CHANGED
(setf wc (+ 2 wc)))
   (t
(incf wc)
  (message (format %d words in %s. wc
   (if mark-active region buffer)
 #+end_src
 

Thanks, I wasn't aware of those pre-existing functions.

I don't agree with changing '(match-end 0)' to '(match-beginning 2)'
however. For most latex macros, I don't want to count the words inside
the macro's arguments. For example, I don't want the next of footnotes
to be included in the word count. However others differ, and there will
always be cases where one DOES want to count the macro arguments - so maybe
org-word-count should do this optionally.

Paul




___
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] Re: Context-sensitive word count in org mode (elisp)

2011-02-16 Thread Paul Sexton
Thanks for all the suggestions. Here is version 2.

Improvements:
- ignores source code blocks
- ignores tags and TODO keywords in headings
- ignores footnotes by default (option to force counting them)
- skips any sections tagged as not for export
- option to count words in latex macro arguments (they are ignored
  by default)

I would still like to count hyperlink descriptions but am not sure
how -- is there a function that fetches the description of the hyperlink
at point?

Paul

---

(defun org-word-count (beg end
   optional count-latex-macro-args?
   count-footnotes?)
  Report the number of words in the Org mode buffer or selected region.
Ignores:
- comments
- tables
- source code blocks (#+BEGIN_SRC ... #+END_SRC, and inline blocks)
- hyperlinks
- tags, priorities, and TODO keywords in headers
- sections tagged as 'not for export'.

The text of footnote definitions is ignored, unless the optional argument
COUNT-FOOTNOTES? is non-nil.

If the optional argument COUNT-LATEX-MACRO-ARGS? is non-nil, the word count
includes LaTeX macro arguments (the material between {curly braces}).
Otherwise, and by default, every LaTeX macro counts as 1 word regardless
of its arguments.
  (interactive r)
  (unless mark-active
(setf beg (point-min)
  end (point-max)))
  (let ((wc 0)
(latex-macro-regexp [A-Za-z]+\\(\\[[^]]*\\]\\|\\){\\([^}]*\\)}))
(save-excursion
  (goto-char beg)
  (while ( (point) end)
(re-search-forward \\w+\\W*)
(cond
 ;; Ignore comments.
 ((or (org-in-commented-line) (org-at-table-p))
  nil)
 ;; Ignore hyperlinks.
 ;; TODO need to count text of the link's description.
 ((looking-at org-any-link-re)
  (goto-char (match-end 0)))
 ;; Ignore source code blocks.
 ((org-in-regexps-block-p ^#\\+BEGIN_SRC\\W ^#\\+END_SRC\\W)
  nil)
 ;; Ignore inline source blocks, counting them as 1 word.
 ((save-excursion
(backward-char)
(looking-at org-babel-inline-src-block-regexp))
  (goto-char (match-end 0))
  (setf wc (+ 2 wc)))
 ;; Count latex macros as 1 word, ignoring their arguments.
 ((save-excursion
(backward-char)
(looking-at latex-macro-regexp))
  (goto-char (if count-latex-macro-args?
 (match-beginning 2)
   (match-end 0)))
  (setf wc (+ 2 wc)))
 ;; Ignore footnotes.
 ((and (not count-footnotes?)
   (or (org-footnote-at-definition-p)
   (org-footnote-at-reference-p)))
  nil)
 (t
  (let ((contexts (org-context)))
(cond
 ;; Ignore tags and TODO keywords, etc.
 ((or (assoc :todo-keyword contexts)
  (assoc :priority contexts)
  (assoc :keyword contexts)
  (assoc :checkbox contexts))
  nil)
 ;; Ignore sections marked with tags that are
 ;; excluded from export.
 ((assoc :tags contexts)
  (if (intersection (org-get-tags-at) org-export-exclude-tags
:test 'equal)
  (org-forward-same-level 1)
nil))
 (t
  (incf wc
(message (format %d words in %s. wc
 (if mark-active region buffer)





___
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] Re: Context-sensitive word count in org mode (elisp)

2011-02-16 Thread Paul Sexton
That looks really good. My suggestion would be to modify it so that
'wc-count' can be redefined on a per-major-mode or per-buffer basis,
eg via a buffer-local variable 'wc-count-function'.

Then my org-word-count function could be slotted in fairly easily - 
I would just have to modify it so that it *returns* the count, rather
than reporting it.

Paul





___
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] Re: Context-sensitive word count in org mode (elisp)

2011-02-17 Thread Paul Sexton
Samuel Wales samologist at gmail.com writes:
 
 This looks great.
 
 How hard do you think it would be to show how many words there are for
 every subtree in a similar way to how clock durations are summed in
 c-c c-x c-d and displayed in the subtree itself in reverse video?

I might leave that functionality to you -- it's pretty far beyond what I need 
out of a word count function.

Cheers
P



___
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] Re: Context-sensitive word count in org mode (elisp)

2011-02-20 Thread Paul Sexton
Bastien bastien.guerry at wikimedia.fr writes:
 #+begin_src emacs-lisp
   (when (looking-at org-bracket-link-analytic-regexp)
 (match-string-no-properties 5))
 #+end_src emacs-lisp

Thanks. Here is version 3 if the function, which is now able to count 
words in link descriptions.

The code to advance to the next word has been moved to the end of the 
loop, which improves accuracy.

Paul

--

(defun org-word-count (beg end
   optional count-latex-macro-args?
   count-footnotes?)
  Report the number of words in the Org mode buffer or selected region.
Ignores:
- comments
- tables
- source code blocks (#+BEGIN_SRC ... #+END_SRC, and inline blocks)
- hyperlinks (but does count words in hyperlink descriptions)
- tags, priorities, and TODO keywords in headers
- sections tagged as 'not for export'.

The text of footnote definitions is ignored, unless the optional argument
COUNT-FOOTNOTES? is non-nil.

If the optional argument COUNT-LATEX-MACRO-ARGS? is non-nil, the word count
includes LaTeX macro arguments (the material between {curly braces}).
Otherwise, and by default, every LaTeX macro counts as 1 word regardless
of its arguments.
  (interactive r)
  (unless mark-active
(setf beg (point-min)
  end (point-max)))
  (let ((wc 0)
(latex-macro-regexp [A-Za-z]+\\(\\[[^]]*\\]\\|\\){\\([^}]*\\)}))
(save-excursion
  (goto-char beg)
  (while ( (point) end)
(cond
 ;; Ignore comments.
 ((or (org-in-commented-line) (org-at-table-p))
  nil)
 ;; Ignore hyperlinks. But if link has a description, count
 ;; the words within the description.
 ((looking-at org-bracket-link-analytic-regexp)
  (when (match-string-no-properties 5)
(let ((desc (match-string-no-properties 5)))
  (save-match-data 
(incf wc (length (remove  (org-split-string
 desc \\W)))
  (goto-char (match-end 0)))
 ((looking-at org-any-link-re)
  (goto-char (match-end 0)))
 ;; Ignore source code blocks.
 ((org-in-regexps-block-p ^#\\+BEGIN_SRC\\W ^#\\+END_SRC\\W)
  nil)
 ;; Ignore inline source blocks, counting them as 1 word.
 ((save-excursion
(backward-char)
(looking-at org-babel-inline-src-block-regexp))
  (goto-char (match-end 0))
  (setf wc (+ 2 wc)))
 ;; Count latex macros as 1 word, ignoring their arguments.
 ((save-excursion
(backward-char)
(looking-at latex-macro-regexp))
  (goto-char (if count-latex-macro-args?
 (match-beginning 2)
   (match-end 0)))
  (setf wc (+ 2 wc)))
 ;; Ignore footnotes.
 ((and (not count-footnotes?)
   (or (org-footnote-at-definition-p)
   (org-footnote-at-reference-p)))
  nil)
 (t
  (let ((contexts (org-context)))
(cond
 ;; Ignore tags and TODO keywords, etc.
 ((or (assoc :todo-keyword contexts)
  (assoc :priority contexts)
  (assoc :keyword contexts)
  (assoc :checkbox contexts))
  nil)
 ;; Ignore sections marked with tags that are
 ;; excluded from export.
 ((assoc :tags contexts)
  (if (intersection (org-get-tags-at) org-export-exclude-tags
:test 'equal)
  (org-forward-same-level 1)
nil))
 (t
  (incf wc))
(re-search-forward \\w+\\W*)))
(message (format %d words in %s. wc
 (if mark-active region buffer)





___
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


[O] [babel] By default, code blocks should not be evaluated during export

2011-04-07 Thread Paul Sexton
The default value of `org-export-babel-evaluate' is t. 

Having just crashed my Emacs session 5 times in a row trying to get
a file containing a BEGIN_SRC emacs-lisp ... END_SRC *code example*
to export to HTML...

I strongly feel it should default to nil.

I also feel that executable code block and quoted code example that I would
like to display/export with pretty syntax highlighting are two very different
concepts, and should have different block names.

eg #+BEGIN_EXEC for the executable blocks?
or allow an argument to example blocks, eg #+BEGIN_EXAMPLE python ?

Paul





[O] Org-drill updated, now at v2.1

2011-04-12 Thread Paul Sexton
I Just thought I would let people know I have made extensive updates to 
org-drill recently. Org-drill uses orgmode topics as flashcards for 
self-testing,
using spaced repetition algorithms like those used in programs such as
SuperMemo, Anki and Mnemosyne. It resides in the contrib directory but has its
own repository at

http://bitbucket.org/eeeickythump/org-drill

Highlights of recent changes:
- new spaced repetition algorithm: a simplified version of SuperMemo SM8,
  in addition to existing SM5 and SM2 algorithms.
- SM5 matrix of optimal factors is now correctly stored as a single
  persistent value, rather than per-item.
- better prioritisation of items within sessions: first failed items, then
  overdue items, then recently learned items, then finally a mix of older +
  new (unlearned) items.
- can now resume drill sessions where you left off, after exiting them via
  edit or quit commands (extremely useful)
- comments and item titles are optionally hidden during review
- almost all customisable variables are declared safe to be file-local

I have used org-drill every day for many months (currently learning Spanish 
using it) and it seems to be pretty robust. If any of you use Anki, etc, 
regularly, please have a look at org-drill -- you may find there is yet 
another job which Emacs can take over for you.

Cheers
Paul





[O] [patch] make 'org-save-outline-visibility' return a useful value

2011-04-21 Thread Paul Sexton
The macro 'org-save-outline-visibility' in org-macs.el seems like 
it should return the value of the last statement in its body (like 
save-excursion and save-restriction do). Instead it discards this
value and returns nothing useful.

The macro is only used in 2 places in the org sources, and its
return value is ignored in both. I feel it would be more useful if 
it returned the value of the last expression in its body. A patch 
to this effect is attached.

Paul



--- C:/Users/paul/org-macs.el   Fri Apr 22 14:57:07 2011
+++ C:/Users/paul/org-macs-new.el   Fri Apr 22 14:56:51 2011
@@ -325,8 +325,9 @@
   (declare (indent 1))
   `(let ((data (org-outline-overlay-data ,use-markers)))
  (unwind-protect
+(prog1
 (progn
-  ,@body
+   ,@body)
   (org-set-outline-overlay-data data))
(when ,use-markers
 (mapc (lambda (c)





[O] Audio/video file playback in org mode

2011-06-09 Thread Paul Sexton
I have spent a few hours figuring this out so I thought I would post it for
the benefit of others.

I am learning a language, and wanted to include hyperlinks to audio files
within my org document, and be able to play each file by clicking on the
link. 

I eventually discovered the variable 'org-file-apps' which allows you to
associate particular applications with particular file types. 

I am using Bongo (https://github.com/dbrock/bongo) as the media player.
EMMS is another actively developed media player, but setup looked too 
complicated at first glance.

I am using MPlayer as the actual media player. This supports almost all 
audio and video file formats. Most importantly, it works on Windows as well
as on Linux (VLC has a Windows port but it doesn't work with Bongo as the
'fake-tty' interface is not implemented on Windows.)

My current setup means that clicking on a link such as [[file:song.mp3]] 
adds it to the active Bongo playlist (in another buffer) and immediately 
starts playing it. Playback can be paused, fast-forwarded etc using 
Bongo.

When Bongo plays a file it puts some icons in the modeline that
resemble the 'play', 'stop' etc symbols, and can be used to control
playback using the mouse. I found these worked erratically outside 
the actual Bongo playlist buffer, so I have instead bound some 
org-mode keys (ctrl + numpad keys) to the relevant functions.
This is optional of course.

I have only tested this with mp3 files, but it ought to work with
video as well.


My setup follows:
---

;;; Part 1. Bongo setup

(add-to-list 'load-path /path/to/bongo))
(autoload 'bongo bongo
  Start Bongo by switching to a Bongo buffer. t)

(setq bongo-mplayer-program-name
  (case system-type
((windows-nt cygwin) c:\\Program Files\\MPlayer for 
Windows\\MPlayer.exe)
(t mplayer)))

(setq bongo-enabled-backends '(mplayer))

;;; Part 2. Org setup

(defvar av-file-regex
  (concat \\. (regexp-opt
 (append bongo-audio-file-name-extensions
 bongo-video-file-name-extensions)) $))

(add-to-list 'org-file-apps
 (cons av-file-regex '(org-play-media-file file)))

(defun org-play-media-file (filename)
  (with-bongo-buffer
(bongo-insert-file filename)
(backward-char)
(bongo-play)))

;;; Part 3. Keybindings to allow control of playback within Org buffer
;;; (optional)

;; Numpad Ctrl-0: pause/resume
(define-key org-mode-map (kbd C-kp-0) 'bongo-pause/resume)
(define-key org-mode-map (kbd C-kp-insert) 'bongo-pause/resume)
;; Numpad Ctrl-.: stop current track, or restart from beginning if stopped
(define-key org-mode-map (kbd C-kp-decimal) 'bongo-start/stop)
(define-key org-mode-map (kbd C-kp-delete) 'bongo-start/stop)
;; Numpad Ctrl-PgUp, Ctrl-PgDn: raise/lower volume
(define-key org-mode-map (kbd C-kp-prior) 'bongo-volume-raise)
(define-key org-mode-map (kbd C-kp-next) 'bongo-volume-lower)
(define-key org-mode-map (kbd C-kp-9) 'bongo-volume-raise)
(define-key org-mode-map (kbd C-kp-3) 'bongo-volume-lower)
;; Numpad Ctrl-left, Ctrl-right: skip back/forward 10 seconds
(define-key org-mode-map (kbd C-kp-left) 'bongo-seek-backward-10)
(define-key org-mode-map (kbd C-kp-right) 'bongo-seek-forward-10)
(define-key org-mode-map (kbd C-kp-4) 'bongo-seek-backward-10)
(define-key org-mode-map (kbd C-kp-6) 'bongo-seek-forward-10)






Re: [O] Org-Drill first interval

2011-06-09 Thread Paul Sexton
Curt Bergmann curt.bergmann at visi.com writes:

 
 The first interval for my first question is always 4 whether I mark it 
as a 3,
 4, or 5. When I change org-drill-learn-factor it doesn't appear to 
change the
 first interval.
 
 I would like to reduce the first interval and I assume that the 
learn-factor
 will allow me to control subsequent intervals.  Anki has an option 
to select the
 first interval for each of its answer qualities. If there is no 
option and you
 can send me a patch I'd be happy to try that as well.

Hi, I'm the author of org-drill. I assume you are using the SM5 spaced 
repetition algorithm (default). The reason that the first interval is always
4 days is because this is specified in that algorithm. And the way that the 
learn-fraction is applied in that algorithm means that it can never have much 
of an effect on early intervals -- its effect becomes apparent later.

However, I have committed a change to org-drill.el which implements a new
variable, org-drill-sm5-initial-interval. Its default value is 4 but you can
change it to another value if you wish.

This change has been committed to the org-drill devel repository at:

https://bitbucket.org/eeeickythump/org-drill

You will need to download the file from there. I have not yet sent it to the
main org repo.

HTH
Paul







Re: [O] Audio/video file playback in org mode

2011-06-10 Thread Paul Sexton
Thanks Michael, I'm glad you think it will be helpful. I have implemented
something like what you have requested here. I have hived this code off 
into a separate file called org-player.el.

You can get it at:

http://bitbucket.org/eeeickythump/org-player/

I intend to add it to worg in the next little while.

Links can now contain times to start playback, as follows:

[[file:/path/to/song.mp3::2:43]]  Starts playback at 2 min 43 sec.
[[file:/path/to/song.mp3::1:10:45]]   Starts playback at 1 hr 10 min 45 sec.
[[file:/path/to/song.mp3::3m15s]] Starts playback at 3 min 15 sec.
[[file:/path/to/song.mp3::49s]]   Starts playback at 0 min 49 sec.
[[file:/path/to/song.mp3::1h21m10s]]  Starts playback at 1 hr 21 min 10 sec.

As you see I have made XX:YY mean minutes and seconds, as it seems more 
logical to me for this particular purpose. If there is a compelling reason 
to interpret XX:YY as hours and minutes in these links then I am not totally
 opposed to changing it, but I think many people would find it confusing and 
counterintuitive.

In all cases playback continues until the end of the file. I couldn't find 
a way to implement playback of 'snippets' with a specified start and end 
time, unfortunately.

Cheers
Paul







Re: [O] Audio/video file playback in org mode

2011-06-10 Thread Paul Sexton
brian powell briangpowellms at gmail.com writes:


 * Something like this; respectively!?: 
 
 [[shell:mplayer -ss 00:03:21 -endpos 00:06:54 ~/some_podcast.mp3 ]]
 [[shell:mplayer -ss 00:03:21 ~/some_podcast.mp3 ]]
 [[shell:mplayer ~/some_podcast.mp3 ]]

The troubles with using shell commands in hyperlinks:
1. Only works in the operating system and directory structure where
   you were when you wrote the link;
2. No ability to stop playback, pause, etc, unless you run the
   program as a GUI, which means (horror!) doing something outside 
   Emacs.

 VLC works great for this too.

In windows VLC works as a shell command, but doesn't work with Bongo.

 P.S. Thanks for the link to BONGO--the EMACS buffer media player.
 I made my own buffer media player and have used it for many years; but,
BONGO.el is wayly kuul too!

You're welcome. Are you aware of EMMS, it seems to be Bongo's main rival (I
haven't tried it).

Paul





Re: [O] #+begin_example broken when #+begin_src included inside?

2011-06-13 Thread Paul Sexton
Nick Dokos nicholas.dokos at hp.com writes:

 I can certainly confirm that: I reported it a week ago - see
 
 http://thread.gmane.org/gmane.emacs.orgmode/42546
 
 Nick
 
 


Lots of org syntax remains inappropriately live inside EXAMPLE blocks. 
For example, a property drawer inside an EXAMPLE block will show up 
'folded' when you open the file. 

Paul





[O] Make M-up and M-down transpose paragraphs in org buffers

2011-06-21 Thread Paul Sexton
By default, if used within ordinary paragraphs in org mode, M-up and M-down 
transpose *lines* (not sentences). This was not useful to me. The following 
code makes these keys transpose paragraphs, keeping the point at the start
of the moved paragraph. Behaviour in tables and headings is unaffected. It
would be easy to modify this to transpose sentences.


(defun org-transpose-paragraphs (arg)
  (interactive)
  (when (and (not (or (org-at-table-p) (org-on-heading-p) (org-at-item-p)))
 (thing-at-point 'sentence))
(transpose-paragraphs arg)
(backward-paragraph)
(re-search-forward [[:graph:]])
(goto-char (match-beginning 0))
t))

(add-to-list 'org-metaup-hook 
  (lambda () (interactive) (org-transpose-paragraphs -1)))
(add-to-list 'org-metadown-hook 
  (lambda () (interactive) (org-transpose-paragraphs 1)))





[O] Typo in 'org-without-partial-completion'

2011-06-22 Thread Paul Sexton
I think there's an error in 'org-without-partial-completion' in org-macs.el.
The variable pc-mode gets bound to the value of partial-completion-mode - but 
this is a VARIABLE (t if that mode is enabled). Funcalling the value of 
the variable produces an error, unsurprisingly. This breaks insertion of 
properties with 'org-set-property'. 

Fixing it involves quoting the the symbol as shown below:


(defmacro org-without-partial-completion (rest body)
   `(let ((pc-mode (and (boundp 'partial-completion-mode)
'partial-completion-mode)))   ; -- quote added
  (unwind-protect
  (progn
(when pc-mode (funcall pc-mode -1))
,@body)
(when pc-mode (funcall pc-mode 1)




[O] Customising C-c C-c behaviour

2011-07-14 Thread Paul Sexton
Hi, I would like to customise the behaviour of C-c C-c on plain text 
(specifically I would like to make it alter the tags, as if the cursor
were on the item header). A variable exists called org-ctrl-c-ctrl-c-hook,
but if any function contained in that variable runs, it overrides
all other C-c C-c behaviour. I want my customisation to only run if 
C-c C-c has nothing more interesting to do.

Possibilities include:
1. Advising org-ctrl-c-ctrl-c. However it seems difficult to tell
   whether this function has succeeded from its return value, ie there
   doesn't seem to be any standard value returned when the command has
   succeeded. OTOH if it fails, it throws a simple error, which I could
   catch -- but then I would not know if the error I was handling was 
   actually caused by something else going wrong in the depths of the
   function. This could be solved by altering org-ctrl-c-ctrl-c so it uses 
   a specific, identifiable error symbol instead of 'error'.
2. Creating another variable called org-ctrl-c-ctrl-c-post-hook 
   which runs after all other possibilities have failed, but just before
   org-ctrl-c-ctrl-c fails. 

Both options would be easy to implement. Option 1 just involves adding
the following code:

(put 'org-ctrl-c-ctrl-c-error 'error-message
 C-c C-c can do nothing useful at this location)
(put 'org-ctrl-c-ctrl-c-error 'error-conditions
 '(error org-ctrl-c-ctrl-c-error))

And changing the '(error ...' line at the end of org-ctrl-c-ctrl-c to:

(signal 'org-ctrl-c-ctrl-c-error nil)

This error is still a subtype of 'error' so it behaves the same, unless
someone is specifically trying to catch it.

Any thoughts, objections, or better ideas?







[O] [ANN] Org-gamify

2014-07-08 Thread Paul Sexton
I have written a plugin for org agenda, which allows gamification of
task management. Define currencies, earn them by completing tasks, and
spend them on rewards. Inspired by HabitRPG, Epic Win and similar
systems.

http://bitbucket.org/eeeickythump/org-gamify

Note - I am well aware of existing criticisms of gamification. I have
significant reservations about many of its applications myself. However 
I am not going to enter into any debate about its desirability or 
ethicality. I have written some software to allow individuals to 
voluntarily experiment with gamifying aspects of their own task 
management systems, in order to find out whether it is enjoyable or 
useful for them.





[Orgmode] More wiki-like behaviour

2009-02-06 Thread Paul Sexton
Hi,
I am interested in using Org mode to create a personal wiki (along the
lines of Wikidpad: http://wikidpad.sourceforge.net/ ), treating top
level headings (one star) as wiki topics.
 
To do this, I have added 2 behaviours to Org-mode.
 
1. Always narrow to subtree after following an internal link (ideally I
would like to only narrow to the relevant one-star heading).
Added to .emacs:
 
(add-hook 'org-follow-link-hook (lambda () (org-narrow-to-subtree)))

2. More difficult: create a new wikiword if the internal link is not
found.
 
In .emacs, add a new function to create the new topic:
 
(defun org-create-new-wikiword (word)
  (interactive s)
  (widen)
  (end-of-buffer)
  (newline 2)
  (insert (format * %s word))  ; create as radio link
  (backward-char 4)
  (org-update-radio-target-regexp)
  (newline 2)
  (org-narrow-to-subtree))
 
 
 
Modification to the (VERY long) function org-open-at-point in org.el:
 
 
   ((string= type thisfile)
 (if in-emacs
 (switch-to-buffer-other-window
   (org-get-buffer-for-internal-link (current-buffer)))
   (org-mark-ring-push))
(let ((cmd `(org-link-search
   ,path
   ,(cond ((equal in-emacs '(4)) 'occur)
   ((equal in-emacs '(16)) 'org-occur)
   (t nil))
   ,pos)))
   (condition-case nil (eval cmd)
 (error (progn (widen)
 ;; BEGIN CHANGE
 (condition-case nil (eval cmd)
   (error
(when (yes-or-no-p
(format Topic '%s' not found; create?
 path))
  (org-create-new-wikiword path)
 ;; END CHANGE
 
I am not the greatest emacs-lisp orgrammer. Is there an easier way to do
this? If not, is it possible to create a 'link-not-found' hook so that I
don't need to modify org.el?
 
Thanks
 
Paul
 
 
___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[O] Fixes for org-capture-templates-contexts

2013-01-10 Thread Paul Sexton
org-capture-templates-contexts currently appears not to work. The structure
that the function 'org-contextualize-validate-key' expects to find in the
variable seems quite different from the structure described in the docstring.

Here are fixed versions of the functions 'org-contextualize-validate-key'
and 'org-contextualize-keys', both from org.el. I have also added some
functionality:
- new context specifiers in-buffer and not-in-buffer
- in-mode and not-in-mode expect a symbol, not a regexp.
- if a rule specifies a template that has 'sub-templates', those sub-templates
  will also be affected by the rule. For example if you have templates 't',
  'ta', 'tb' and 'tc', you can specify a rule for 't' which will affect
  all of them.

I have also rewritten the docstring for org-capture-templates-contexts,
from org-capture.el.




(defcustom org-capture-templates-contexts nil
  Alist of capture templates and valid contexts.

Each entry in the alist takes the form:
   (KEY [USUAL-KEY] CONTEXT [CONTEXT...])

Where:
   KEY :: a string of one or more letters, identifying a
   capture template.
   USUAL-KEY :: if supplied, this is the string that identifies
   the capture template in `org-capture-templates', while KEY
   becomes the string which will be used to select the
   template only in the present context (see below).
   CONTEXT :: a context definition.

Each context definition (CONTEXT) takes the form:
   FUNCTION
   or  (SPECIFIER . ARGUMENT)

Where:
   FUNCTION :: either a lambda form or a symbol naming a function.
  The function must take no arguments.
   SPECIFIER :: a symbol matching one of the context specifiers listed
  below.
   ARGUMENT :: either a string regular expression (for in-file and
  in-buffer), or a symbol (for in-mode).

Here are the available context specifiers:

  in-file: command displayed in files matching regex
in-buffer: command displayed in buffers matching regex
  in-mode: command displayed if major mode matches symbol
  not-in-file: command not displayed in files matching regex
not-in-buffer: command not displayed in buffers matching regex
  not-in-mode: command not displayed when major mode matches symbol

For example, if you have a capture template \c\ and you want
this template to be accessible only from `message-mode' buffers,
use this:

   '((\c\ (in-mode . message-mode)))

If you include several context definitions, the agenda command
will be accessible if at least one of them is valid.

If the template specified by KEY has sub-templates, they will also
be affected by the rule (unless they have their own rules). For
example, if you have a template `t' and sub-templates `ta', `tb'
and `tc', then a rule for `t' will affect whether all of those
contexts are accessible.

You can also bind a key to another agenda custom command
depending on contextual rules.

'((\c\ \d\ (in-file . \\\.el$\) (in-buffer \scratch\)))

Here it means: in files ending in `.el' and in buffers whose
name contains `scratch', use \c\ as the
key for the capture template otherwise associated with \d\.
\(The template originally associated with \q\ is not displayed
to avoid duplicates.)
  :version 24.3
  :group 'org-capture
  :type '(repeat (list :tag Rule
   (string :tag Capture key)
   (string :tag Replace by template)
   (repeat :tag Available when
  (choice
   (cons :tag Condition
 (choice
  (const :tag In file in-file)
  (const :tag Not in file not-in-file)
  (const :tag In mode in-mode)
  (const :tag Not in mode not-in-mode))
 (regexp))
   (function :tag Custom function))


(defun org-contextualize-validate-key (key contexts)
  Check CONTEXTS for agenda or capture KEY.
  (let (clause context res)
(while (setq clause (pop contexts))
  (destructuring-bind (context-key old-key . context-list) clause
(mapc
 (lambda (context)
   (when
   (cond
((and (= (length context-key) (length key))
  (not (equal key context-key)))
 nil)
((and ( (length context-key) (length key))
  (not (string-prefix-p context-key key)))
 nil)
((functionp context)
 (funcall context))
(t
 (destructuring-bind (context-spec . context-arg) context
   (message Considering context %s context)
   (or (and (eq context-spec 'in-file)
(buffer-file-name)
(string-match context-arg
  

Re: [O] Fixes for org-capture-templates-contexts

2013-01-14 Thread Paul Sexton
Bastien bzg at altern.org writes:

 If you can send a patch against master for this, I'd be happy to apply
 it!  Thanks again for pointing to these problems,
 

Below are patches against org.el and org-capture.el.

Are you sure it works correctly? The following setting for the variable
does causes an error for me out of the box, but does work with the changes
in the patch.

(setq org-capture-templates-contexts
  '((f (not-in-file . \\(espanol\\|verbs\\|nouns\\)\\.org))
(t (not-in-file . \\(espanol\\|verbs\\|nouns\\)\\.org))
(e (in-file . \\(espanol\\|verbs\\|nouns\\)\\.org))
(m (in-file . maths.*\\.org))
(M (in-file . med\\.org

Also, very important. I updated to master in order to make the patch and found
the current orgmode does not compile or even load. This is because
ob-eval.el uses 'declare-function' which is undefined (it is defined in
org-macs.el but ob-eval.el does not require that file).


--- ./org.el2013-01-15 10:54:43.0 +1300
+++ /Users/paul/org.el  2013-01-15 11:17:01.0 +1300
@@ -8682,9 +8682,11 @@
 (while (setq c (pop a))
   (let (vrules repl)
(cond
-((not (assoc (car c) contexts))
+((and (not (assoc (car c) contexts))
+   (not (assoc (string (elt (car c) 0)) contexts)))
  (push c r))
-((and (assoc (car c) contexts)
+((and (or (assoc (car c) contexts)
+   (assoc (string (elt (car c) 0)) contexts))
   (setq vrules (org-contextualize-validate-key
 (car c) contexts)))
  (mapc (lambda (vr)
@@ -8712,27 +8714,49 @@
 
 (defun org-contextualize-validate-key (key contexts)
   Check CONTEXTS for agenda or capture KEY.
-  (let (r rr res)
-(while (setq r (pop contexts))
-  (mapc
-   (lambda (rr)
-(when
- (and (equal key (car r))
-  (if (functionp rr) (funcall rr)
-(or (and (eq (car rr) 'in-file)
- (buffer-file-name)
- (string-match (cdr rr) (buffer-file-name)))
-(and (eq (car rr) 'in-mode)
- (string-match (cdr rr) (symbol-name major-mode)))
-(when (and (eq (car rr) 'not-in-file)
-   (buffer-file-name))
-  (not (string-match (cdr rr) (buffer-file-name
-(when (eq (car rr) 'not-in-mode)
-  (not (string-match (cdr rr) (symbol-name 
major-mode)))
- (push r res)))
-   (car (last r
+  (let (clause context res)
+(while (setq clause (pop contexts))
+  (let ((context-key (first clause))
+   (old-key (second clause))
+   (context-list (cddr clause)))
+(mapc
+ (lambda (context)
+   (when
+   (cond
+((and (= (length context-key) (length key))
+  (not (equal key context-key)))
+ nil)
+((and ( (length context-key) (length key))
+  (not (string-prefix-p context-key key)))
+ nil)
+((functionp context)
+ (funcall context))
+(t
+ (let ((context-spec (first context))
+  (context-arg (rest context)))
+   (or (and (eq context-spec 'in-file)
+(buffer-file-name)
+(string-match context-arg
+  (buffer-file-name)))
+   (and (eq context-spec 'in-buffer)
+(string-match context-arg
+  (buffer-name)))
+   (and (eq context-spec 'in-mode)
+(eq context-arg major-mode))
+   (when (and (eq context-spec 'not-in-file)
+  (buffer-file-name))
+ (not (string-match context-arg
+(buffer-file-name
+   (and (eq context-spec 'not-in-buffer)
+(not (string-match context-arg
+   (buffer-name
+   (when (eq context-spec 'not-in-mode)
+ (not (eq context-arg major-mode)))
+ (push clause res)))
+ context-list)))
 (delete-dups (delq nil res
 
+
 (defun org-context-p (rest contexts)
   Check if local context is any of CONTEXTS.
 Possible values in the list of contexts are `table', `headline', and `item'.


--- ./org-capture.el2013-01-15 10:54:42.0 +1300
+++ /Users/paul/org-capture.el  2013-01-15 11:17:45.0 +1300
@@ -449,31 +449,63 @@
 (defcustom org-capture-templates-contexts nil
   Alist of capture templates and valid contexts.
 
+Each entry in the alist takes the form:
+   (KEY [USUAL-KEY] 

Re: [O] org-drill - properties displayed during card review

2013-02-24 Thread Paul Sexton



I just never got around to fixing that minor glitch until now. I have committed 
a fix to the org-drill repository at

http://bitbucket.org/eeeickythump/org-drill

So if you download and use the org-drill.el from there, the problem will be 
fixed.

On 24/02/2013, at 9:16 PM, Bastien b...@altern.org wrote:

 Hi Paul,
 
 Paul Rudin paul-sqpymovxoov10xsdtd+...@public.gmane.org writes:
 
 I'm experimenting with org-drill. One thing that seems odd is that when
 reviewing a card for scoring the properties drawer is displayed. It
 seems unlikely that this is intended? Is it intended? If not is there
 some easy way I can fix it? TIA.
 
 I'm not sure Paul is still hacking org-drill.el, so you'll have to
 digg a bit yourself.  Or give more context for non-org-drill users
 so that they can help with the code.
 
 Thanks!
 
 -- 
 Bastien






[O] Patch: option to not hide brackets in org links

2012-05-09 Thread Paul Sexton
I would like to be able to control whether the '[[' ...']]' brackets around
links are made invisible during fontification. The motivation is that I have a
minor mode that makes org-style links fully active and fontifed in other major
modes. But I can imagine some others might want to use it, as behaviour of
these invisible brackets is sometimes unpredictable at the end of lines --
sometimes the cursor appears outside the link, but pressing return actually 
introduces a newline in the link. 

The following is a patch to org.el that accomplishes this. It introduces a new
boolean global variable, defaulting to current behaviour.

--- dotemacs/site-lisp/org/lisp/org.el  2012-05-06 10:45:07.0 +1200
+++ org-new.el  2012-05-10 09:00:14.0 +1200
@@ -1383,6 +1383,17 @@
   :group 'org-link
   :type 'function)
 
+
+(defcustom org-hide-link-brackets-p
+  t
+  Should the double square brackets [[...]] around links be invisible?
+Default is t.
+  :group 'org-link
+  :type 'boolean)
+
+(put 'org-hide-link-brackets-p 'safe-local-variable 'booleanp)
+
+
 (defgroup org-link-store nil
   Options concerning storing links in Org-mode.
   :tag Org Store Link
@@ -5576,9 +5587,10 @@
 ;; but that requires another match, protecting match data,
 ;; a lot of overhead for font-lock.
 (ip (org-maybe-intangible
- (list 'invisible 'org-link
-   'keymap org-mouse-map 'mouse-face 'highlight
-   'font-lock-multiline t 'help-echo help)))
+ (append (list 'keymap org-mouse-map 'mouse-face 'highlight
+'font-lock-multiline t 'help-echo help)
+  (if org-hide-link-brackets-p
+  (list 'invisible 'org-link) nil
 (vp (list 'keymap org-mouse-map 'mouse-face 'highlight
   'font-lock-multiline t 'help-echo help)))
;; We need to remove the invisible property here.  Table narrowing





Re: [O] Patch: option to not hide brackets in org links

2012-05-10 Thread Paul Sexton
Sean O'Halpin sean.ohalpin at gmail.com writes:
 Is that publicly available anywhere?

Here you go. To use, add orgl-enable to the relevant mode-hook, eg:
(add-hook 'python-mode-hook 'orgl-enable)



(defface orgl-target-face
 '((t (:foreground cyan :background royalblue4 :weight normal)))
;;  '((t (:weight bold :box (:line-width 1 :color red
  The face used to emphasise org-mode targets.)
(make-face 'orgl-target-face)
(setq orgl-target-face 'orgl-target-face)


(defvar *orgl-link-abbrevs*
  '((lisp-mode (defun . (defun %s ()
   (class . (defclass %s ()
   (wwdoc . file:../TODO::%s)))
  Define link abbreviations for each major mode.
The variable contains a list, each element of which has the
form (MAJOR-MODE (ABBREV . EXPANSION) .)
ABBREV is a short string. Links of the form '[[ABBREV:TEXT]]' will
be expanded into EXPANSION. See the documentation for
org-link-abbrev-alist for more details.)


(defun orgl-do-font-lock (add-or-remove)
  Add or remove font-lock rules for org hyperlinks.
  (funcall add-or-remove nil '((org-activate-bracket-links (0 'org-link t
  (funcall add-or-remove nil `((,org-target-regexp (0 'orgl-target-face t)


(defun orgl-enable ()
  Enable fontification of org-style hyperlinks in the current buffer.
  (interactive)
  ;; The following variable has to be bound to a string, or following links
  ;; will not work.
  ;; There is probably a more elegant solution.
  (unless org-todo-line-tags-regexp
(set (make-local-variable 'org-todo-line-tags-regexp)
 XYZ_THIS@SHOULD_NEVER~MATCH_ZYX))
  (orgl-do-font-lock 'font-lock-add-keywords)
  ;; Stop org links from having invisible [[ brackets ]].
  (remove-text-properties (point-min) (point-max) '(invisible nil))
  (font-lock-fontify-buffer)
  ;; Add special link abbreviations.
  (unless org-link-abbrev-alist-local
(make-local-variable 'org-link-abbrev-alist-local))
  (dolist (pair (cdr (assoc major-mode *orgl-link-abbrevs*)))
(pushnew pair org-link-abbrev-alist-local)))


(defun orgl-disable ()
  Disable fontification of org-style hyperlinks in the current buffer.
  (interactive)
  (remove-text-properties
 (point-min) (point-max)
   '(mouse-face t keymap t org-linked-text t
invisible t intangible t
org-no-flyspell t))
  (orgl-do-font-lock 'font-lock-remove-keywords)
  (font-lock-fontify-buffer)
  ;; Remove special link abbreviations
  (dolist (pair (cdr (assoc major-mode *orgl-link-abbrevs*)))
(setq org-link-abbrev-alist-local
  (delete pair org-link-abbrev-alist-local






Re: [O] Patch: option to not hide brackets in org links

2012-05-13 Thread Paul Sexton
Sean O'Halpin sean.ohalpin at gmail.com writes:
 Thanks!

I just noticed that the main function, orgl-enable, sets the buffer's
modification status to true when it runs. This is because altering text
properties is considered a modification of the buffer.

Fixed by wrapping the offending line in a 'with-silent-modifications' macro.
Some older Emacsen may not have this macro -- alternative solutions
are given at:

http://stackoverflow.com/questions/2699857/emacs-how-to-intelligently-handle-
buffer-modified-when-setting-text-properties



(defun orgl-enable ()
  Enable fontification of org-style hyperlinks in the current buffer.
  (interactive)
  ;; The following variable has to be bound to a string, or following links
  ;; will not work.
  ;; There is probably a more elegant solution.
  (unless org-todo-line-tags-regexp
(set (make-local-variable 'org-todo-line-tags-regexp)
 XYZ_THIS@SHOULD_NEVER~MATCH_ZYX))
  (orgl-do-font-lock 'font-lock-add-keywords)
  ;; Stop org links from having invisible [[ brackets ]].
  (with-silent-modifications
(remove-text-properties (point-min) (point-max) '(invisible nil)))
  (font-lock-fontify-buffer)
  ;; Add special link abbreviations.
  (unless org-link-abbrev-alist-local
(make-local-variable 'org-link-abbrev-alist-local))
  (dolist (pair (cdr (assoc major-mode *orgl-link-abbrevs*)))
(pushnew pair org-link-abbrev-alist-local)))





[Orgmode] Small patch to restrict syntactic context where [[links]] are active

2010-07-24 Thread Paul Sexton
Hi,
I posted a bit of code here a while back which allows org [[links]] and
targets to be fontified and active in any major mode.

I have been using this with great success in elisp and common lisp source code
files, where it actually works much more smoothly than linkd mode (see
emacswiki) which I used previously.

I have become interested in a very cool dialect of lisp called Clojure. Clojure
uses square brackets [ ] for syntax a lot more than other lisps. This sometimes
leads to eg argument lists of functions being fontified as org [[links]].

Fixing this requires a tiny change to 'org-activate-bracket-links' (2 lines),
one helper function and one variable which the user can set per-buffer.

With this, if I have the following code in my .emacs:

(add-hook 'clojure-mode-hook
  (lambda ()
(setq org-bracket-link-context '(string comment

Then org [[links]] will only be recognised when they occur inside a string or
comment (as defined by Clojure mode), rather than messing up function
arglists.


The patch follows (org.el):

 
 (defun org-activate-bracket-links (limit)
   Run through the buffer and add overlays to bracketed links.
-  (if (re-search-forward org-bracket-link-regexp limit t)
+  (if (and (re-search-forward org-bracket-link-regexp limit t)
+   (org-bracket-link-context-ok))
   (let* ((help (concat LINK: 
   (org-match-string-no-properties 1)))
 ;; FIXME: above we should remove the escapes.



The helper function and variable:


(defvar org-bracket-link-context nil
  Buffer-local Variable that defines the syntactic contexts
where org-style bracketed links should be recognised as such,
provided that they match the regular expression for bracketed
links.
Possible values:
nil - Any context is acceptable (default).
STRING  - The point is within a 'string'.
COMMENT - The point is within a comment.
OTHER   - The point is outside a string or comment.
A list  - One of the contexts in the list is satisfied. The list must
only contain some combination of the symbols STRING, COMMENT, or OTHER. )
(make-variable-buffer-local 'org-bracket-link-context)


(defun org-bracket-link-context-ok ()
  Helper function, called by ORG-ACTIVATE-BRACKET-LINKS. Returns
true if the syntactic context at the point is an acceptable place
to fontify an org bracketed link.  This is decided by checking
the syntactic context against the value of the variable
ORG-BRACKET-LINK-CONTEXT.
  (or (null org-bracket-link-context)
  (let ((context (syntax-ppss-context (syntax-ppss
(cond
 ((eql context org-bracket-link-context)
  t)
 ((eql 'other org-bracket-link-context)
  (null context))
 ((listp org-bracket-link-context)
  (find (or context 'other) org-bracket-link-context))


Below I have copied the code that activates org-style links in arbitrary
buffers, in case anyone is interested and missed it.


;; Put all this in your .emacs:

(defface orgl-target-face 
 '((t (:foreground cyan :background royalblue4 :weight normal)))
;;  '((t (:weight bold :box (:line-width 1 :color red
  The face used to emphasise org-mode targets.)
(make-face 'orgl-target-face)
(setq orgl-target-face 'orgl-target-face)


(defvar *orgl-link-abbrevs*
  '((lisp-mode (defun . (defun %s ()
   (class . (defclass %s ()
   (wwdoc . file:../TODO::%s)))
  Define link abbreviations for each major mode.
The variable contains a list, each element of which has the
form (MAJOR-MODE (ABBREV . EXPANSION) .)
ABBREV is a short string. Links of the form '[[ABBREV:TEXT]]' will
be expanded into EXPANSION. See the documentation for
org-link-abbrev-alist for more details.)


(defun orgl-do-font-lock (add-or-remove)
  Add or remove font-lock rules for org hyperlinks.
  (funcall add-or-remove nil '((org-activate-bracket-links (0 'org-link t
  (funcall add-or-remove nil `((,org-target-regexp (0 'orgl-target-face t)


(defun orgl-enable ()
  Enable fontification of org-style hyperlinks in the current buffer.
  (interactive)
  ;; The following variable has to be bound to a string, or following links
  ;; will not work.
  ;; There is probably a more elegant solution.
  (unless org-todo-line-tags-regexp
(set (make-local-variable 'org-todo-line-tags-regexp)
 DSFSFSFSF_UTTER_NONSENSE_TAG_SDSDFSFDF))
  (orgl-do-font-lock 'font-lock-add-keywords)
  (font-lock-fontify-buffer)
  ;; Add special link abbreviations.
  (unless org-link-abbrev-alist-local
(make-local-variable 'org-link-abbrev-alist-local))
  (dolist (pair (cdr (assoc major-mode *orgl-link-abbrevs*)))
(pushnew pair org-link-abbrev-alist-local)))


(defun orgl-disable ()
  Disable fontification of org-style hyperlinks in the current buffer.
  (interactive)
  (remove-text-properties
 (point-min) (point-max)
   '(mouse-face t keymap t org-linked-text t
invisible t intangible t
org-no-flyspell 

[Orgmode] Re: Small patch to restrict syntactic context where [[links]] are active

2010-07-26 Thread Paul Sexton
Paul Sexton psexton at xnet.co.nz writes:


Unfortunately this doesn't seem to work as well as I thought. For some reason 
when org-bracket-link-context-ok is called, (point) is not at the end of the
link, despite the fact that the docs for re-search-forward state that is where
the point should be. Without a way to get the position at the end of the match,
the context stuff does not work correctly.

(the stuff activating org links outside org mode still works however.)




___
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] [PATCH] org-depend only blocks null-TODO state change

2010-07-26 Thread Paul Sexton
In agenda view, tasks which are supposed to be blocked using org-depend's
:BLOCKER: property, are not actually blocked and do not show up dimmed.

This is because of a logic error in 'org-depend-block-undo', hopefully 
fixed below.

index eb38aa0..84fa1a7 100644
--- a/d:/paul/dotemacs/site-lisp/org/contrib/lisp/org-depend.el
+++ b/d:/paul/dotemacs/site-lisp/org/contrib/lisp/org-depend-new.el
@@ -224,12 +224,13 @@ this ID property, that entry is also checked.
 blocker blockers bl p1
 (proceed-p
  (catch 'return
-   (unless (eq type 'todo-state-change)
- ;; We are not handling this kind of change
- (throw 'return t))
-   (unless (and (not from) (member to org-not-done-keywords))
- ;; This is not a change from nothing to TODO, ignore it
- (throw 'return t))
+;; If this is not a todo state change, or if this entry is 
+;; DONE, do not block
+(when (or (not (eq type 'todo-state-change))
+  (member from (cons 'done org-done-keywords))
+  (member to (cons 'todo org-not-done-keywords))
+  (not to))
+  (throw 'return t))

;; OK, the plan is to switch from nothing to TODO
;; Lets see if we will allow it.  Find the BLOCKER property



___
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] Re: [ANN] Org-Drill: Interactive revision a la Anki/Mnemosyne

2010-08-02 Thread Paul Sexton
Detlef Steuer detlef.steuer at gmx.de writes:

 
 Hi!
 
 Just to give some feedback on org-drill. I had a look into writing something 
 similar some time ago, but never got around learning enough emacs lisp.
[...]

Thanks for the feedback. If by whitespace you mean blank lines, that's not a
requirement of org-drill. Org-drill just deals with topics and subtopics, how
you format their contents is up to you. You could delete all the blank lines in
spanish.org and it would work the same.

Paul





___
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] Some useful timestamp s-expressions

2010-08-18 Thread Paul Sexton
In org, timestamps can be in the usual angle-bracket format,
eg 2010-08-19 +2w, or you can use lisp s-expressions. These are in the same
format as the s-expressions used in the 'diary'/'calendar' emacs packages. I
only discovered these recently but have been able to use them to schedule some
complex recurring items. I thought I would share the code here.

1. Recurring items with a limited number of occurrences

For example, say you are taking night classes in Spanish. The class is every
Wednesday evening at 7pm, starting on 18 August, and runs for 8 weeks. AFAIK
Org's timestamps do not support limited occurrences of recurrent items -- you
have to schedule the item with infinite recurrences, then delete it when it
finishes.

To schedule the Spanish classes, put the following in your .emacs:

(defun diary-limited-cyclic (recurrences interval m d y)
  For use in emacs diary. Cyclic item with limited number of recurrences.
Occurs every INTERVAL days, starting on -MM-DD, for a total of
RECURRENCES occasions.
  (let ((startdate (calendar-absolute-from-gregorian (list m d y)))
(today (calendar-absolute-from-gregorian date)))
(and (not (minusp (- today startdate)))
 (zerop (% (- today startdate) interval))
 ( (floor (- today startdate) interval) recurrences

The item in the org file looks like this:


** 19:00-21:00 Spanish lessons
%%(diary-limited-cyclic 8 7 8 18 2010)


2. Public holiday that is the nearest Monday to DATE

In New Zealand each regional capital has an Anniversary Day. The date of 
Auckland's anniversary day is the nearest Monday to 29 January. 

Put this in your .emacs:

(defun calendar-nearest-to (target-dayname target-day target-month)
  Recurring event that occurs in the nearest TARGET-DAYNAME to
the date TARGET-DAY, TARGET-MONTH each year.
  (interactive)
  (let* ((dayname (calendar-day-of-week date))
 (target-date (list target-month target-day (calendar-extract-year 
date)))
 (days-diff (abs (- (calendar-day-number date)
(calendar-day-number target-date)
(and (= dayname target-dayname)
 ( days-diff 4

Now we can schedule Auckland Anniversary Day. The first argument, 1, means
Monday (days of the week are numbered starting with Sunday=0).


*** Auckland Anniversary Day
%%(calendar-nearest-to 1 29 1)


3. Public holiday on the 4th Monday in October.

This does not require any additions to .emacs:


*** Labour Day (NZ)
%%(diary-float 10 1 4)


4. Easter

Easter's date moves around from year to year according to a complicated set of
criteria which I do not claim to understand. However the following code will
allow you to schedule recurring events relative to Easter sunday.

Note: the function da-easter is from:
http://github.com/soren/elisp/blob/master/da-kalender.el

Put the following in your .emacs:

(defun da-easter (year)
  Calculate the date for Easter Sunday in YEAR. Returns the date in the
Gregorian calendar, ie (MM DD YY) format.
  (let* ((century (1+ (/ year 100)))
 (shifted-epact (% (+ 14 (* 11 (% year 19))
  (- (/ (* 3 century) 4))
  (/ (+ 5 (* 8 century)) 25)
  (* 30 century))
   30))
 (adjusted-epact (if (or (= shifted-epact 0)
 (and (= shifted-epact 1)
  ( 10 (% year 19
 (1+ shifted-epact)
   shifted-epact))
 (paschal-moon (- (calendar-absolute-from-gregorian
   (list 4 19 year))
  adjusted-epact)))
(calendar-dayname-on-or-before 0 (+ paschal-moon 7


(defun da-easter-gregorian (year)
  (calendar-gregorian-from-absolute (da-easter year)))

(defun calendar-days-from-easter ()
  When used in a diary sexp, this function will calculate how many days
are between the current date (DATE) and Easter Sunday.
  (- (calendar-absolute-from-gregorian date)
 (da-easter (calendar-extract-year date

Now we can schedule the public holidays associated with Easter as 
recurring events. Good Friday is 2 days before Easter, Easter Monday is one
day after.


*** Good Friday
%%(= -2 (calendar-days-from-easter))

*** Easter Sunday
%%(= 0 (calendar-days-from-easter))

*** Easter Monday
%%(= 1 (calendar-days-from-easter))


Paul



___
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] Folding org drawers in elisp code?

2010-08-23 Thread Paul Sexton
Can anyone tell me how I can write elisp code to force drawers to appear closed
(folded) in an org buffer?

Thanks 
Paul



___
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] [Ann] Updates to org-drill (org topics as interactive flashcards using spaced repetition)

2010-08-26 Thread Paul Sexton
Org-Drill has recently been added to the contrib directory of the org 
repository.

Latest version is in repository at:
http://bitbucket.org/eeeickythump/org-drill

I have made a couple of major updates recently. Changelogs are below.
Reports of user experiences are welcome.

Version 1.0
Added README with more detailed documentation.
Items which are failed during session are presented again before the session 
ends.
Items which were failures at the last review session are presented first in the
next session.
Added recognition of leech items, based on excessive number of failures.
Leeches can be skipped or warned about.
When reviewing an item, the prompt shows the number of items remaining.
When the session finishes, the minibuffer shows a brief report givisng
statistics about total time spent reviewing, number of cards that
still need review, etc.
Fixed the regexp for cloze-deleted text.
Optional face for cloze text in org mode buffers.
New card type: twosided.

Version 1.1
Added implementation of SM2 algorithm (now supports both SM2 and SM5).
Add option 'org-drill-spaced-repetition-algorithm': choose either SM2 or SM5
algorithm.
Add option 'org-drill-add-random-noise-to-intervals-p': randomly vary repetition
intervals slightly, to avoid clumping.
Fixed a bug in org-learn's SM5 algorithm (intervals much too long).
Use overlays to display cloze deletions as '[...]' during reviews.
Cloze text can contain hints, which will visible during review.
Add option 'org-drill-failure-quality': customise which quality is regarded as
unambiguous failure (1 or 2).
Expanded documentation, and added section on 'incremental reading', with example
setup.




___
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] Bug: export aborts if ':eval query/never' in source code blocks

2010-08-26 Thread Paul Sexton
#+BEGIN_SRC R :eval query
...
#+END_SRC

If the above is in an org file, the user runs an export (C-c C-e), and the user
types 'no' when asked whether to evaluate the code block, then the whole export
process is aborted (no further blocks are processed and no export output is
produced).

The same thing happens with ':eval never'.

Paul



___
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] Re: Bug: export aborts if ':eval query/never' in source code blocks

2010-08-26 Thread Paul Sexton
Eric Schulte schulte.eric at gmail.com writes:

 
 I've just pushed up a fix for this issue. For more information see
 http://eschulte.github.com/babel-dev/DONE-eval-and-noeval.html

Wow, that was fast!
Thanks very much.

Paul



___
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] Re: [Ann] Updates to org-drill (org topics as interactive quot; flashcardsquot; using spaced repetition)

2010-08-27 Thread Paul Sexton
Detlef Steuer detlef.steuer at gmx.de writes:
 What is the intended way to input a few hundred two-sided
 cards?
 
 If I understand spanish.org correctly I need a headline like
 
 *** Noun :drill:
 :PROPERTIES:
 :DRILL_CARD_TYPE: twosided
 :END:
 
 and subheadings
  Language1
  text
 
  Language2
  text
 
 for each and every word?
 Or is there a way to have one such headline followed by a lot of 
 pairs of text for both languages?
 
 Detlef


Hi Detlef
Your example card layout is correct. Note you can add other sections such 
as Examples as well -- any headings after the first 2 are always hidden 
during review.

What I suggest is to enter your cards in an easy, regular format such as
tab-delimited, or even into a spreadsheet and then export to a tab-delimited 
or comma-delimited text file. Then use query-replace-regexp (C-M-%) to turn 
them into drill items as in your example.

eg: if your file contains:

el perrotabthe dognewline
el gatotabthe catnewline
...

replace newlines with ^J***Noun^JLanguage1^J
replace TABs with ^JLanguage2^J
replace *** Noun^J with *** Noun^J:PROPERTIES:^J..^J
(where ^J is the newline character, entered by pressing C-q C-j)
 
There is no special way to import such a file into org, as far as I 
am aware. FWIW I followed a very similar process to the above yesterday
with 450 cards exported from Anki, and it worked well.

For entry of more words as you learn, I very strongly suggest setting 
up an org capture template. 

Paul





___
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] [BUG] org-read-date produces imaginary date

2010-08-30 Thread Paul Sexton
Today (31 August), 
if I evaluate (org-read-date t), then at the prompt type
+3
The string returned is:
2010-08-34

Paul



___
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] [BUG] some nasty bugs with PROPERTIES drawers

2010-08-30 Thread Paul Sexton
There seems to be a fairly nasty bug caused by :PROPERTIES: drawers still 
being recognised by org when they appear inside BEGIN_EXAMPLE or 
BEGIN_SRC blocks. I encountered this behaviour while writing docs for 
org-drill. The doc file, README.org, contains quoted examples of org
items, and also of an emacs lisp capture template containing the string
:PROPERTIES:.

The first thing I noticed was that PROPERTIES drawers inside EXAMPLE/SRC 
blocks appear *folded* when the file is opened in org mode, and 
'org-cycle' toggles their folded status, as if they belonged to a 
real org heading.

That is cosmetic, but I also encountered a more serious problem. 
README.org contains the following block of example elisp code, which 
is meant to illustrate an example setup of org-capture:

#+BEGIN_SRC emacs-lisp
(setq org-capture-templates
   `((u
 Task: Read this URL
 entry
 (file+headline tasks.org Articles To Read)
 ,(concat * TODO Read article: '%:description'\nURL: %c\n\n)
 :empty-lines 1
 :immediate-finish t)

(w
 Capture web snippet
 entry
 (file+headline my-facts.org Inbox)
 ,(concat * Fact: '%:description':
  (format %s org-drill-question-tag)
  :\n:PROPERTIES:\n:DATE_ADDED: %u\n:SOURCE_URL:
%c\n:END:\n\n%i\n%?\n)
 :empty-lines 1
 :immediate-finish t)
;; ...other capture templates...
))
#+END_EXAMPLE

Basically, every time I tried to export this file to HTML, Emacs would 
become unresponsive (C-g did nothing) and would have to be killed with 
the task manager (or xkill in Linux -- I tried on 2 systems).

After about 20 crashes and restarts of Emacs, I finally identified the 
problem (I think). when I changed the above block from BEGIN_SRC to
BEGIN_EXAMPLE, the file exported correctly.

I think org was seeing the :PROPERTIES string within the elisp code 
and trying to interpret it as the beginning of a drawer, with disastrous
results.

Once I managed to fix the problem for myself I did not investigate it 
further. However I hope someone can fix it as it certainly caused a 
stressful afternoon.

Paul 

PS: I also realised that I was confused regarding how to get a syntax-
highlighted block of example source code into an org document, as 
BEGIN_SRC appears to execute the code by default, which was not what 
I wanted. Should BEGIN_EXAMPLE take an argument which specifies syntax 
highlighting (eg BEGIN_EXAMPLE emacs-lisp)?





___
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] Re: [BUG] some nasty bugs with PROPERTIES drawers

2010-08-31 Thread Paul Sexton
David Maus dmaus at ictsoc.de writes:
 I cannot reproduce this wiht Org-mode version 7.01trans (pulled
 yesterday) on GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version
 2.20.0) of 2010-08-14 on raven, modified by Debian

There is a documentation file, README.org, that accompanies org-drill.
It can be downloaded at:
http://bitbucket.org/eeeickythump/org-drill/src/tip/README.org

The quoted emacs lisp example occurs near the end of the file. As is, it
exports to HTML (C-c C-e h) successfully for me, but if I change 
BEGIN_EXAMPLE/END_EXAMPLE to BEGIN_SRC/END_SRC for that block, it 
reproduces the bug.

 PS: I also realised that I was confused regarding how to get a syntax-
 highlighted block of example source code into an org document, as
 BEGIN_SRC appears to execute the code by default, which was not what
 I wanted.
 
 No, at least not for Elisp.  What is your assumption of Org mode
 executing source blocks based on?
 

My assumption is based on reading the manual. I couldn't find clearly stated 
anywhere exactly what BEGIN_SRC blocks do by default during export, and there 
are :eval never and eval query headline option, implying that these are not 
the default behaviours. But perhaps I read it wrong.

Paul



___
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] Re: [BUG] some nasty bugs with PROPERTIES drawers

2010-08-31 Thread Paul Sexton
Erik Iverson eriki at ccbr.umn.edu writes:
 See the :exports argument, the default is code only.
 
 http://orgmode.org/org.html#exports

That was my initial assumption, which is why I had BEGIN_SRC blocks in the file.
But then I found that it crashed during export with these blocks, and stopped
crashing once I changed them to BEGIN_EXAMPLE, which made me question my 
initial 
assumption and suspect that the BEGIN_SRC blocks were being evaluated/executed 
somehow.

Paul



___
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] Re: cannot enable org-habit

2010-09-01 Thread Paul Sexton
Joseph Buchignani joseph.buchignani at gmail.com writes:

 Yes, here is how it looks:
...

Hi Joseph
The following item has been working fine for me. However I can't see any 
glaring 
differences wrt to your example item.


** TODO Add MCQs
   SCHEDULED: 2010-09-03 Fri .+1d/4d
   - State DONE   from TODO   [2010-09-02 Thu 07:51]
   - State DONE   from TODO   [2010-08-25 Wed 15:52]
  :PROPERTIES:
  :STYLE: habit
  :LAST_REPEAT: [2010-09-02 Thu 07:51]
  :END:


Rather than use 'modules' I just have
(require 'org-habit)
in my .emacs -- maybe that is worth trying.

Paul



___
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] Problem with URLs in export to latex

2010-09-02 Thread Paul Sexton
Hi guys

My .org document contains the following sentence.

In R, procedures in the =survey= library were
used\footnote{Available at: http://faculty.washington.edu/tlumley/survey/}.

This is exported to:

In R, procedures in the \texttt{survey} library were
used\footnote{Available at: [[http://faculty.washington.edu/tlumley/survey/]
[http://faculty.washington.edu/tlumley/survey/]]}.

As you can see, the URL gets exported as an [[org link]], meaningless 
outside org.

The same thing happens with \footnote{Available at: \url{...}}

Do I have things configured wrong, or is this a bug?

thanks
Paul



___
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] Re: orgmode as a reference system: Storing private/sensitive information and syncing across devices.

2010-09-23 Thread Paul Sexton
Check out: http://ccrypt.sourceforge.net/

There is an emacs package provided, ps-ccrypt.el,  which provides seamless
loading  saving of encryted files. I have been using it with my org agenda
file for several months with no problems. 

Paul


Marcelo de Moraes Serpa celoserpa at gmail.com writes:
} 
} Yeah, you are right. Even if the transport protocol is encrypted,
} storing in plaintext doesn't sound like a good idea. Maybe we could
} have a series of tutorials or guidelines written on how to use org on
} the cloud securely, since I see many people are using it as their
} main personal-information-manager and also are using mobile-org to
} sync stuff across devices.
} 
} Marcelo.



___
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] Minor bug: org-agenda-holidays

2010-12-21 Thread Paul Sexton
In org-agenda.el, the function org-agenda-holidays is coded as:

(defun org-agenda-holidays ()
  Display the holidays for the 3 months around the cursor date.
  (interactive)
  (org-agenda-execute-calendar-command 'list-calendar-holidays))

'list-calendar-holidays' does not exist. It should be 
'calendar-list-holidays'.

Paul



___
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] Babel: replace inline block with evaluation result?

2011-01-13 Thread Paul Sexton
I have an org-mode document that uses a lot of R code (via babel). I have found
that using inline code blocks, ie src_R{...}, within org tables works
erratically, often either causing emacs to hang during latex export, or
producing a table where random cells containing 'nil' instead of the result I
get when I manually evaluate the inline code block via C-c C-c.

I am therefore in the process of converting many of these tables back to 'plain'
org, ie replacing the inline code blocks with their results. 

My question is: is there any way to automate this? Ideally I would like to press
a key with the cursor on an inline block, and have the block replaced with its
eval result, rather than have the result appear in the minibuffer.

Paul



___
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] Re: Babel: replace inline block with evaluation result?

2011-01-13 Thread Paul Sexton
Eric Schulte schulte.eric at gmail.com writes:
 
 The following function could be bound to a key, and should do the job if
 called with the point on the src_lang portion of the inline code block.
 
[snip - gmane web-thingy won't let me quote the function]

Thanks Eric!

I will try to come up with a minimal example of the error I talked
about.
Paul






___
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] Patch: More options for ignoring scheduled items in agenda todo lists

2011-01-13 Thread Paul Sexton
In agenda todo lists, currently it is possible to ignore scheduled
items according to when they are scheduled, using the variable
'org-agenda-todo-ignore-scheduled'. This can take one of three
values - all, future (ignore if scheduled after today), or past 
(ignore if scheduled TODAY or in the past).

My definition of 'the past' does not include 'today'.
In light of that, the following is a patch that makes the variable 
accept 2 more values:
- notpast: ignore if scheduled today or in the future
- notfuture: ignore if scheduled today or in the past
  (this is the current behaviour of the 'past' setting)
- past: changed to ignore if scheduled BEFORE today, but no 
  longer ignores items scheduled today.

Paul




--- D:/paul/dotemacs/site-lisp/org/lisp/org-agenda.el   Mon Dec 13 07:57:31 2010
+++ D:/paul/dotemacs/site-lisp/org/lisp/org-agenda_p.el Fri Jan 14 11:32:23 2011
@@ -598,12 +598,18 @@
 This applies when creating the global todo list.
 Valid values are:
 
-past Don't show entries scheduled today or in the past.
+past Don't show entries scheduled in the past.
 
 future   Don't show entries scheduled in the future.
  The idea behind this is that by scheduling it, you don't want to
  think about it until the scheduled date.
 
+notpast  Don't show entries scheduled today or in the
+ future.
+
+notfuture  Don't show entries scheduled today or in the
+   past.
+
 all  Don't show any scheduled entries in the global todo list.
  The idea behind this is that by scheduling it, you have already
  \taken care\ of this item.
@@ -4512,8 +4518,12 @@
   (cond
((eq org-agenda-todo-ignore-scheduled 'future)
 ( (org-days-to-time (match-string 1)) 0))
-   ((eq org-agenda-todo-ignore-scheduled 'past)
+   ((eq org-agenda-todo-ignore-scheduled 'past) ; before today
+( (org-days-to-time (match-string 1)) 0))
+   ((eq org-agenda-todo-ignore-scheduled 'notfuture)
 (= (org-days-to-time (match-string 1)) 0))
+   ((eq org-agenda-todo-ignore-scheduled 'notpast)
+(= (org-days-to-time (match-string 1)) 0))
(t)))
  (and org-agenda-todo-ignore-deadlines
   (re-search-forward org-deadline-time-regexp end t)



___
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] Re: [PATCH] Add new option for ignoring past or future items in the global todo list

2011-01-17 Thread Paul Sexton
Matt Lundin mdl at imapmail.org writes:
[snip]

Thanks Matt! (And it was mostly your idea.)
Paul



___
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