Mercurial > emacs
comparison lisp/cedet/semantic/mru-bookmark.el @ 108210:5143700578d0
Use define-minor-mode in CEDET where applicable.
* cedet/srecode/mode.el (srecode-minor-mode,global-srecode-minor-mode):
Use define-minor-mode.
* cedet/semantic/util-modes.el (semantic-add-minor-mode):
Remove unused arg `keymap' and code redundant with define-minor-mode.
(semantic-toggle-minor-mode-globally): Only handle arg -1 and 1.
(semantic-stickyfunc-mode, global-semantic-show-unmatched-syntax-mode)
(semantic-highlight-func-mode, global-semantic-show-parser-state-mode)
(global-semantic-highlight-edits-mode, semantic-highlight-edits-mode)
(semantic-show-unmatched-syntax-mode, semantic-show-parser-state-mode)
(global-semantic-stickyfunc-mode, global-semantic-highlight-func-mode):
Use define-minor-mode.
(semantic-stickyfunc-mode-setup, semantic-highlight-edits-mode-setup)
(semantic-show-unmatched-syntax-mode-setup)
(semantic-show-parser-state-mode-setup)
(semantic-highlight-func-mode-setup): Inline into sole caller.
* cedet/semantic/mru-bookmark.el (global-semantic-mru-bookmark-mode)
(semantic-mru-bookmark-mode): Use define-minor-mode.
(semantic-mru-bookmark-mode-setup): Inline into sole caller.
* cedet/semantic/idle.el (define-semantic-idle-service):
Use define-minor-mode and inline setup function into its sole caller.
(semantic-idle-scheduler-mode-setup)
(semantic-idle-summary-mode-setup): Inline into sole caller.
(global-semantic-idle-scheduler-mode, semantic-idle-scheduler-mode):
Use define-minor-mode.
* cedet/semantic/decorate/mode.el (global-semantic-decoration-mode)
(semantic-decoration-mode): Use define-minor-mode.
(semantic-decoration-mode-setup): Inline into sole caller.
* cedet/ede/dired.el (ede-dired-minor-mode): Initialize in declaration.
(ede-dired-minor-mode): Use define-minor-mode and derived-mode-p.
(ede-dired-add-to-target): Use dolist.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sat, 01 May 2010 23:38:19 -0400 |
parents | 1d1d5d9bd884 |
children | 73a1ddc06d0e |
comparison
equal
deleted
inserted
replaced
108209:b757d9aee37e | 108210:5143700578d0 |
---|---|
237 | 237 |
238 ;;; MINOR MODE | 238 ;;; MINOR MODE |
239 ;; | 239 ;; |
240 ;; Tracking minor mode. | 240 ;; Tracking minor mode. |
241 | 241 |
242 (defcustom global-semantic-mru-bookmark-mode nil | |
243 "If non-nil, enable `semantic-mru-bookmark-mode' globally. | |
244 When this mode is enabled, Emacs keeps track of which tags have | |
245 been edited, and you can re-visit them with \\[semantic-mrub-switch-tags]." | |
246 :group 'semantic | |
247 :group 'semantic-modes | |
248 :type 'boolean | |
249 :require 'semantic-util-modes | |
250 :initialize 'custom-initialize-default | |
251 :set (lambda (sym val) | |
252 (global-semantic-mru-bookmark-mode (if val 1 -1)))) | |
253 | |
254 ;;;###autoload | 242 ;;;###autoload |
255 (defun global-semantic-mru-bookmark-mode (&optional arg) | 243 (define-minor-mode global-semantic-mru-bookmark-mode |
256 "Toggle global use of option `semantic-mru-bookmark-mode'. | 244 "Toggle global use of option `semantic-mru-bookmark-mode'. |
257 If ARG is positive, enable, if it is negative, disable. | 245 If ARG is positive or nil, enable, if it is negative, disable." |
258 If ARG is nil, then toggle." | 246 :global t :group 'semantic :group 'semantic-modes |
259 (interactive "P") | 247 ;; Not needed because it's autoloaded instead. |
260 (setq global-semantic-mru-bookmark-mode | 248 ;; :require 'semantic-util-modes |
261 (semantic-toggle-minor-mode-globally | 249 (semantic-toggle-minor-mode-globally |
262 'semantic-mru-bookmark-mode arg))) | 250 'semantic-mru-bookmark-mode (if global-semantic-mru-bookmark-mode 1 -1))) |
263 | 251 |
264 (defcustom semantic-mru-bookmark-mode-hook nil | 252 (defcustom semantic-mru-bookmark-mode-hook nil |
265 "*Hook run at the end of function `semantic-mru-bookmark-mode'." | 253 "*Hook run at the end of function `semantic-mru-bookmark-mode'." |
266 :group 'semantic | 254 :group 'semantic |
267 :type 'hook) | 255 :type 'hook) |
270 (let ((km (make-sparse-keymap))) | 258 (let ((km (make-sparse-keymap))) |
271 (define-key km "\C-xB" 'semantic-mrub-switch-tags) | 259 (define-key km "\C-xB" 'semantic-mrub-switch-tags) |
272 km) | 260 km) |
273 "Keymap for mru-bookmark minor mode.") | 261 "Keymap for mru-bookmark minor mode.") |
274 | 262 |
275 (defvar semantic-mru-bookmark-mode nil | 263 (define-minor-mode semantic-mru-bookmark-mode |
276 "Non-nil if mru-bookmark minor mode is enabled. | 264 "Minor mode for tracking tag-based bookmarks automatically. |
277 Use the command `semantic-mru-bookmark-mode' to change this variable.") | 265 When this mode is enabled, Emacs keeps track of which tags have |
278 (make-variable-buffer-local 'semantic-mru-bookmark-mode) | 266 been edited, and you can re-visit them with \\[semantic-mrub-switch-tags]. |
279 | 267 |
280 (defun semantic-mru-bookmark-mode-setup () | 268 \\{semantic-mru-bookmark-mode-map} |
281 "Setup option `semantic-mru-bookmark-mode'. | 269 |
282 The minor mode can be turned on only if semantic feature is available | 270 With prefix argument ARG, turn on if positive, otherwise off. The |
283 and the current buffer was set up for parsing. When minor mode is | 271 minor mode can be turned on only if semantic feature is available and |
284 enabled parse the current buffer if needed. Return non-nil if the | 272 the current buffer was set up for parsing. Return non-nil if the |
285 minor mode is enabled." | 273 minor mode is enabled." |
274 :keymap semantic-mru-bookmark-mode-map | |
286 (if semantic-mru-bookmark-mode | 275 (if semantic-mru-bookmark-mode |
287 (if (not (and (featurep 'semantic) (semantic-active-p))) | 276 (if (not (and (featurep 'semantic) (semantic-active-p))) |
288 (progn | 277 (progn |
289 ;; Disable minor mode if semantic stuff not available | 278 ;; Disable minor mode if semantic stuff not available |
290 (setq semantic-mru-bookmark-mode nil) | 279 (setq semantic-mru-bookmark-mode nil) |
292 (buffer-name))) | 281 (buffer-name))) |
293 (semantic-make-local-hook 'semantic-edits-new-change-hooks) | 282 (semantic-make-local-hook 'semantic-edits-new-change-hooks) |
294 (add-hook 'semantic-edits-new-change-hooks | 283 (add-hook 'semantic-edits-new-change-hooks |
295 'semantic-mru-bookmark-change-hook-fcn nil t) | 284 'semantic-mru-bookmark-change-hook-fcn nil t) |
296 (add-hook 'semantic-edits-move-change-hooks | 285 (add-hook 'semantic-edits-move-change-hooks |
297 'semantic-mru-bookmark-change-hook-fcn nil t) | 286 'semantic-mru-bookmark-change-hook-fcn nil t)) |
298 ) | |
299 ;; Remove hooks | 287 ;; Remove hooks |
300 (remove-hook 'semantic-edits-new-change-hooks | 288 (remove-hook 'semantic-edits-new-change-hooks |
301 'semantic-mru-bookmark-change-hook-fcn t) | 289 'semantic-mru-bookmark-change-hook-fcn t) |
302 (remove-hook 'semantic-edits-move-change-hooks | 290 (remove-hook 'semantic-edits-move-change-hooks |
303 'semantic-mru-bookmark-change-hook-fcn t) | 291 'semantic-mru-bookmark-change-hook-fcn t)) |
304 ) | 292 (semantic-mode-line-update)) |
305 semantic-mru-bookmark-mode) | |
306 | |
307 (defun semantic-mru-bookmark-mode (&optional arg) | |
308 "Minor mode for tracking tag-based bookmarks automatically. | |
309 When this mode is enabled, Emacs keeps track of which tags have | |
310 been edited, and you can re-visit them with \\[semantic-mrub-switch-tags]. | |
311 | |
312 \\{semantic-mru-bookmark-mode-map} | |
313 | |
314 With prefix argument ARG, turn on if positive, otherwise off. The | |
315 minor mode can be turned on only if semantic feature is available and | |
316 the current buffer was set up for parsing. Return non-nil if the | |
317 minor mode is enabled." | |
318 (interactive | |
319 (list (or current-prefix-arg | |
320 (if semantic-mru-bookmark-mode 0 1)))) | |
321 (setq semantic-mru-bookmark-mode | |
322 (if arg | |
323 (> | |
324 (prefix-numeric-value arg) | |
325 0) | |
326 (not semantic-mru-bookmark-mode))) | |
327 (semantic-mru-bookmark-mode-setup) | |
328 (run-hooks 'semantic-mru-bookmark-mode-hook) | |
329 (if (called-interactively-p 'interactive) | |
330 (message "mru-bookmark minor mode %sabled" | |
331 (if semantic-mru-bookmark-mode "en" "dis"))) | |
332 (semantic-mode-line-update) | |
333 semantic-mru-bookmark-mode) | |
334 | 293 |
335 (semantic-add-minor-mode 'semantic-mru-bookmark-mode | 294 (semantic-add-minor-mode 'semantic-mru-bookmark-mode |
336 "k" | 295 "k") |
337 semantic-mru-bookmark-mode-map) | |
338 | 296 |
339 ;;; COMPLETING READ | 297 ;;; COMPLETING READ |
340 ;; | 298 ;; |
341 ;; Ask the user for a tag in MRU order. | 299 ;; Ask the user for a tag in MRU order. |
342 (defun semantic-mrub-read-history nil | 300 (defun semantic-mrub-read-history nil |