• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/

Lines Matching defs:view

0 ;;; view.el --- peruse file or buffer without editing
29 ;; This package provides the `view' minor mode documented in the Emacs
31 ;; View mode entry and exit is done through the functions view-mode-enter
32 ;; and view-mode-exit. Use these functions to enter or exit view-mode from
34 ;; We use both view- and View- as prefix for symbols. View- is used as
35 ;; prefix for commands that have a key binding. view- is used for commands
41 ;; (define-key ctl-x-4-map "v" 'view-file-other-window) ; ^x4v
42 ;; (define-key ctl-x-5-map "v" 'view-file-other-frame) ; ^x5v
44 ;; You could also bind view-file, view-buffer, view-buffer-other-window and
45 ;; view-buffer-other-frame to keys.
50 (defgroup view nil
52 :link '(function-link view-mode)
57 (defcustom view-highlight-face 'highlight
60 :group 'view)
62 ;; `view-mode-auto-exit' is replaced by the following option variable which
63 ;; only says if scrolling past buffer end should leave view mode or not, it
64 ;; doesn't say if leaving view mode should restore windows or not. The latter
65 ;; is now controlled by the presence of a value in `view-return-to-alist'.
66 (defcustom view-scroll-auto-exit nil
71 :group 'view)
73 (defcustom view-try-extend-at-buffer-end nil
76 the F command in view-mode, but you can set it to t if you want the action
77 for all scroll commands in view mode."
79 :group 'view)
81 (defcustom view-remove-frame-by-deleting nil
85 :group 'view)
87 (defcustom view-exits-all-viewing-windows nil
88 "*Non-nil means restore all windows used to view buffer.
91 `view-return-to-alist'.
92 If `view-exits-all-viewing-windows' is nil, only the selected window is
95 :group 'view)
97 (defcustom view-inhibit-help-message nil
100 :group 'view
104 (defvar view-mode nil
107 functions that enable or disable view mode.")
109 (make-variable-buffer-local 'view-mode)
111 (defcustom view-mode-hook nil
112 "Normal hook run when starting to view a buffer or file."
114 :group 'view)
117 (defvar view-old-buffer-read-only nil)
118 (make-variable-buffer-local 'view-old-buffer-read-only)
120 (defvar view-old-Helper-return-blurb)
121 (make-variable-buffer-local 'view-old-Helper-return-blurb)
126 (defvar view-page-size nil
129 (make-variable-buffer-local 'view-page-size)
131 (defvar view-half-page-size nil
134 (make-variable-buffer-local 'view-half-page-size)
136 (defvar view-last-regexp nil)
137 (make-variable-buffer-local 'view-last-regexp) ; Global is better???
139 (defvar view-return-to-alist nil
142 It is added to by `view-mode-enter' when starting to view a buffer and
143 subtracted from by `view-mode-exit' when finished viewing the buffer.
145 See RETURN-TO-ALIST argument of function `view-mode-exit' for the format of
146 `view-return-to-alist'.")
147 (make-variable-buffer-local 'view-return-to-alist)
148 (put 'view-return-to-alist 'permanent-local t)
150 (defvar view-exit-action nil
153 The \\[view-file] and \\[view-file-other-window] commands may set this to
155 (make-variable-buffer-local 'view-exit-action)
157 (defvar view-no-disable-on-exit nil
163 (defvar view-overlay nil
166 (make-variable-buffer-local 'view-overlay)
168 (unless (assq 'view-mode minor-mode-alist)
170 (cons (list 'view-mode
179 (defvar view-mode-map
238 (or (assq 'view-mode minor-mode-map-alist)
240 (cons (cons 'view-mode view-mode-map) minor-mode-map-alist)))
243 ;;; Commands that enter or exit view mode.
246 (defun view-file (file)
254 This command runs the normal hook `view-mode-hook'."
265 (view-buffer buffer (and (not had-a-buf) 'kill-buffer)))))
268 (defun view-file-other-window (file)
277 This command runs the normal hook `view-mode-hook'."
278 (interactive "fIn other window view file: ")
281 (view-buffer-other-window (find-file-noselect file) nil
285 (defun view-file-other-frame (file)
294 This command runs the normal hook `view-mode-hook'."
295 (interactive "fIn other frame view file: ")
298 (view-buffer-other-frame (find-file-noselect file) nil
303 (defun view-buffer (buffer &optional exit-action)
311 This command runs the normal hook `view-mode-hook'.
315 Use this argument instead of explicitly setting `view-exit-action'."
320 (view-mode-enter (cons (selected-window) (cons nil undo-window))
324 (defun view-buffer-other-window (buffer &optional not-return exit-action)
333 This command runs the normal hook `view-mode-hook'.
337 Use this argument instead of explicitly setting `view-exit-action'."
338 (interactive "bIn other window view buffer:\nP")
351 (view-mode-enter (and return-to (cons (selected-window) return-to))
355 (defun view-buffer-other-frame (buffer &optional not-return exit-action)
364 This command runs the normal hook `view-mode-hook'.
368 Use this argument instead of explicitly setting `view-exit-action'."
373 (view-mode-enter (and return-to (cons (selected-window) return-to))
378 (defun view-mode (&optional arg)
389 \\<view-mode-map>
415 Use this to view a changing file.
436 \\[View-quit] is the normal way to leave view mode.
446 The effect of \\[View-leave], \\[View-quit] and \\[View-kill-and-leave] depends on how view-mode was entered. If it was
447 entered by view-file, view-file-other-window, view-file-other-frame, or
448 \\[dired-view-file] \(\\[view-file], \\[view-file-other-window],
449 \\[view-file-other-frame], or the Dired mode v command),
451 If view-mode was entered from another buffer, by \\[view-buffer],
452 \\[view-buffer-other-window], \\[view-buffer-other frame], \\[view-file],
453 \\[view-file-other-window], or \\[view-file-other-frame],
456 Entry to view-mode runs the normal hook `view-mode-hook'."
459 (if (> (prefix-numeric-value arg) 0) view-mode (not view-mode)))
460 (if view-mode (view-mode-disable)
461 (view-mode-enable))))
464 (defun view-mode-enable ()
466 ;; Always leave view mode before changing major mode.
468 (add-hook 'change-major-mode-hook 'view-mode-disable nil t)
469 (setq view-mode t
470 view-page-size nil
471 view-half-page-size nil
472 view-old-buffer-read-only buffer-read-only
474 view-old-Helper-return-blurb (and (boundp 'Helper-return-blurb)
482 (run-hooks 'view-mode-hook))
484 (defun view-mode-disable ()
486 (remove-hook 'change-major-mode-hook 'view-mode-disable t)
487 (and view-overlay (delete-overlay view-overlay))
490 ;; sets view-read-only to t as a buffer-local variable
495 (if (local-variable-p 'view-read-only)
496 (kill-local-variable 'view-read-only))
497 (setq view-mode nil
498 Helper-return-blurb view-old-Helper-return-blurb)
500 (setq buffer-read-only view-old-buffer-read-only)))
503 (defun view-mode-enter (&optional return-to exit-action) "\
504 Enter View mode and set up exit from view mode depending on optional arguments.
506 `view-return-to-alist'.
507 Save EXIT-ACTION in buffer local variable `view-exit-action'.
509 This function will be called by `view-mode-exit'.
511 RETURN-TO is either nil, meaning do nothing when exiting view mode, or
524 This function runs the normal hook `view-mode-hook'."
526 (let ((entry (assq (car return-to) view-return-to-alist)))
528 (setq view-return-to-alist (cons return-to view-return-to-alist)))))
529 (if exit-action (setq view-exit-action exit-action))
530 (unless view-mode ; Do nothing if already in view mode.
531 (view-mode-enable)
533 (unless view-inhibit-help-message
539 (defun view-mode-exit (&optional return-to-alist exit-action all-win)
546 If ALL-WIN or the variable `view-exits-all-viewing-windows' is non-nil,
563 (and return-to-alist (or all-win view-exits-all-viewing-windows)))
564 (if view-mode ; Only do something if in view mode.
584 (or view-no-disable-on-exit
585 (view-mode-disable))
605 (if view-remove-frame-by-deleting
611 ;; view-return-to-alist so that if the user deiconifies the frame
614 (setq view-return-to-alist
615 (delete (car alist) view-return-to-alist)))
620 (setq view-exit-action nil)
628 (view-mode-exit))
634 (let ((view-old-buffer-read-only nil)
635 (view-no-disable-on-exit nil))
636 (view-mode-exit)))
641 (view-mode-exit view-return-to-alist))
648 (view-mode-exit view-return-to-alist view-exit-action))
655 (view-mode-exit view-return-to-alist view-exit-action t))
660 (view-mode-exit view-return-to-alist (or view-exit-action 'kill-buffer) t))
666 (defun view-window-size ()
670 ;(defun view-last-command (&optional who what)
671 ; (setq view-last-command-entry this-command)
672 ; (setq view-last-command who)
673 ; (setq view-last-command-argument what))
678 ; (if (and view-last-command
679 ; (eq view-last-command-entry last-command))
680 ; (funcall view-last-command view-last-command-argument))
681 ; (setq this-command view-last-command-entry))
683 (defun view-recenter ()
685 (recenter (/ (view-window-size) 2)))
687 (defun view-page-size-default (lines)
689 (let ((default (- (view-window-size) next-screen-context-lines)))
694 (defun view-set-half-page-size-default (lines)
696 (if (not lines) (or view-half-page-size
697 (/ (view-window-size) 2))
698 (setq view-half-page-size
700 (/ (view-window-size) 2)
701 (view-page-size-default lines)))))
718 (view-recenter))
729 ; (view-recenter))
738 (view-recenter))
748 (view-recenter))
751 (defun view-scroll-lines (lines backward default maxdefault)
761 (setq default (view-page-size-default nil)) ; Max scrolled at a time.
765 ((view-really-at-end)
766 (if view-scroll-auto-exit (View-quit)
768 (view-end-message)))
772 (if (view-really-at-end) (setq lines 0)))
774 (if (view-really-at-end) (view-end-message))
778 (defun view-really-at-end ()
784 (or (not view-try-extend-at-buffer-end)
800 (defun view-end-message ()
803 (if view-return-to-alist
806 (if view-scroll-auto-exit "\\[View-scroll-page-forward]"
821 Exit if end of text is visible and `view-scroll-auto-exit' is non-nil.
827 (view-scroll-lines lines nil (view-page-size-default view-page-size) nil))
833 (view-scroll-lines lines t (view-page-size-default view-page-size) nil))
844 (view-scroll-lines lines nil
845 (setq view-page-size (view-page-size-default lines))
852 (view-scroll-lines lines t
853 (setq view-page-size (view-page-size-default lines))
861 (view-scroll-lines lines nil 1 t))
867 (view-scroll-lines lines t 1 t))
875 (view-scroll-lines lines nil (view-set-half-page-size-default lines) t))
881 (view-scroll-lines lines t (view-set-half-page-size-default lines) t))
895 (let ((view-scroll-auto-exit nil)
896 (view-try-extend-at-buffer-end t))
897 (view-scroll-lines lines nil (view-page-size-default view-page-size) nil)))
914 The variable `view-highlight-face' controls the face that is used
917 (view-search n regexp))
933 The variable `view-highlight-face' controls the face that is used
936 (view-search (- n) regexp))
943 The variable `view-highlight-face' controls the face that is used
946 (view-search n nil))
953 The variable `view-highlight-face' controls the face that is used
956 (view-search (- n) nil))
958 (defun view-search (times regexp)
961 ;; search backwards. If REGEXP is nil use `view-last-regexp'.
976 (setq view-last-regexp (if no (list regexp) regexp)))
977 ((consp view-last-regexp)
978 (setq regexp (car view-last-regexp))
979 (unless (setq no (not no)) (setq view-last-regexp regexp)))
980 (view-last-regexp (setq regexp view-last-regexp)
981 (if no (setq view-last-regexp (list regexp))))
986 (if (if no (view-search-no-match-lines times regexp)
993 (if view-overlay
994 (move-overlay view-overlay (match-beginning 0) (match-end 0))
995 (setq view-overlay
997 (overlay-put view-overlay 'face view-highlight-face)
999 (view-recenter))
1004 (defun view-search-no-match-lines (times regexp)
1026 (provide 'view)
1029 ;;; view.el ends here