"Chris Lott" <[EMAIL PROTECTED]> 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) "<<TODO: Please Insert Documentation>>" (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 _______________________________________________ Help-gnu-emacs mailing list Help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs