diff options
| author | Jim Blandy | 1991-05-17 00:15:22 +0000 |
|---|---|---|
| committer | Jim Blandy | 1991-05-17 00:15:22 +0000 |
| commit | 63c86e176db3da13697a283615420b6223f81f9e (patch) | |
| tree | cbea635ad26a9498a40c6a36d3062b2f1976aaf8 | |
| parent | db9f027896e815f919b717e699cd3a6c3daef956 (diff) | |
| download | emacs-63c86e176db3da13697a283615420b6223f81f9e.tar.gz emacs-63c86e176db3da13697a283615420b6223f81f9e.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/macros.el | 56 | ||||
| -rw-r--r-- | lisp/term/x-win.el | 135 |
2 files changed, 126 insertions, 65 deletions
diff --git a/lisp/macros.el b/lisp/macros.el index 75510a48ed9..42fedffafdc 100644 --- a/lisp/macros.el +++ b/lisp/macros.el | |||
| @@ -105,4 +105,60 @@ C-l -- redisplay screen and ask again." | |||
| 105 | (recursive-edit)))))))))) | 105 | (recursive-edit)))))))))) |
| 106 | 106 | ||
| 107 | ;;;###autoload | 107 | ;;;###autoload |
| 108 | (defun apply-macro-to-region-lines (top bottom &optional macro) | ||
| 109 | "For each complete line in the current region, move to the beginning of | ||
| 110 | the line, and run the last keyboard macro. | ||
| 111 | |||
| 112 | When called from lisp, this function takes two arguments TOP and | ||
| 113 | BOTTOM, describing the current region. TOP must be before BOTTOM. | ||
| 114 | The optional third argument MACRO specifies a keyboard macro to | ||
| 115 | execute. | ||
| 116 | |||
| 117 | This is useful for quoting or unquoting included text, adding and | ||
| 118 | removing comments, or producing tables where the entries are regular. | ||
| 119 | |||
| 120 | For example, in Usenet articles, sections of text quoted from another | ||
| 121 | author are indented, or have each line start with `>'. To quote a | ||
| 122 | section of text, define a keyboard macro which inserts `>', put point | ||
| 123 | and mark at opposite ends of the quoted section, and use | ||
| 124 | `\\[apply-macro-to-region-lines]' to mark the entire section. | ||
| 125 | |||
| 126 | Suppose you wanted to build a keyword table in C where each entry | ||
| 127 | looked like this: | ||
| 128 | |||
| 129 | { \"foo\", foo_data, foo_function }, | ||
| 130 | { \"bar\", bar_data, bar_function }, | ||
| 131 | { \"baz\", baz_data, baz_function }, | ||
| 132 | |||
| 133 | You could enter the names in this format: | ||
| 134 | |||
| 135 | foo | ||
| 136 | bar | ||
| 137 | baz | ||
| 138 | |||
| 139 | and write a macro to massage a word into a table entry: | ||
| 140 | |||
| 141 | \\C-x ( | ||
| 142 | \\M-d { \"\\C-y\", \\C-y_data, \\C-y_function }, | ||
| 143 | \\C-x ) | ||
| 144 | |||
| 145 | and then select the region of un-tablified names and use | ||
| 146 | `\\[apply-macro-to-region-lines]' to build the table from the names. | ||
| 147 | " | ||
| 148 | (interactive "r") | ||
| 149 | (if (null last-kbd-macro) | ||
| 150 | (error "No keyboard macro has been defined.")) | ||
| 151 | (save-excursion | ||
| 152 | (let ((end-marker (progn | ||
| 153 | (goto-char bottom) | ||
| 154 | (beginning-of-line) | ||
| 155 | (point-marker)))) | ||
| 156 | (goto-char top) | ||
| 157 | (if (not (bolp)) | ||
| 158 | (forward-line 1)) | ||
| 159 | (while (< (point) end-marker) | ||
| 160 | (execute-kbd-macro (or macro last-kbd-macro)) | ||
| 161 | (forward-line 1))))) | ||
| 162 | |||
| 163 | ;;;###autoload | ||
| 108 | (define-key ctl-x-map "q" 'kbd-macro-query) | 164 | (define-key ctl-x-map "q" 'kbd-macro-query) |
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el index feff6de1865..a848ecd4e80 100644 --- a/lisp/term/x-win.el +++ b/lisp/term/x-win.el | |||
| @@ -58,38 +58,44 @@ | |||
| 58 | ;; An alist of X options and the function which handles them. See | 58 | ;; An alist of X options and the function which handles them. See |
| 59 | ;; ../startup.el. | 59 | ;; ../startup.el. |
| 60 | 60 | ||
| 61 | (if (not (eq window-system 'x)) | ||
| 62 | (error "Loading x-win.el but not compiled for X")) | ||
| 63 | |||
| 61 | ;; This is a temporary work-around while we the separate keymap | 64 | ;; This is a temporary work-around while we the separate keymap |
| 62 | ;; stuff isn't yet fixed. These variables aren't used anymore, | 65 | ;; stuff isn't yet fixed. These variables aren't used anymore, |
| 63 | ;; but the lisp code wants them to exist. -JimB | 66 | ;; but the lisp code wants them to exist. -JimB |
| 64 | (setq global-mouse-map (make-sparse-keymap)) | 67 | (setq global-mouse-map (make-sparse-keymap)) |
| 65 | (setq global-function-map (make-sparse-keymap)) | 68 | (setq global-function-map (make-sparse-keymap)) |
| 66 | 69 | ||
| 70 | (require 'x-mouse) | ||
| 71 | (require 'screen) | ||
| 72 | |||
| 67 | (setq command-switch-alist | 73 | (setq command-switch-alist |
| 68 | (append '(("-dm" . x-establish-daemon-mode) | 74 | (append '(("-dm" . x-establish-daemon-mode) |
| 69 | ("-bw" . x-handle-numeric-switch) | 75 | ("-bw" . x-handle-numeric-switch) |
| 70 | ("-d" . x-handle-display) | 76 | ("-d" . x-handle-display) |
| 71 | ("-display" . x-handle-display) | 77 | ("-display" . x-handle-display) |
| 72 | ("-name" . x-handle-switch) | 78 | ("-name" . x-handle-switch) |
| 73 | ("-T" . x-handle-switch) | 79 | ("-T" . x-handle-switch) |
| 74 | ("-r" . x-handle-switch) | 80 | ("-r" . x-handle-switch) |
| 75 | ("-rv" . x-handle-switch) | 81 | ("-rv" . x-handle-switch) |
| 76 | ("-reverse" . x-handle-switch) | 82 | ("-reverse" . x-handle-switch) |
| 77 | ("-fn" . x-handle-switch) | 83 | ("-fn" . x-handle-switch) |
| 78 | ("-font" . x-handle-switch) | 84 | ("-font" . x-handle-switch) |
| 79 | ("-ib" . x-handle-switch) | 85 | ("-ib" . x-handle-switch) |
| 80 | ("-g" . x-handle-geometry) | 86 | ("-g" . x-handle-geometry) |
| 81 | ("-geometry" . x-handle-geometry) | 87 | ("-geometry" . x-handle-geometry) |
| 82 | ("-fg" . x-handle-switch) | 88 | ("-fg" . x-handle-switch) |
| 83 | ("-foreground" . x-handle-switch) | 89 | ("-foreground". x-handle-switch) |
| 84 | ("-bg" . x-handle-switch) | 90 | ("-bg" . x-handle-switch) |
| 85 | ("-background" . x-handle-switch) | 91 | ("-background". x-handle-switch) |
| 86 | ("-ms" . x-handle-switch) | 92 | ("-ms" . x-handle-switch) |
| 87 | ("-ib" . x-handle-switch) | 93 | ("-ib" . x-handle-switch) |
| 88 | ("-iconic" . x-handle-switch) | 94 | ("-iconic" . x-handle-switch) |
| 89 | ("-cr" . x-handle-switch) | 95 | ("-cr" . x-handle-switch) |
| 90 | ("-vb" . x-handle-switch) | 96 | ("-vb" . x-handle-switch) |
| 91 | ("-hb" . x-handle-switch) | 97 | ("-hb" . x-handle-switch) |
| 92 | ("-bd" . x-handle-switch)) | 98 | ("-bd" . x-handle-switch)) |
| 93 | command-switch-alist)) | 99 | command-switch-alist)) |
| 94 | 100 | ||
| 95 | (defvar x-switches-specified nil) | 101 | (defvar x-switches-specified nil) |
| @@ -161,53 +167,37 @@ | |||
| 161 | (setq x-display-name (car x-invocation-args) | 167 | (setq x-display-name (car x-invocation-args) |
| 162 | x-invocation-args (cdr x-invocation-args))) | 168 | x-invocation-args (cdr x-invocation-args))) |
| 163 | 169 | ||
| 164 | ;; Here the X-related command line options are processed, before the user's | ||
| 165 | ;; startup file is loaded. These are present in ARGS (see startup.el). | ||
| 166 | ;; They are copied to x-invocation args from which the X-related things | ||
| 167 | ;; are extracted, first the switch (e.g., "-fg") in the following code, | ||
| 168 | ;; and possible values (e.g., "black") in the option handler code | ||
| 169 | ;; (e.g., x-handle-switch). | ||
| 170 | |||
| 171 | ;; When finished, only things not pertaining to X (e.g., "-q", filenames) | ||
| 172 | ;; are left in ARGS | ||
| 173 | |||
| 174 | (defvar x-invocation-args nil) | 170 | (defvar x-invocation-args nil) |
| 175 | 171 | ||
| 176 | (if (eq window-system 'x) | 172 | (defun x-handle-args () |
| 177 | (progn | 173 | "Here the X-related command line options are processed, before the user's |
| 178 | (setq window-setup-hook 'x-pop-initial-window | 174 | startup file is loaded. These are present in ARGS (see startup.el). |
| 179 | x-invocation-args args | 175 | They are copied to x-invocation args from which the X-related things |
| 180 | args nil) | 176 | are extracted, first the switch (e.g., \"-fg\") in the following code, |
| 181 | (require 'x-mouse) | 177 | and possible values (e.g., \"black\") in the option handler code (e.g., |
| 182 | (require 'screen) | 178 | x-handle-switch). |
| 183 | (setq suspend-hook | 179 | When finished, only things not pertaining to X (e.g., \"-q\", filenames) |
| 184 | '(lambda () | 180 | are left in ARGS." |
| 185 | (error "Suspending an emacs running under X makes no sense"))) | 181 | (setq x-invocation-args args |
| 186 | (define-key global-map "" 'iconify-emacs) | 182 | args nil) |
| 187 | (while x-invocation-args | 183 | (while x-invocation-args |
| 188 | (let* ((this-switch (car x-invocation-args)) | 184 | (let* ((this-switch (car x-invocation-args)) |
| 189 | (aelt (assoc this-switch command-switch-alist))) | 185 | (aelt (assoc this-switch command-switch-alist))) |
| 190 | (setq x-invocation-args (cdr x-invocation-args)) | 186 | (setq x-invocation-args (cdr x-invocation-args)) |
| 191 | (if aelt | 187 | (if aelt |
| 192 | (funcall (cdr aelt) this-switch) | 188 | (funcall (cdr aelt) this-switch) |
| 193 | (setq args (cons this-switch args))))) | 189 | (setq args (cons this-switch args))))) |
| 194 | (setq args (nreverse args)) | 190 | (setq args (nreverse args))) |
| 195 | (x-open-connection (or x-display-name | 191 | |
| 196 | (setq x-display-name (getenv "DISPLAY")))) | 192 | ;; |
| 197 | ;; | 193 | ;; This is the place to handle Xresources |
| 198 | ;; This is the place to handle Xresources | 194 | ;; |
| 199 | ;; | ||
| 200 | ) | ||
| 201 | (error "Loading x-win.el but not compiled for X")) | ||
| 202 | 195 | ||
| 203 | 196 | ||
| 204 | ;; This is the function which creates the first X window. It is called | 197 | ;; This is the function which creates the first X window. It is called |
| 205 | ;; from startup.el after the user's init file is processed. | 198 | ;; from startup.el before the user's init file is processed. |
| 206 | 199 | ||
| 207 | (defun x-pop-initial-window () | 200 | (defun x-pop-initial-window () |
| 208 | ;; xterm.c depends on using interrupt-driven input. | ||
| 209 | (set-input-mode t nil t) | ||
| 210 | (setq mouse-motion-handler 'x-track-pointer) | ||
| 211 | (setq x-switches-specified (append x-switches-specified | 201 | (setq x-switches-specified (append x-switches-specified |
| 212 | initial-screen-alist | 202 | initial-screen-alist |
| 213 | screen-default-alist)) | 203 | screen-default-alist)) |
| @@ -613,3 +603,18 @@ | |||
| 613 | (define-function-key global-function-map 'xk-f33 nil) | 603 | (define-function-key global-function-map 'xk-f33 nil) |
| 614 | (define-function-key global-function-map 'xk-f34 nil) | 604 | (define-function-key global-function-map 'xk-f34 nil) |
| 615 | (define-function-key global-function-map 'xk-f35 nil) | 605 | (define-function-key global-function-map 'xk-f35 nil) |
| 606 | |||
| 607 | ;;; Here | ||
| 608 | |||
| 609 | ;; xterm.c depends on using interrupt-driven input. | ||
| 610 | (set-input-mode t nil t) | ||
| 611 | (x-handle-args) | ||
| 612 | (x-open-connection (or x-display-name | ||
| 613 | (setq x-display-name (getenv "DISPLAY")))) | ||
| 614 | (x-pop-initial-window) | ||
| 615 | |||
| 616 | (setq suspend-hook | ||
| 617 | '(lambda () | ||
| 618 | (error "Suspending an emacs running under X makes no sense"))) | ||
| 619 | |||
| 620 | (define-key global-map "\C-z" 'iconify-emacs) | ||