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

Lines Matching defs:ex

217 (define-key vip-mode-map ":" 'vip-ex)
2055 ;; implement ex commands
2057 (defvar ex-token-type nil
2061 (defvar ex-token nil
2064 (defvar ex-addresses nil
2065 "list of ex addresses")
2067 (defvar ex-flag nil
2068 "flag for ex flag")
2070 (defvar ex-buffer nil
2071 "name of ex buffer")
2073 (defvar ex-count nil
2074 "value of ex count")
2076 (defvar ex-g-flag nil
2079 (defvar ex-g-variant nil
2080 "if t global command is executed on lines not matching ex-g-pat")
2082 (defvar ex-reg-exp nil
2085 (defvar ex-repl nil
2088 (defvar ex-g-pat nil
2091 (defvar ex-map (make-sparse-keymap)
2094 (defvar ex-tag nil
2095 "save ex tag")
2097 (defvar ex-file nil)
2099 (defvar ex-variant nil)
2101 (defvar ex-offset nil)
2103 (defvar ex-append nil)
2115 "check if ex-token is an initial segment of STR"
2116 (let ((length (length ex-token)))
2118 (string= ex-token (substring str 0 length)))
2119 (setq ex-token str)
2120 (setq ex-token-type "non-command"))))
2122 (defun vip-get-ex-com-subr ()
2123 "get a complete ex command"
2126 (setq ex-token-type "command")
2127 (setq ex-token (buffer-substring (point) (mark)))
2133 ((looking-at "[bh]") (setq ex-token-type "non-command"))
2139 (if (looking-at "ex") (vip-check-sub "ex")
2188 (defun vip-get-ex-token ()
2189 "get an ex-token which is either an address or a command.
2192 (set-buffer " *ex-working-space*")
2195 (setq ex-token-type "command")
2196 (setq ex-token (char-to-string (following-char)))
2198 ((looking-at "[a-z]") (vip-get-ex-com-subr))
2201 (setq ex-token-type "dot"))
2205 (setq ex-token-type
2206 (cond ((string= ex-token-type "plus") "add-number")
2207 ((string= ex-token-type "minus") "sub-number")
2209 (setq ex-token (string-to-number (buffer-substring (point) (mark)))))
2212 (setq ex-token-type "end"))
2215 (setq ex-token-type "whole"))
2221 (setq ex-token-type "plus"))
2224 (setq ex-token-type "plus"))
2232 (setq ex-token-type "minus"))
2235 (setq ex-token-type "minus"))
2248 (setq ex-token (buffer-substring (point) (mark)))
2250 (setq ex-token-type "search-forward"))
2262 (setq ex-token-type "search-backward")
2263 (setq ex-token (buffer-substring (1- (point)) (mark))))
2266 (setq ex-token-type "comma"))
2269 (setq ex-token-type "semi-colon"))
2271 (setq ex-token-type "command")
2272 (setq ex-token (char-to-string (following-char)))
2275 (setq ex-token-type "goto-mark")
2277 (cond ((looking-at "'") (setq ex-token nil))
2278 ((looking-at "[a-z]") (setq ex-token (following-char)))
2282 (setq ex-token-type "end-mark")
2283 (setq ex-token "goto"))
2287 (defun vip-ex (&optional string)
2288 "ex commands within VIP."
2291 (setq ex-g-flag nil
2292 ex-g-variant nil))
2296 (set-buffer (get-buffer-create " *ex-working-space*"))
2300 (setq ex-token-type "")
2301 (setq ex-addresses nil)
2303 (vip-get-ex-token)
2304 (cond ((or (string= ex-token-type "command")
2305 (string= ex-token-type "end-mark"))
2306 (if address (setq ex-addresses (cons address ex-addresses)))
2307 (cond ((string= ex-token "global")
2308 (ex-global nil)
2310 ((string= ex-token "v")
2311 (ex-global t)
2314 (vip-execute-ex-command)
2316 (set-buffer " *ex-working-space*")
2323 ((string= ex-token-type "non-command")
2324 (error "%s: Not an editor command" ex-token))
2325 ((string= ex-token-type "whole")
2326 (setq ex-addresses
2327 (cons (point-max) (cons (point-min) ex-addresses))))
2328 ((string= ex-token-type "comma")
2329 (setq ex-addresses
2330 (cons (if (null address) (point) address) ex-addresses)))
2331 ((string= ex-token-type "semi-colon")
2333 (setq ex-addresses
2334 (cons (if (null address) (point) address) ex-addresses)))
2335 (t (let ((ans (vip-get-ex-address-subr address dot)))
2338 (defun vip-get-ex-pat ()
2339 "get a regular expression and set ex-variant if found"
2341 (set-buffer " *ex-working-space*")
2345 (setq ex-g-variant (not ex-g-variant)
2346 ex-g-flag (not ex-g-flag))
2359 (setq ex-token
2363 (setq ex-token nil))))
2365 (defun vip-get-ex-command ()
2366 "get an ex command"
2368 (set-buffer " *ex-working-space*")
2372 (vip-get-ex-com-subr)
2373 (if (string= ex-token-type "non-command")
2374 (error "%s: not an editor command" ex-token)))
2376 (setq ex-token (char-to-string (following-char)))
2378 (t (error "Could not find an ex command")))))
2380 (defun vip-get-ex-opt-gc ()
2381 "get an ex option g or c"
2383 (set-buffer " *ex-working-space*")
2387 (setq ex-token "g")
2391 (setq ex-token "c")
2396 (defun vip-default-ex-addresses (&optional whole-flag)
2398 (cond ((null ex-addresses)
2399 (setq ex-addresses
2403 ((null (cdr ex-addresses))
2404 (setq ex-addresses
2405 (cons (car ex-addresses) ex-addresses)))))
2407 (defun vip-get-ex-address ()
2408 "get an ex-address as a marker and set ex-flag if a flag is found"
2410 (setq ex-token "")
2411 (setq ex-flag nil)
2413 (vip-get-ex-token)
2414 (cond ((string= ex-token-type "command")
2415 (if (or (string= ex-token "print") (string= ex-token "list")
2416 (string= ex-token "#"))
2418 (setq ex-flag t)
2421 ((string= ex-token-type "end-mark")
2423 ((string= ex-token-type "whole")
2425 ((string= ex-token-type "comma")
2427 (t (let ((ans (vip-get-ex-address-subr address (point-marker))))
2431 (defun vip-get-ex-address-subr (old-address dot)
2435 (cond ((string= ex-token-type "dot")
2437 ((string= ex-token-type "add-number")
2440 (forward-line (if (= old-address 0) (1- ex-token) ex-token))
2442 ((string= ex-token-type "sub-number")
2445 (forward-line (- ex-token))
2447 ((string= ex-token-type "abs-number")
2450 (if (= ex-token 0) (setq address 0)
2451 (forward-line (1- ex-token))
2453 ((string= ex-token-type "end")
2455 ((string= ex-token-type "plus") t);; do nothing
2456 ((string= ex-token-type "minus") t);; do nothing
2457 ((string= ex-token-type "search-forward")
2459 (ex-search-address t)
2461 ((string= ex-token-type "search-backward")
2463 (ex-search-address nil)
2465 ((string= ex-token-type "goto-mark")
2467 (if (null ex-token)
2469 (goto-char (register-to-point (- ex-token (- ?a ?\C-a)))))
2473 (defun ex-search-address (forward)
2475 (if (string= ex-token "")
2477 (setq ex-token vip-s-string))
2478 (setq vip-s-string ex-token))
2482 (re-search-forward ex-token))
2484 (re-search-backward ex-token)))
2486 (defun vip-get-ex-buffer ()
2487 "get a buffer name and set ex-count and ex-flag if found"
2488 (setq ex-buffer nil)
2489 (setq ex-count nil)
2490 (setq ex-flag nil)
2492 (set-buffer " *ex-working-space*")
2496 (setq ex-buffer (following-char))
2503 (setq ex-count (string-to-number (buffer-substring (point) (mark))))
2507 (setq ex-flag t)
2512 (defun vip-get-ex-count ()
2513 (setq ex-variant nil
2514 ex-count nil
2515 ex-flag nil)
2517 (set-buffer " *ex-working-space*")
2521 (setq ex-variant t)
2528 (setq ex-count (string-to-number (buffer-substring (point) (mark))))
2532 (setq ex-flag t)
2537 (defun vip-get-ex-file ()
2538 "get a file name and set ex-variant, ex-append and ex-offset if found"
2539 (setq ex-file nil
2540 ex-variant nil
2541 ex-append nil
2542 ex-offset nil)
2544 (set-buffer " *ex-working-space*")
2548 (setq ex-variant t)
2553 (setq ex-append t
2554 ex-variant t)
2563 (setq ex-offset (buffer-substring (point) (mark)))
2569 (setq ex-file (buffer-substring (point) (mark)))))
2571 (defun vip-execute-ex-command ()
2572 "execute ex command using the value of addresses."
2573 (cond ((string= ex-token "goto") (ex-goto))
2574 ((string= ex-token "copy") (ex-copy nil))
2575 ((string= ex-token "delete") (ex-delete))
2576 ((string= ex-token "edit") (ex-edit))
2577 ((string= ex-token "file") (vip-info-on-file))
2578 ;((string= ex-token "global") (ex-global nil))
2579 ((string= ex-token "join") (ex-line "join"))
2580 ((string= ex-token "k") (ex-mark))
2581 ((string= ex-token "mark") (ex-mark))
2582 ((string= ex-token "map") (ex-map))
2583 ((string= ex-token "move") (ex-copy t))
2584 ((string= ex-token "put") (ex-put))
2585 ((string= ex-token "quit") (ex-quit))
2586 ((string= ex-token "read") (ex-read))
2587 ((string= ex-token "set") (ex-set))
2588 ((string= ex-token "shell") (ex-shell))
2589 ((string= ex-token "substitute") (ex-substitute))
2590 ((string= ex-token "stop") (suspend-emacs))
2591 ((string= ex-token "t") (ex-copy nil))
2592 ((string= ex-token "tag") (ex-tag))
2593 ((string= ex-token "undo") (vip-undo))
2594 ((string= ex-token "unmap") (ex-unmap))
2595 ;((string= ex-token "v") (ex-global t))
2596 ((string= ex-token "version") (vip-version))
2597 ((string= ex-token "visual") (ex-edit))
2598 ((string= ex-token "write") (ex-write nil))
2599 ((string= ex-token "wq") (ex-write t))
2600 ((string= ex-token "yank") (ex-yank))
2601 ((string= ex-token "!") (ex-command))
2602 ((string= ex-token "=") (ex-line-no))
2603 ((string= ex-token ">") (ex-line "right"))
2604 ((string= ex-token "<") (ex-line "left"))
2605 ((string= ex-token "&") (ex-substitute t))
2606 ((string= ex-token "~") (ex-substitute t t))
2607 ((or (string= ex-token "append")
2608 (string= ex-token "args")
2609 (string= ex-token "change")
2610 (string= ex-token "insert")
2611 (string= ex-token "open")
2613 (error "%s: no such command from VIP" ex-token))
2614 ((or (string= ex-token "abbreviate")
2615 (string= ex-token "list")
2616 (string= ex-token "next")
2617 (string= ex-token "print")
2618 (string= ex-token "preserve")
2619 (string= ex-token "recover")
2620 (string= ex-token "rewind")
2621 (string= ex-token "source")
2622 (string= ex-token "unabbreviate")
2623 (string= ex-token "xit")
2624 (string= ex-token "z")
2626 (error "%s: not implemented in VIP" ex-token))
2627 (t (error "%s: Not an editor command" ex-token))))
2629 (defun ex-goto ()
2630 "ex goto command"
2631 (if (null ex-addresses)
2632 (setq ex-addresses (cons (point) nil)))
2634 (goto-char (car ex-addresses))
2637 (defun ex-copy (del-flag)
2638 "ex copy and move command. DEL-FLAG means delete."
2639 (vip-default-ex-addresses)
2640 (let ((address (vip-get-ex-address))
2641 (end (car ex-addresses)) (beg (car (cdr ex-addresses))))
2648 (if ex-flag
2652 (if (or del-flag ex-g-flag ex-g-variant)
2668 (defun ex-delete ()
2669 "ex delete"
2670 (vip-default-ex-addresses)
2671 (vip-get-ex-buffer)
2672 (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses))))
2677 (if ex-count
2680 (forward-line (1- ex-count)))
2683 (if ex-flag
2694 (if ex-buffer
2695 (if (and (<= ?A ex-buffer) (<= ex-buffer ?Z))
2697 (+ ex-buffer 32) (point) (mark))
2698 (copy-to-register ex-buffer (point) (mark) nil)))
2701 (defun ex-edit ()
2702 "ex-edit"
2703 (vip-get-ex-file)
2704 (if (and (not ex-variant) (buffer-modified-p) buffer-file-name)
2708 (find-file-noselect (concat default-directory ex-file)))
2711 (if ex-offset
2714 (set-buffer " *ex-working-space*")
2716 (insert ex-offset "\n")
2718 (goto-char (vip-get-ex-address))
2721 (defun ex-global (variant)
2722 "ex global command"
2723 (if (or ex-g-flag ex-g-variant)
2726 (setq ex-g-flag nil
2727 ex-g-variant t)
2728 (setq ex-g-flag t
2729 ex-g-variant nil)))
2730 (vip-get-ex-pat)
2731 (if (null ex-token)
2733 (if (string= ex-token "")
2735 (setq ex-g-pat vip-s-string))
2736 (setq ex-g-pat ex-token
2737 vip-s-string ex-token))
2738 (if (null ex-addresses)
2739 (setq ex-addresses (list (point-max) (point-min))))
2741 com-str (end (car ex-addresses)) (beg (car (cdr ex-addresses))))
2755 (let ((found (re-search-backward ex-g-pat (mark) t)))
2756 (if (or (and ex-g-flag found)
2757 (and ex-g-variant (not found)))
2767 (set-buffer " *ex-working-space*")
2775 (vip-ex com-str)
2780 (defun ex-line (com)
2781 "ex line commands. COM is join, shift-right or shift-left."
2782 (vip-default-ex-addresses)
2783 (vip-get-ex-count)
2784 (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses))) point)
2789 (if ex-count
2792 (forward-line ex-count)))
2793 (if ex-flag
2801 (ex-line-subr com (point) (mark)))
2805 (ex-line-subr com (point) (mark)))
2810 (defun ex-line-subr (com beg end)
2819 (if (not ex-variant) (fixup-whitespace))))))
2828 (defun ex-mark ()
2829 "ex mark"
2831 (if (null ex-addresses)
2832 (setq ex-addresses
2835 (set-buffer " *ex-working-space*")
2848 (goto-char (car ex-addresses))
2851 (defun ex-map ()
2852 "ex map"
2855 (set-buffer " *ex-working-space*")
2866 (if (not (lookup-key ex-map char))
2867 (define-key ex-map char
2877 (defun ex-unmap ()
2878 "ex unmap"
2881 (set-buffer " *ex-working-space*")
2887 (if (not (lookup-key ex-map char))
2889 (define-key vip-mode-map char (lookup-key ex-map char))
2890 (define-key ex-map char nil)))
2892 (defun ex-put ()
2893 "ex put"
2894 (let ((point (if (null ex-addresses) (point) (car ex-addresses))))
2895 (vip-get-ex-buffer)
2896 (setq vip-use-register ex-buffer)
2900 (defun ex-quit ()
2901 "ex quit"
2904 (set-buffer " *ex-working-space*")
2909 (defun ex-read ()
2910 "ex read"
2911 (let ((point (if (null ex-addresses) (point) (car ex-addresses)))
2917 (set-buffer " *ex-working-space*")
2936 (defun ex-set ()
2941 (defun ex-shell ()
2942 "ex shell"
2946 (defun ex-substitute (&optional repeat r-flag)
2947 "ex substitute.
2948 If REPEAT use previous reg-exp which is ex-reg-exp or
2951 (if repeat (setq ex-token nil) (vip-get-ex-pat))
2952 (if (null ex-token)
2953 (setq pat (if r-flag vip-s-string ex-reg-exp)
2954 repl ex-repl)
2955 (setq pat (if (string= ex-token "") vip-s-string ex-token))
2957 ex-reg-exp pat)
2958 (vip-get-ex-pat)
2959 (if (null ex-token)
2960 (setq ex-token ""
2961 ex-repl "")
2962 (setq repl ex-token
2963 ex-repl ex-token)))
2964 (while (vip-get-ex-opt-gc)
2965 (if (string= ex-token "g") (setq opt-g t) (setq opt-c t)))
2966 (vip-get-ex-count)
2967 (if ex-count
2969 (if ex-addresses (goto-char (car ex-addresses)))
2971 (forward-line (1- ex-count))
2972 (setq ex-addresses (cons (point) (cons (mark) nil))))
2973 (if (null ex-addresses)
2974 (setq ex-addresses (cons (point) (cons (point) nil)))
2975 (if (null (cdr ex-addresses))
2976 (setq ex-addresses (cons (car ex-addresses) ex-addresses)))))
2978 (let ((beg (car ex-addresses)) (end (car (cdr ex-addresses)))
3011 (defun ex-tag ()
3012 "ex tag"
3015 (set-buffer " *ex-working-space*")
3020 (if (not (string= tag "")) (setq ex-tag tag))
3025 (find-tag ex-tag t)
3026 (find-tag-other-window ex-tag))
3032 (defun ex-write (q-flag)
3033 "ex write"
3034 (vip-default-ex-addresses t)
3035 (vip-get-ex-file)
3036 (if (string= ex-file "")
3040 (setq ex-file buffer-file-name))
3041 (setq ex-file (expand-file-name ex-file)))
3042 (if (and (not (string= ex-file (buffer-file-name)))
3043 (file-exists-p ex-file)
3044 (not ex-variant))
3045 (error "\"%s\" File exists - use w! to override" ex-file))
3046 (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses))))
3050 (write-region (point) (mark) ex-file ex-append t)))
3051 (if (null buffer-file-name) (setq buffer-file-name ex-file))
3054 (defun ex-yank ()
3055 "ex yank"
3056 (vip-default-ex-addresses)
3057 (vip-get-ex-buffer)
3058 (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses))))
3063 (if (or ex-g-flag ex-g-variant) (error "Can't yank within global"))
3064 (if ex-count
3067 (forward-line (1- ex-count)))
3070 (if ex-flag (error "Extra characters at end of command"))
3071 (if ex-buffer
3072 (copy-to-register ex-buffer (point) (mark) nil))
3075 (defun ex-command ()
3079 (set-buffer " *ex-working-space*")
3084 (if (null ex-addresses)
3086 (let ((end (car ex-addresses)) (beg (car (cdr ex-addresses))))
3095 (defun ex-line-no ()
3100 (if (null ex-addresses) (point-max) (car ex-addresses))))))