From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: Associated notes with documents Date: Thu, 21 Jul 2005 08:39:00 +0200 Organization: [posted via Easynet Spain] Message-ID: <87y8808xyz.fsf@thalassa.informatimago.com> References: <1121914017.718653.310620@z14g2000cwz.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1121928313 30782 80.91.229.2 (21 Jul 2005 06:45:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 21 Jul 2005 06:45:13 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 21 08:45:02 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DvUnb-0002NG-QU for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Jul 2005 08:44:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DvUpg-0002sT-Ci for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Jul 2005 02:47:00 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!easynet-quince!easynet.net!easynet-post2!not-for-mail Original-Newsgroups: comp.emacs,gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:6/W+syE+UZx8qb2HJfO8vgsfnmM= Original-Lines: 74 Original-NNTP-Posting-Host: 62.93.174.79 Original-X-Trace: DXC=0hBg3Rj_8mh0gcQ\3Z7K>oSiHWb3f14:cbBd4DjF1d]a Original-Xref: shelby.stanford.edu comp.emacs:89700 gnu.emacs.help:132523 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:28040 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:28040 "Chris Lott" writes: > I'm trying to figure out an automated way to have a "notes" window > associated with documents while using emacs. Ideally, the associated > notes file for a document would open up automatically with the document > inside a split window of some kind. If there were no notes, then > entering something in that window and saving it would automatically > create the notes file, which would open with the document next time. > > Is there any code out there that does this kind of thing? No, but it's so easy and so funny to do it yourself! (defun FILE-NAMESTRING (pathname) "Common-Lisp: returns just the name, type, and version components of pathname. These functions convert pathname into a namestring. The name represented by pathname is returned as a namestring in an implementation-dependent canonical form. URL: http://www.lispworks.com/reference/HyperSpec/Body/f_namest.htm NOTE: in current implementation pathname=namestring. RETURN: the 'basename' of the pathname. " (if (string-match "\\(^.*/\\([^/][^/]*\\)/*$\\)\\|\\(^\\([^/][^/]*\\)/*$\\)" pathname) (let ((res (match-string 2 pathname))) (if res res (match-string 4 pathname))) pathname)) (defun DIRECTORY-NAMESTRING (pathname) "Common-Lisp: returns the directory name portion. These functions convert pathname into a namestring. The name represented by pathname is returned as a namestring in an implementation-dependent canonical form. URL: http://www.lispworks.com/reference/HyperSpec/Body/f_namest.htm NOTE: in current implementation pathname=namestring. RETURN: the 'basename' of the pathname. " (if (string-match "\\(^.*[^/].*\\)/[^/][^/]*/*$" pathname) (match-string 1 pathname) (if (= ?/ (aref pathname 0)) "/" "."))) (defun annotation-file-path (file-path) (format "%s/.%s" (DIRECTORY-NAMESTRING file-path) (FILE-NAMESTRING file-path))) (defun find-annotated-file (filename &optional wildcards) "<>" (interactive (find-file-read-args "Find file: " nil)) (let* ((value (find-file-noselect filename nil nil wildcards)) (files (if (listp value) value (list value))) (notes (mapcar (lambda (file-buffer) (let* ((file-path (buffer-file-name file-buffer)) (note-path (annotation-file-path file-path))) (find-file-noselect note-path))) files))) (delete-other-windows) (switch-to-buffer (first files)) (split-window-vertically) (other-window 1) (switch-to-buffer (first notes)) (other-window 1))) (global-set-key (kbd "C-x C-f") (function find-annotated-file)) -- __Pascal Bourguignon__ http://www.informatimago.com/ Small brave carnivores Kill pine cones and mosquitoes Fear vacuum cleaner