[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature request(?): adding annotations for nodes?
From: |
Richard Y. Kim |
Subject: |
Re: Feature request(?): adding annotations for nodes? |
Date: |
Tue, 25 Dec 2001 11:17:09 -0800 |
Dave Gillespie added `Info-annotate' function to info.el
that he wrote about 10 years ago for Emacs 18. His version
of info.el has been included with XEmacs for many years. I
quote a few lines from XEmacs-21.5.0/lisp/info.el below.
This is for FYI only. I'm sure that after 10 years, there
are much better ways to implement "annotation" solution such
as <http://www.emacslisp.org/manuals/elisp_annotated>.
Jean-Philippe Theberge posted taelm.el to gnu.emacs.sources
a few months ago with which you could annotate emacs-lisp
manual within Emacs.
(defun Info-annotate-mode ()
"Major mode for adding an annotation to an Info node.
Like text mode with the addition of Info-cease-annotate
which returns to Info mode for browsing.
\\{Info-annotate-map}")
(defun Info-annotate (arg)
"Add a personal annotation to the current Info node.
Only you will be able to see this annotation. Annotations are stored
in the file \"~/.xemacs/info.notes\" by default. If point is inside
an existing annotation, edit that annotation. A prefix argument
specifies which annotations file (from `Info-annotations-path') is to
be edited; default is 1."
(interactive "p")
(setq arg (1- arg))
(if (or (< arg 0) (not (nth arg Info-annotations-path)))
(if (= arg 0)
(setq Info-annotations-path
(list (read-file-name
"Annotations file: " "~/" "~/.infonotes")))
(error "File number must be in the range from 1 to %d"
(length Info-annotations-path))))
(let ((which nil)
(file (file-name-nondirectory Info-current-file))
(d Info-directory-list)
where pt)
(while (and d (not (equal (expand-file-name file (car d))
Info-current-file)))
(setq d (cdr d)))
(or d (setq file Info-current-file))
(if (and (save-excursion
(goto-char (min (point-max) (+ (point) 13)))
(and (search-backward "------ NOTE:\n" nil t)
(setq pt (match-end 0))
(search-forward "\n------\n" nil t)))
(< (point) (match-end 0)))
(setq which (format "File: *%s *Node: *%s *Line:.*\n%s"
(regexp-quote file)
(regexp-quote Info-current-node)
(regexp-quote
(buffer-substring pt (match-beginning 0))))
where (max (- (point) pt) 0)))
(let ((node Info-current-node)
(line (if (looking-at "[ \n]*\\'") 0
(count-lines (point-min) (point)))))
(or which
(let ((buffer-read-only nil)
(bufmod (buffer-modified-p)))
(beginning-of-line)
(if (bobp) (goto-char (point-max)))
(insert "------ NOTE:\n------\n")
(backward-char 20)
(set-buffer-modified-p bufmod)))
;; (setq Info-window-start (window-start))
(setq Info-window-configuration (current-window-configuration))
(pop-to-buffer (find-file-noselect (nth arg Info-annotations-path)))
(use-local-map Info-annotate-map)
(setq major-mode 'Info-annotate-mode)
(setq mode-name "Info Annotate")
(if which
(if (save-excursion
(goto-char (point-min))
(re-search-forward which nil t))
(progn
(goto-char (match-beginning 0))
(forward-line 1)
(forward-char where)))
(let ((bufmod (buffer-modified-p)))
(goto-char (point-max))
(insert (format "\n------ File: %s Node: %s Line: %d\n"
file node line))
(setq pt (point))
(insert "\n------\n"
"\nPress C-c C-c to save and return to Info.\n")
(goto-char pt)
(set-buffer-modified-p bufmod))))))
>>>>> "P" == Pavel Jan