annotate lisp/hyperbole/hhist.el @ 111:164ab62060bf

Added tag r20-1b7 for changeset fe104dbd9147
author cvs
date Mon, 13 Aug 2007 09:19:47 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;!emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; FILE: hhist.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Maintains history of Hyperbole buttons selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; USAGE: GNU Emacs Lisp Library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; KEYWORDS: hypermedia
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; AUTHOR: Bob Weiner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; ORG: Brown U.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; ORIG-DATE: 24-Apr-91 at 03:36:23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; LAST-MOD: 14-Apr-95 at 16:02:05 by Bob Weiner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; This file is part of Hyperbole.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; Available for use and distribution under the same terms as GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; Copyright (C) 1991-1995, Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; Developed with support from Motorola Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; DESCRIPTION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; This is minimal right now and will be extended.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; Currently, it implements a push-pop stack of traversed locations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; It will be extended to allow random access to previous locations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; and to store traversal histories for later recall.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (defun hhist:add (elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 "Adds ELT to hyper-history list if not the same as current or previous loc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ELT must have been created via a call to 'hhist:element'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; Even though this next line looks useless, it cures a problem with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; window buffer correspondences on startup, so don't remove it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (set-buffer (window-buffer (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (let ((prev-buf (car elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (if (or (equal prev-buf (buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (equal prev-buf (car (car *hhist*))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (setq *hhist* (cons elt *hhist*)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (defun hhist:element ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 "Returns a history element for current point location."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (list (current-buffer) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (defun hhist:remove (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 "Removes optional prefix ARG entries from history, returns to ARGth location.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 The command is ignored with ARG < 1."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (setq arg (or arg 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (let ((prev-buf-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (if (null *hhist*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (and (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (message "(hhist:remove): No previous source to which to return.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (beep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (while (and (> arg 0) *hhist*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (setq prev-buf-line (car *hhist*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 *hhist* (cdr *hhist*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 arg (1- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (switch-to-buffer (car prev-buf-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (goto-char (car (cdr prev-buf-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (defun hhist:init ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 "Resets history list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (setq *hhist* nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (defun hhist:wind-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 "Returns window relative line number that point is on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (max 0 (1- (- (count-lines 1 (1+ (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (count-lines 1 (window-start))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defconst *hhist* nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 "List of previously visited Hyperbole button source locations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 Car of list is most recent.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (provide 'hhist)