From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "PT" Newsgroups: gmane.emacs.help Subject: Re: Annotation mode Date: 15 Oct 2005 21:56:35 -0700 Organization: http://groups.google.com Message-ID: <1129438595.215018.113610@g47g2000cwa.googlegroups.com> References: <1129271963.787889.149720@g14g2000cwa.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1129438891 32686 80.91.229.2 (16 Oct 2005 05:01:31 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 16 Oct 2005 05:01:31 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 16 07:01:17 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1ER0d8-0002UB-IB for geh-help-gnu-emacs@m.gmane.org; Sun, 16 Oct 2005 07:00:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ER0d7-0002pz-NO for geh-help-gnu-emacs@m.gmane.org; Sun, 16 Oct 2005 01:00:17 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 109 Original-NNTP-Posting-Host: 81.183.149.136 Original-X-Trace: posting.google.com 1129438600 4876 127.0.0.1 (16 Oct 2005 04:56:40 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sun, 16 Oct 2005 04:56:40 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 X-HTTP-UserAgent: Opera/8.50 (Windows NT 5.0; U; en),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g47g2000cwa.googlegroups.com; posting-host=81.183.149.136; posting-account=b98TkQ0AAAD7PsllN8gfWGRoPOPWdnv4 Original-Xref: shelby.stanford.edu gnu.emacs.help:134670 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:30251 Archived-At: I took a look at the options and decided to implement my own solution, since it was pretty easy. Here it is if someone is interested: ;;; annotate.el --- simple file annotation system ;;; ;;; ;;; M-x annotate-file pops up a window where the annotation for the ;;; current file can be edited. If the annotation window is left open ;;; it always shows the annotation belonging to the current buffer. ;;; ;;; ;;; Code: (defvar annotate-storage-file "~/.annotate" "File containing the stored annotations.") (defvar annotate-current-buffer nil "The last buffer known to be the current one.") (defvar annotate-window-configuration nil "The window configuration before the annoation buffer was displayed.") (defun annotate-file () (interactive) (annotate-narrow-to-annotation) (setq annotate-window-configuration (current-window-configuration)) (pop-to-buffer (get-file-buffer annotate-storage-file)) (local-set-key (kbd "C-c C-c") 'annotate-finish) (message "Type C-c C-c to hide the annotation buffer.") (setq annotate-current-buffer 'nosuchbuffer) (ad-activate 'switch-to-buffer)) (defun annotate-narrow-to-annotation () "Narrow the annotation buffer to the portion belonging to the file associated wit the current buffer. If no annotation exists for the file a new section is created. If the current buffer has no file associated with it then show a warning message." (let* ((buffer (find-file-noselect annotate-storage-file)) (file (buffer-file-name)) (filename (if file (expand-file-name file) "nofile"))) (with-current-buffer buffer (widen) (unless (equal filename (expand-file-name annotate-storage-file)) (goto-char (point-min)) (if (re-search-forward (concat "^ " filename) nil t) (forward-line) (goto-char (point-min)) (insert " " filename "\n\n") (forward-line -1)) (let ((begin (point))) (if (re-search-forward "^ " nil t) (progn (forward-line -1) (end-of-line)) (goto-char (point-max))) (narrow-to-region begin (point)) (goto-char (point-min))) ;; prepare warning message if it does not exist yet (if (and (not file) (=3D (point-min) (point-max))) (insert "The current buffer has no file associated with it, " "so it cannot have an annotation.")))))) (defadvice switch-to-buffer (after annotate-handle-buffer-change) (annotate-update-annotation-display)) (defun annotate-update-annotation-display () "Synchronize the displayed annotation to the current buffer if the annotation window is visible. Otherwise cancel current buffer monitoring." (if (get-buffer-window (get-file-buffer annotate-storage-file)) (unless (equal (current-buffer) annotate-current-buffer) (setq annotate-current-buffer (current-buffer)) (annotate-narrow-to-annotation)) (ad-deactivate 'switch-to-buffer))) (defun annotate-finish () "Hide the annotation buffer and restore previous window configuration." (interactive) (set-window-configuration annotate-window-configuration) (with-current-buffer (get-file-buffer annotate-storage-file) (save-buffer))) (provide 'annotate) ;;; annotate.el ends here