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

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

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


From: emacs-wiki
Subject: Re: [emacs-wiki-discuss] planner.el patch + Re: Relative paths in annotations, and planner sub-directories
Date: Sun, 20 Nov 2005 21:36:14 +0200 (IST)


On Fri, 18 Nov 2005, Sacha Chua wrote:

Date: Fri, 18 Nov 2005 17:48:07 -0500
From: Sacha Chua <address@hidden>
To: address@hidden
Subject: [emacs-wiki-discuss] planner.el patch + Re: Relative paths in
    annotations, and planner sub-directories

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.


So the new construct below,
  (expand-file-name file (planner-directory))
facilitates for that; did I get it right?

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)))


Thanks for the patch.

I implemented it and still, the links lead me to the wrong place. Assume planner-directory is ~/var/plans; I have opened the planner page ~/var/plans/comp/pim, and I try to follow
  [[pos://../../.xemacs/init.el#0]].
The result: xemacs tries to open ~/var/.xemacs/init.el instead of ~/.xemacs/init.el.

[snip]

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)))


Thanks!

Am I correct to assume that the definition below would render useless the patch for planner.el (at the top of this message)? If yes, I think I should move carefully and first understand why the one above didn't work, before I check out the implementation for "~".

(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)))


I should have mentioned it in my original message -- better late than never. I use planner-muse.

        Many thanks for your detailed reply.
        Itay

--
Itay Furman <address@hidden>
  xemacs        = 21.4.17
  planner-muse  = mwolson--1.0 patch-93 (2005-11-02 03:37:57)
  muse          = 3.02.01               (2005-09-26 22:31:57)
  remember      = stable--1.0  patch 17 (2005-04-03 18:09:28)




reply via email to

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