emacs-wiki-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[emacs-wiki-discuss] planner.el patch + Re: Relative paths in annotation


From: Sacha Chua
Subject: [emacs-wiki-discuss] planner.el patch + Re: Relative paths in annotations, and planner sub-directories
Date: Fri, 18 Nov 2005 17:48:07 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

address@hidden writes:

> 1. The path that is offered in the "*Remember*" buffer is relative to
>    ~/var/plans, and not to the would-be project page(s).  I expand on
>    this below.

I get around the problem of relative filenames by making them always
relative to a fixed location. This makes it easy to move plan pages in
your tree without having to update all the links. By default, file
links are relative to the first directory in the muse project
definition for the Planner project.

The following patch should make planner-browse-position-url work properly:

--- orig/planner.el
+++ mod/planner.el
@@ -1693,7 +1703,7 @@
   (when (string-match "^pos://\\(.+\\)#\\([0-9]+\\)$" url)
     (let ((file (match-string 1 url))
           (pos (string-to-number (match-string 2 url))))
-    (find-file file)
+    (find-file (expand-file-name file (planner-directory)))
     (goto-char pos)
     t)))


> 2. When I type 'C-c C-c' followed by 'comp/pim' as the target project
>    page, I get an error
>       "Symbol's function definition is void:
>               match-string-no-properties"
> the note is not saved, and the buffer is not exited.

Oops, that really should be planner-match-string-no-properties. I've
updated the dev version of remember. =)

> Another (more robust?) solution, would be to use the home directory
> alias "~"
>     [[pos://~/what/ever][~/what/ever]]
> provided that muse and (X)emacs support this.  This will
> solve the problem of saving a note into multiple pages that do not
> reside at the same depth within the directory tree, or copying it
> later into a different page that is on a different directory level.

Sure, no prob. Just redefine
planner-annotation-from-file-with-position and
planner-browse-position-url . For example, if you want it to always be
relative to your home directory:

(defvar itay/planner-relative-base "~" "Make all planner links relative to this 
directory.")

(defun planner-annotation-from-file-with-position ()
  "Return the filename and cursor position of the current buffer.
If `planner-annotation-use-relative-file' is t or a function that
returns non-nil, a relative link is used instead. If
`planner-annotation-strip-directory' is non-nil, the directory is
stripped from the link description."
  (when buffer-file-name
    (planner-make-link
     (concat
      "pos://"
      (if (or (and (functionp planner-annotation-use-relative-file)
                   (funcall planner-annotation-use-relative-file
                            (buffer-file-name)))
              (equal planner-annotation-use-relative-file t))
          (file-relative-name (buffer-file-name) itay/planner-relative-base)
        buffer-file-name)
      "#" (number-to-string (point)))
     (if planner-annotation-strip-directory
         (file-name-nondirectory buffer-file-name)
       buffer-file-name)
     t)))

(defun planner-browse-position-url (url)
  "If this is a position URL, jump to it."
  (when (string-match "^pos://\\(.+\\)#\\([0-9]+\\)$" url)
    (let ((file (match-string 1 url))
          (pos (string-to-number (match-string 2 url))))
    (find-file (expand-file-name file itay/planner-relative-base))
    (goto-char pos)
    t)))
     
> Unfortunately I can code neither as I know very little lisp.
> Is it difficult to do?  Could someone show me an example, please?

Hope that helps! =)
-- 
Sacha Chua <address@hidden> - open source, free software geekette
http://sacha.free.net.ph/ - PGP Key ID: 0xE7FDF77C
interests: emacs, gnu/linux, personal information management, public speaking
sachac on irc.freenode.net#emacs . YM: sachachua83




reply via email to

[Prev in Thread] Current Thread [Next in Thread]