[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[emacs-wiki-discuss] Re: annotations from files: line and column numbers
From: |
Sacha Chua |
Subject: |
[emacs-wiki-discuss] Re: annotations from files: line and column numbers |
Date: |
Mon, 21 Feb 2005 10:10:38 +0900 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) |
Jesse Alama <address@hidden> writes:
> I appreciate being able to revisit files by following links that were
> generated from M-x remember. This function could be improved, IMHO,
> if M-x remember recorded the line number of the file I was visiting at
That's a great idea! Here's code to do that for Planner. If you don't
use Planner, you can tweak it to work with emacs-wiki+remember. =)
(defun alama/planner-annotation-from-file ()
"Return alama://filename#point
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
"alama://"
(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) planner-directory)
buffer-file-name)
"#"
(number-to-string (point)))
(when planner-annotation-strip-directory
(file-name-nondirectory buffer-file-name)))))
(defun alama/browse-file (url)
"Jump to the file named by a URL of the form alama://foo/bar/baz#point."
(when (string-match "^alama://\\(.*\\)#\\([0-9]+\\)" url)
(let ((filename (match-string 1 url))
(number (string-to-number (match-string 2 url))))
(find-file filename)
(widen)
(goto-char number))))
(defun alama/resolve-file (url)
"Transform URL into a form ready for publishing."
(when (string-match "^alama://\\(.*\\)#\\([0-9]+\\)" url)
(match-string 1 url)))
(defalias 'planner-annotation-from-file 'alama/planner-annotation-from-file)
--
Sacha Chua <address@hidden> - open source geekette
http://sacha.free.net.ph/ - PGP Key ID: 0xE7FDF77C
interests: emacs, gnu/linux, personal information management, CS ed
sachac on irc.freenode.net#emacs . YM: sachachua83
Re: [emacs-wiki-discuss] annotations from files: line and column numbers, Dryice Liu, 2005/02/20
planner-snap (was Re: [emacs-wiki-discuss] annotations from files: line and column numbers), Berkan Eskikaya, 2005/02/22