• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/emulation/

Lines Matching +defs:shell +defs:mode

1 ;;; vi.el --- major mode for emulating "vi" editor under GNU Emacs
19 ;; 1) Add a global key binding for command "vi-mode" (I use ESC ESC instead of
23 ;; (define-key global-map "\e\e" 'vi-mode) ;quick switch into vi-mode
28 ;; (if (not (or (eq major-mode 'Info-mode)
29 ;; (eq major-mode 'vi-mode)))
30 ;; (vi-mode))))))
31 ;; 3) In your .emacs file you can define the command "vi-mode" to be "autoload"
33 ;; 4) Read the comments for command "vi-mode" before you start using it.
42 (defvar vi-mode-old-major-mode)
43 (defvar vi-mode-old-mode-name)
44 (defvar vi-mode-old-local-map)
45 (defvar vi-mode-old-case-fold)
47 (if (null (where-is-internal 'vi-switch-mode (current-local-map)))
48 (define-key ctl-x-map "~" 'vi-switch-mode))
51 "Keymap used for \\[vi-switch-mode] prefix key. Link to various major modes.")
56 (define-key vi-tilde-map "a" 'abbrev-mode)
57 (define-key vi-tilde-map "c" 'c-mode)
59 (define-key vi-tilde-map "e" 'emacs-lisp-mode)
60 (define-key vi-tilde-map "f" 'auto-fill-mode)
61 (define-key vi-tilde-map "g" 'prolog-mode)
63 (define-key vi-tilde-map "i" 'info-mode)
64 (define-key vi-tilde-map "l" 'lisp-mode)
65 (define-key vi-tilde-map "n" 'nroff-mode)
66 (define-key vi-tilde-map "o" 'overwrite-mode)
67 (define-key vi-tilde-map "O" 'outline-mode)
68 (define-key vi-tilde-map "P" 'picture-mode)
69 (define-key vi-tilde-map "r" 'vi-readonly-mode)
70 (define-key vi-tilde-map "t" 'text-mode)
71 (define-key vi-tilde-map "v" 'vi-mode)
72 (define-key vi-tilde-map "x" 'tex-mode)
73 (define-key vi-tilde-map "~" 'vi-back-to-old-mode))
76 (defun vi-switch-mode (arg mode-char)
77 "Switch the major mode of current buffer as specified by the following char \\{vi-tilde-map}"
79 (let ((mode-cmd (lookup-key vi-tilde-map (char-to-string mode-char))))
80 (if (null mode-cmd)
85 (help-mode)))
87 (command-execute mode-cmd nil) ; may need to save mode-line-format etc
88 (force-mode-line-update)))) ; just in case
102 (defun vi-back-to-old-mode ()
103 "Go back to the previous mode without setting up for insertion."
105 (if vi-mode-old-major-mode
107 (setq mode-name vi-mode-old-mode-name)
108 (use-local-map vi-mode-old-local-map)
109 (setq major-mode vi-mode-old-major-mode)
110 (setq case-fold-search vi-mode-old-case-fold)
111 (force-mode-line-update))))
113 (defun vi-readonly-mode ()
130 (define-key vi-com-map "\C-c" 'vi-do-old-mode-C-c-command) ; extension
353 (defvar vi-last-shell-command nil ; last shell op command line
354 "Save last shell command given for \"!\" operator.")
366 (defvar vi-mode-old-local-map nil
367 "Save the local-map used before entering vi-mode.")
369 (defvar vi-mode-old-mode-name nil
370 "Save the mode-name before entering vi-mode.")
372 (defvar vi-mode-old-major-mode nil
373 "Save the major-mode before entering vi-mode.")
375 (defvar vi-mode-old-case-fold nil)
377 ;(defconst vi-add-to-mode-line-1
378 ; '(overwrite-mode nil " Insert"))
380 ;; Value is same as vi-add-to-mode-line-1 when in vi mode,
382 ;(defvar vi-add-to-mode-line nil)
384 (defun vi-mode-setup ()
385 "Setup a buffer for vi-mode by creating necessary buffer-local variables."
386 ; (make-local-variable 'vi-add-to-mode-line)
387 ; (setq vi-add-to-mode-line vi-add-to-mode-line-1)
388 ; (or (memq vi-add-to-mode-line minor-mode-alist)
389 ; (setq minor-mode-alist (cons vi-add-to-mode-line minor-mode-alist)))
400 (make-local-variable 'vi-last-shell-command)
404 (make-local-variable 'vi-mode-old-local-map)
405 (make-local-variable 'vi-mode-old-mode-name)
406 (make-local-variable 'vi-mode-old-major-mode)
407 (make-local-variable 'vi-mode-old-case-fold)
408 (run-mode-hooks 'vi-mode-hook))
411 (defun vi-mode ()
412 "Major mode that acts like the `vi' editor.
413 The purpose of this mode is to provide you the combined power of vi (namely,
417 It records the previous major mode, and any vi command for input
418 \(`i', `a', `s', etc.) switches back to that mode.
419 Thus, ordinary Emacs (in whatever major mode you had been using)
420 is \"input\" mode as far as vi is concerned.
422 To get back into vi from \"input\" mode, you must issue this command again.
425 Major differences between this mode and real vi :
452 - Use \\[vi-switch-mode] to switch among different modes quickly.
454 Syntax table and abbrevs while in vi mode remain as they were in Emacs."
456 (if (null vi-mode-old-major-mode) ; very first call for current buffer
457 (vi-mode-setup))
459 (if (eq major-mode 'vi-mode)
460 (progn (ding) (message "Already in vi-mode."))
461 (setq vi-mode-old-local-map (current-local-map))
462 (setq vi-mode-old-mode-name mode-name)
463 (setq vi-mode-old-major-mode major-mode)
464 (setq vi-mode-old-case-fold case-fold-search) ; this is needed !!
467 (setq major-mode 'vi-mode)
468 (setq mode-name "VI")
469 (force-mode-line-update) ; force mode line update
489 "Ex commands are not implemented in Evi mode. For some commonly used ex
506 (help-mode))))
525 This function expects `overwrite-mode' being set properly beforehand."
530 (setq mode-name vi-mode-old-mode-name)
531 (setq case-fold-search vi-mode-old-case-fold)
532 (use-local-map vi-mode-old-local-map)
533 (setq major-mode vi-mode-old-major-mode)
534 (force-mode-line-update)
550 overwrite-mode vi-ins-prefix-code)
555 future redoes. Do prefix-code if it's given, use overwrite mode if asked."
563 "Redo more insertion : copy string from STR to point, use overwrite mode
570 "Go to vi-mode command state. If optional arg exists, means return from
575 (if overwrite-mode
576 (overwrite-mode 0)
577 ; (set-minor-mode 'ins "Insert" nil)
616 "open new line(s) and go into insert mode on the last line."
961 (overwrite-mode 1)
1021 (if (vi-shell-op motion-command arg)
1022 (vi-set-last-change-command 'vi-shell-op (vi-repeat-command-of motion-command) arg vi-last-shell-command)))
1143 (defun vi-shell-op (motion-command arg &optional shell-command)
1144 "Perform shell command (as filter).
1152 (cond ((null shell-command)
1153 (setq shell-command (read-string "!" nil))
1154 (setq vi-last-shell-command shell-command)))
1155 (shell-command-on-region begin end shell-command (not (vi-prefix-char-value arg)))
1417 (defun vi-do-old-mode-C-c-command (arg)
1418 "This is a hack for accessing mode specific C-c commands in vi-mode."
1420 (let ((cmd (lookup-key vi-mode-old-local-map
1422 (if (catch 'exit-vi-mode ; kludge hack due to dynamic binding
1426 (let ((case-fold-search vi-mode-old-case-fold)) ; a hack
1431 (vi-back-to-old-mode)