Mercurial > emacs
comparison lisp/bookmark.el @ 13895:0c12b3398d37
Removed all `bookmark-xemacsp' conditional code relating to menus. Do
";;;###autoloads" the as they were done in 2.6.13.
(bookmark-version): new var, set to 2.6.19.
(baud-rate): set to 19200 if not already bound.
(bookmark-make): don't call `set-text-properties' on a Lisp string if
this is XEmacs, because it won't work.
(buffer-substring-no-properties): if this is not fboundp, then fset it
to `buffer-substring-without-properties'.
author | Karl Fogel <kfogel@red-bean.com> |
---|---|
date | Sat, 30 Dec 1995 19:52:40 +0000 |
parents | 273905baf4b3 |
children | 8fd836e88aec |
comparison
equal
deleted
inserted
replaced
13894:eeee95f4d989 | 13895:0c12b3398d37 |
---|---|
3 ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation | 3 ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation |
4 | 4 |
5 ;; Author: Karl Fogel <kfogel@cyclic.com> | 5 ;; Author: Karl Fogel <kfogel@cyclic.com> |
6 ;; Maintainer: Karl Fogel <kfogel@cyclic.com> | 6 ;; Maintainer: Karl Fogel <kfogel@cyclic.com> |
7 ;; Created: July, 1993 | 7 ;; Created: July, 1993 |
8 ;; Author's Update Number: 2.6.13 | 8 ;; Author's Update Number: see variable `bookmark-version'. |
9 ;; Keywords: bookmarks, placeholders, annotations | 9 ;; Keywords: bookmarks, placeholders, annotations |
10 | 10 |
11 ;;; Summary: | 11 ;;; Summary: |
12 ;; This package is for setting "bookmarks" in files. A bookmark | 12 ;; This package is for setting "bookmarks" in files. A bookmark |
13 ;; associates a string with a location in a certain file. Thus, you | 13 ;; associates a string with a location in a certain file. Thus, you |
67 ;; <olstad@msc.edu>. | 67 ;; <olstad@msc.edu>. |
68 | 68 |
69 ;; Thanks to Mikio Nakajima <PBC01764@niftyserve.or.jp> for many bugs | 69 ;; Thanks to Mikio Nakajima <PBC01764@niftyserve.or.jp> for many bugs |
70 ;; reported and fixed. | 70 ;; reported and fixed. |
71 | 71 |
72 ;; Thank you, Michael Kifer, for contributing the XEmacs support. | |
73 | |
72 ;; Enough with the credits already, get on to the good stuff: | 74 ;; Enough with the credits already, get on to the good stuff: |
73 | 75 |
74 ;; FAVORITE CHINESE RESTAURANT: | 76 ;; FAVORITE CHINESE RESTAURANT: |
75 ;; Boy, that's a tough one. Probably Hong Min, or maybe Emperor's | 77 ;; Boy, that's a tough one. Probably Hong Min, or maybe Emperor's |
76 ;; Choice (both in Chicago's Chinatown). Well, both. How about you? | 78 ;; Choice (both in Chicago's Chinatown). Well, both. How about you? |
78 | 80 |
79 (require 'pp) | 81 (require 'pp) |
80 | 82 |
81 | 83 |
82 ;;;; Code: | 84 ;;;; Code: |
85 | |
86 (defconst bookmark-version "2.6.19" | |
87 "Version number of bookmark.el. This is not related to the version | |
88 of Emacs bookmark comes with; it is used solely by bookmark's | |
89 maintainers to avoid version confusion.") | |
83 | 90 |
84 ;;; Misc comments: | 91 ;;; Misc comments: |
85 ;; | 92 ;; |
86 ;; If variable bookmark-use-annotations is non-nil, an annotation is | 93 ;; If variable bookmark-use-annotations is non-nil, an annotation is |
87 ;; queried for when setting a bookmark. | 94 ;; queried for when setting a bookmark. |
174 "*Maximum length of a bookmark name displayed on a popup menu.") | 181 "*Maximum length of a bookmark name displayed on a popup menu.") |
175 | 182 |
176 | 183 |
177 ;;; No user-serviceable parts beyond this point. | 184 ;;; No user-serviceable parts beyond this point. |
178 | 185 |
186 ;; Is it XEmacs? | |
187 (defconst bookmark-xemacsp | |
188 (string-match "\\(Lucid\\|Xemacs\\)" emacs-version)) | |
189 | |
190 | |
179 ;; Added for lucid emacs compatibility, db | 191 ;; Added for lucid emacs compatibility, db |
180 (or (fboundp 'defalias) (fset 'defalias 'fset)) | 192 (or (fboundp 'defalias) (fset 'defalias 'fset)) |
181 | 193 |
182 ;; suggested for lucid compatibility by david hughes: | 194 ;; suggested for lucid compatibility by david hughes: |
183 (or (fboundp 'frame-height) (defalias 'frame-height 'screen-height)) | 195 (or (fboundp 'frame-height) (defalias 'frame-height 'screen-height)) |
184 | 196 |
197 ;; This variable is probably obsolete now... | |
198 (or (boundp 'baud-rate) | |
199 ;; some random value higher than 9600 | |
200 (setq baud-rate 19200)) | |
201 | |
202 ;; XEmacs apparently call this `buffer-substring-without-properties', | |
203 ;; sigh. | |
204 (or (fboundp 'buffer-substring-no-properties) | |
205 (if (fboundp 'buffer-substring-without-properties) | |
206 (fset 'buffer-substring-no-properties | |
207 'buffer-substring-without-properties) | |
208 (fset 'buffer-substring-no-properties 'buffer-substring))) | |
185 | 209 |
186 | 210 |
187 ;;; Keymap stuff: | 211 ;;; Keymap stuff: |
188 ;; some people have C-x r set to rmail or whatever. We don't want to | 212 ;; some people have C-x r set to rmail or whatever. We don't want to |
189 ;; assume that C-x r is a prefix map just because it's distributed | 213 ;; assume that C-x r is a prefix map just because it's distributed |
472 Optional second arg ANNOTATION gives it an annotation. | 496 Optional second arg ANNOTATION gives it an annotation. |
473 Optional third arg OVERWRITE means replace any existing bookmarks with | 497 Optional third arg OVERWRITE means replace any existing bookmarks with |
474 this name." | 498 this name." |
475 (bookmark-maybe-load-default-file) | 499 (bookmark-maybe-load-default-file) |
476 (let ((stripped-name (copy-sequence name))) | 500 (let ((stripped-name (copy-sequence name))) |
477 (set-text-properties 0 (length stripped-name) nil stripped-name) | 501 (or bookmark-xemacsp |
502 ;; XEmacs's `set-text-properties' doesn't work on | |
503 ;; free-standing strings, apparently. | |
504 (set-text-properties 0 (length stripped-name) nil stripped-name)) | |
478 (if (and (bookmark-get-bookmark stripped-name) (not overwrite)) | 505 (if (and (bookmark-get-bookmark stripped-name) (not overwrite)) |
479 ;; already existing boookmark under that name and | 506 ;; already existing boookmark under that name and |
480 ;; no prefix arg means just overwrite old bookmark | 507 ;; no prefix arg means just overwrite old bookmark |
481 (setcdr (bookmark-get-bookmark stripped-name) | 508 (setcdr (bookmark-get-bookmark stripped-name) |
482 (list (bookmark-make-cell annotation))) | 509 (list (bookmark-make-cell annotation))) |
1956 | 1983 |
1957 ;; Return the menu: | 1984 ;; Return the menu: |
1958 (cons (concat "-*- " name " -*-") pane-list))) | 1985 (cons (concat "-*- " name " -*-") pane-list))) |
1959 | 1986 |
1960 | 1987 |
1988 (defun bookmark-build-xemacs-menu (name entries function) | |
1989 "Build a menu named NAME from the strings in ENTRIES. | |
1990 That is, ENTRIES is a list of strings that appear as the choices | |
1991 in the menu. | |
1992 The visible entries are truncated to `bookmark-menu-length', but the | |
1993 strings returned are not." | |
1994 (let* (lst | |
1995 (pane-list | |
1996 (progn | |
1997 (while entries | |
1998 (let ((str (car entries))) | |
1999 (setq lst (cons | |
2000 (vector | |
2001 (if (> (length str) bookmark-menu-length) | |
2002 (substring str 0 bookmark-menu-length) | |
2003 str) | |
2004 (list function str) | |
2005 t) | |
2006 lst)) | |
2007 (setq entries (cdr entries)))) | |
2008 (nreverse lst)))) | |
2009 | |
2010 ;; Return the menu: | |
2011 (append (if popup-menu-titles (list (concat "-*- " name " -*-"))) | |
2012 pane-list))) | |
2013 | |
2014 | |
1961 (defun bookmark-menu-popup-paned-menu (event name entries) | 2015 (defun bookmark-menu-popup-paned-menu (event name entries) |
1962 "Pop up multi-paned menu at EVENT, return string chosen from ENTRIES. | 2016 "Pop up multi-paned menu at EVENT, return string chosen from ENTRIES. |
1963 That is, ENTRIES is a list of strings which appear as the choices | 2017 That is, ENTRIES is a list of strings which appear as the choices |
1964 in the menu. | 2018 in the menu. |
1965 The number of panes depends on the number of entries." | 2019 The number of panes depends on the number of entries." |
2069 ;; following works, and for explaining what to do to make it work. | 2123 ;; following works, and for explaining what to do to make it work. |
2070 | 2124 |
2071 ;; We MUST autoload EACH form used to set up this variable's value, so | 2125 ;; We MUST autoload EACH form used to set up this variable's value, so |
2072 ;; that the whole job is done in loaddefs.el. | 2126 ;; that the whole job is done in loaddefs.el. |
2073 | 2127 |
2128 ;; FSF Emacs menubar stuff | |
2129 ;; The odd conditional structure is due to the limitations of autoload | |
2130 ;; cookies. | |
2131 | |
2074 ;;;###autoload | 2132 ;;;###autoload |
2075 (defvar menu-bar-bookmark-map (make-sparse-keymap "Bookmark functions")) | 2133 (defvar menu-bar-bookmark-map (make-sparse-keymap "Bookmark functions")) |
2076 | 2134 |
2077 ;;;###autoload | 2135 ;;;###autoload |
2078 (defalias 'menu-bar-bookmark-map (symbol-value 'menu-bar-bookmark-map)) | 2136 (defalias 'menu-bar-bookmark-map (symbol-value 'menu-bar-bookmark-map)) |
2079 | 2137 |
2138 ;; make bookmarks appear toward the right side of the menu. | |
2139 (if (boundp 'menu-bar-final-items) | |
2140 (if menu-bar-final-items | |
2141 (setq menu-bar-final-items | |
2142 (cons 'bookmark menu-bar-final-items))) | |
2143 (setq menu-bar-final-items '(bookmark))) | |
2144 | |
2080 ;;;###autoload | 2145 ;;;###autoload |
2081 (define-key menu-bar-bookmark-map [load] | 2146 (define-key menu-bar-bookmark-map [load] |
2082 '("Load a Bookmark File" . bookmark-load)) | 2147 '("Load a Bookmark File..." . bookmark-load)) |
2083 | 2148 |
2084 ;;;###autoload | 2149 ;;;###autoload |
2085 (define-key menu-bar-bookmark-map [write] | 2150 (define-key menu-bar-bookmark-map [write] |
2086 '("Write \(to another file\)" . bookmark-write)) | 2151 '("Save Bookmarks As..." . bookmark-write)) |
2087 | 2152 |
2088 ;;;###autoload | 2153 ;;;###autoload |
2089 (define-key menu-bar-bookmark-map [save] | 2154 (define-key menu-bar-bookmark-map [save] |
2090 '("Save \(in default file\)" . bookmark-save)) | 2155 '("Save Bookmarks" . bookmark-save)) |
2091 | 2156 |
2092 ;;;###autoload | 2157 ;;;###autoload |
2093 (define-key menu-bar-bookmark-map [edit] | 2158 (define-key menu-bar-bookmark-map [edit] |
2094 '("Edit Bookmark List" . bookmark-bmenu-list)) | 2159 '("Edit Bookmark List" . bookmark-bmenu-list)) |
2095 | 2160 |