Mercurial > emacs
annotate lisp/progmodes/asm-mode.el @ 1717:aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
`has_vertical_scrollbars'.
(FRAME_CAN_HAVE_SCROLLBARS, FRAME_HAS_VERTICAL_SCROLLBARS): New
accessors, for both the MULTI_FRAME and non-MULTI_FRAME.
(VERTICAL_SCROLLBAR_WIDTH, WINDOW_VERTICAL_SCROLLBAR,
WINDOW_VERTICAL_SCROLLBAR_COLUMN,
WINDOW_VERTICAL_SCROLLBAR_HEIGHT): New macros.
* window.h (struct window): New field `vertical_scrollbar'.
* xterm.h (struct x_display): vertical_scrollbars,
judge_timestamp, vertical_scrollbar_extra: New fields.
(struct scrollbar): New struct.
(VERTICAL_SCROLLBAR_PIXEL_WIDTH, VERTICAL_SCROLLBAR_PIXEL_HEIGHT,
VERTICAL_SCROLLBAR_LEFT_BORDER, VERTICAL_SCROLLBAR_RIGHT_BORDER,
VERTICAL_SCROLLBAR_TOP_BORDER, VERTICAL_SCROLLBAR_BOTTOM_BORDER,
CHAR_TO_PIXEL_WIDTH, CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_WIDTH,
PIXEL_TO_CHAR_HEIGHT): New accessors and macros.
* frame.c (make_frame): Initialize the `can_have_scrollbars' and
`has_vertical_scrollbars' fields of the frame.
* term.c (term_init): Note that TERMCAP terminals don't support
scrollbars.
(mouse_position_hook): Document new args.
(set_vertical_scrollbar_hook, condemn_scrollbars_hook,
redeem_scrollbar_hook, judge_scrollbars_hook): New hooks.
* termhooks.h: Declare and document them.
(enum scrollbar_part): New type.
(struct input_event): Describe the new form of the scrollbar_click
event type. Change `part' from a Lisp_Object to an enum
scrollbar_part. Add a new field `scrollbar'.
* keyboard.c (kbd_buffer_get_event): Pass appropriate new
parameters to *mouse_position_hook, and make_lispy_movement.
* xfns.c (x_set_vertical_scrollbar): New function.
(x_figure_window_size): Use new macros to calculate frame size.
(Fx_create_frame): Note that X Windows frames do support scroll
bars. Default to "yes".
* xterm.c: #include <X11/cursorfont.h> and "window.h".
(x_vertical_scrollbar_cursor): New variable.
(x_term_init): Initialize it.
(last_mouse_bar, last_mouse_bar_frame, last_mouse_part,
last_mouse_scroll_range_start, last_mouse_scroll_range_end): New
variables.
(XTmouse_position): Use them to return scrollbar movement events.
Take new arguments, for that purpose.
(x_window_to_scrollbar, x_scrollbar_create,
x_scrollbar_set_handle, x_scrollbar_remove, x_scrollbar_move,
XTset_scrollbar, XTcondemn_scrollbars, XTredeem_scrollbar,
XTjudge_scrollbars, x_scrollbar_expose,
x_scrollbar_background_expose, x_scrollbar_handle_click,
x_scrollbar_handle_motion): New functions to implement scrollbars.
(x_term_init): Set the termhooks.h hooks to point to them.
(x_set_window_size): Use new macros to calculate frame size. Set
vertical_scrollbar_extra field.
(x_make_frame_visible): Use the frame accessor
FRAME_HAS_VERTICAL_SCROLLBARS to decide if we need to map the
frame's subwindows as well.
(XTread_socket): Use new size-calculation macros from xterm.h when
processing ConfigureNotify events.
(x_wm_set_size_hint): Use PIXEL_TO_CHAR_WIDTH and
PIXEL_TO_CHAR_HEIGHT macros.
* ymakefile (xdisp.o): This now depends on termhooks.h.
(xterm.o): This now depends on window.h.
| author | Jim Blandy <jimb@redhat.com> |
|---|---|
| date | Thu, 24 Dec 1992 06:17:18 +0000 |
| parents | 7861f8756850 |
| children | 7c9deb765a64 |
| rev | line source |
|---|---|
|
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
1 ;;; asm-mode.el --- mode for editing assembler code |
|
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
2 |
| 869 | 3 ;; Copyright (C) 1991 Free Software Foundation, Inc. |
| 4 | |
|
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> |
|
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
6 ;; Last-Modified: 14 Jul 1992 |
|
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
7 ;; Keywords: tools, languages |
|
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
8 |
| 869 | 9 ;; @(#)asm-mode.el 1.7 |
| 473 | 10 |
| 11 ;; This file is part of GNU Emacs. | |
| 12 | |
| 13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
| 14 ;; it under the terms of the GNU General Public License as published by | |
| 869 | 15 ;; the Free Software Foundation; either version 2, or (at your option) |
| 473 | 16 ;; any later version. |
| 17 | |
| 18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 21 ;; GNU General Public License for more details. | |
| 22 | |
| 23 ;; You should have received a copy of the GNU General Public License | |
| 24 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
| 25 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 26 | |
|
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
27 ;;; Commentary: |
|
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
28 |
|
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
29 ;; This mode was written by Eric S. Raymond <esr@snark.thyrsus.com>, |
| 473 | 30 ;; inspired by an earlier asm-mode by Martin Neitzel. |
| 31 | |
| 32 ;; This minor mode is based on text mode. It defines a private abbrev table | |
| 33 ;; that can be used to save abbrevs for assembler mnemonics. It binds just | |
| 34 ;; five keys: | |
| 35 ;; | |
| 36 ;; TAB tab to next tab stop | |
| 37 ;; : outdent preceding label, tab to tab stop | |
| 38 ;; ; place or move comment | |
| 39 ;; C-j, C-m newline and tab to tab stop | |
| 40 ;; | |
| 41 ;; Code is indented to the first tab stop level. | |
| 42 ;; The ; key inserts copies of the value of asm-comment-char at an | |
| 43 ;; appropriate spot. | |
|
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
44 |
| 473 | 45 ;; This mode runs two hooks: |
| 46 ;; 1) An asm-set-comment-hook before the part of the initialization | |
| 47 ;; depending on asm-comment-char, and | |
| 48 ;; 2) an asm-mode-hook at the end of initialization. | |
| 49 | |
|
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
50 ;;; Code: |
|
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
51 |
| 473 | 52 (defvar asm-comment-char ?; |
| 53 "*The comment-start character assumed by asm-mode.") | |
| 54 | |
| 55 (defvar asm-mode-syntax-table nil | |
| 56 "Syntax table used while in asm mode.") | |
| 57 | |
| 58 (defvar asm-mode-abbrev-table nil | |
| 59 "Abbrev table used while in asm mode.") | |
| 60 (define-abbrev-table 'asm-mode-abbrev-table ()) | |
| 61 | |
| 62 (defvar asm-mode-map nil | |
| 63 "Keymap for asm-mode") | |
| 64 | |
| 65 (if asm-mode-map | |
| 66 nil | |
| 67 (setq asm-mode-map (make-sparse-keymap)) | |
| 68 (define-key asm-mode-map ";" 'asm-comment) | |
| 69 (define-key asm-mode-map ":" 'asm-colon) | |
| 70 (define-key asm-mode-map "\C-i" 'tab-to-tab-stop) | |
|
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
71 (define-key asm-mode-map "\C-j" 'asm-newline) |
|
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
72 (define-key asm-mode-map "\C-m" 'asm-newline) |
|
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
73 ) |
| 473 | 74 |
| 75 (defvar asm-code-level-empty-comment-pattern nil) | |
| 76 (defvar asm-flush-left-empty-comment-pattern nil) | |
| 77 (defvar asm-inline-empty-comment-pattern nil) | |
| 78 | |
| 79 ;;;###autoload | |
| 80 (defun asm-mode () | |
| 81 "Major mode for editing typical assembler code. | |
|
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
82 Features a private asm-mode-abbrev-table and the following bindings: |
| 473 | 83 |
| 84 \\[asm-colon]\toutdent a preceding label, tab to next tab stop. | |
| 85 \\[tab-to-tab-stop]\ttab to next tab stop. | |
| 86 \\[asm-newline]\tnewline, then tab to next tab stop. | |
| 87 \\[asm-comment]\tsmart placement of assembler comments. | |
| 88 | |
| 89 The character used for making comments is set by the variable | |
|
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
90 asm-comment-char (which defaults to ?;). You may want to set this |
|
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
91 appropriately for the assembler on your machine in defaults.el. |
| 473 | 92 |
|
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
93 Alternatively, you may set this variable in asm-set-comment-hook, which is |
| 473 | 94 called near the beginning of mode initialization. |
| 95 | |
|
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
803
diff
changeset
|
96 Turning on asm-mode calls the value of the variable asm-mode-hook, |
| 473 | 97 if that value is non-nil, at the end of initialization. |
| 98 | |
| 99 Special commands:\\{asm-mode-map} | |
| 100 " | |
| 101 (interactive) | |
| 102 (kill-all-local-variables) | |
| 103 (use-local-map asm-mode-map) | |
| 104 (setq mode-name "Assembler") | |
| 105 (setq major-mode 'asm-mode) | |
| 106 (setq local-abbrev-table asm-mode-abbrev-table) | |
| 107 (make-local-variable 'asm-mode-syntax-table) | |
| 108 (setq asm-mode-syntax-table (make-syntax-table)) | |
| 109 (set-syntax-table asm-mode-syntax-table) | |
| 110 (run-hooks 'asm-mode-set-comment-hook) | |
| 111 (modify-syntax-entry asm-comment-char | |
| 112 "<" asm-mode-syntax-table) | |
| 113 (modify-syntax-entry ?\n | |
| 114 ">" asm-mode-syntax-table) | |
| 115 (let ((cs (regexp-quote (char-to-string asm-comment-char)))) | |
| 116 (make-local-variable 'comment-start) | |
| 117 (setq comment-start (concat cs " ")) | |
| 118 (make-local-variable 'comment-start-skip) | |
| 119 (setq comment-start-skip (concat cs "+[ \t]*")) | |
| 120 (setq asm-inline-empty-comment-pattern (concat "^.+" cs "+ *$")) | |
| 121 (setq asm-code-level-empty-comment-pattern (concat "^[\t ]+" cs cs " *$")) | |
| 122 (setq asm-flush-left-empty-comment-pattern (concat "^" cs cs cs " *$")) | |
| 123 ) | |
| 124 (make-local-variable 'comment-end) | |
| 125 (setq comment-end "") | |
| 126 (make-local-variable 'comment-column) | |
| 127 (setq comment-column 32) | |
| 128 (auto-fill-mode 1) | |
| 129 (setq fill-prefix "\t") | |
| 130 (run-hooks 'asm-mode-hook) | |
| 131 ) | |
| 132 | |
| 133 | |
| 134 (defun asm-colon () | |
| 135 "Insert a colon; if it follows a label, delete the label's indentation." | |
| 136 (interactive) | |
| 137 (save-excursion | |
| 138 (beginning-of-line) | |
| 139 (if (looking-at "[ \t]+\\(\\sw\\|\\s_\\)+$") | |
| 140 (delete-horizontal-space))) | |
| 141 (insert ":") | |
| 142 (tab-to-tab-stop) | |
| 143 ) | |
| 144 | |
| 145 (defun asm-newline () | |
| 146 "Insert LFD + fill-prefix, to bring us back to code-indent level." | |
| 147 (interactive) | |
| 148 (if (eolp) (delete-horizontal-space)) | |
| 149 (insert "\n") | |
| 150 (tab-to-tab-stop) | |
| 151 ) | |
| 152 | |
| 153 (defun asm-line-matches (pattern &optional withcomment) | |
| 154 (save-excursion | |
| 155 (beginning-of-line) | |
| 156 (looking-at pattern))) | |
| 157 | |
| 158 (defun asm-pop-comment-level () | |
| 159 ;; Delete an empty comment ending current line. Then set up for a new one, | |
| 160 ;; on the current line if it was all comment, otherwise above it | |
| 161 (end-of-line) | |
| 162 (delete-horizontal-space) | |
| 163 (while (= (preceding-char) asm-comment-char) | |
| 164 (delete-backward-char 1)) | |
| 165 (delete-horizontal-space) | |
| 166 (if (bolp) | |
| 167 nil | |
| 168 (beginning-of-line) | |
| 169 (open-line 1)) | |
| 170 ) | |
| 171 | |
| 172 | |
| 173 (defun asm-comment () | |
| 174 "Convert an empty comment to a `larger' kind, or start a new one. | |
| 175 These are the known comment classes: | |
| 176 | |
| 177 1 -- comment to the right of the code (at the comment-column) | |
| 178 2 -- comment on its own line, indented like code | |
| 179 3 -- comment on its own line, beginning at the left-most column. | |
| 180 | |
| 181 Suggested usage: while writing your code, trigger asm-comment | |
| 182 repeatedly until you are satisfied with the kind of comment." | |
| 183 (interactive) | |
| 184 (cond | |
| 185 | |
| 186 ;; Blank line? Then start comment at code indent level. | |
| 187 ((asm-line-matches "^[ \t]*$") | |
| 188 (delete-horizontal-space) | |
| 189 (tab-to-tab-stop) | |
| 190 (insert asm-comment-char comment-start)) | |
| 191 | |
| 192 ;; Nonblank line with no comment chars in it? | |
| 193 ;; Then start a comment at the current comment column | |
| 194 ((asm-line-matches (format "^[^%c]+$" asm-comment-char)) | |
| 195 (indent-for-comment)) | |
| 196 | |
| 197 ;; Flush-left comment present? Just insert character. | |
| 198 ((asm-line-matches asm-flush-left-empty-comment-pattern) | |
| 199 (insert asm-comment-char)) | |
| 200 | |
| 201 ;; Empty code-level comment already present? | |
| 202 ;; Then start flush-left comment, on line above if this one is nonempty. | |
| 203 ((asm-line-matches asm-code-level-empty-comment-pattern) | |
| 204 (asm-pop-comment-level) | |
| 205 (insert asm-comment-char asm-comment-char comment-start)) | |
| 206 | |
| 207 ;; Empty comment ends line? | |
| 208 ;; Then make code-level comment, on line above if this one is nonempty. | |
| 209 ((asm-line-matches asm-inline-empty-comment-pattern) | |
| 210 (asm-pop-comment-level) | |
| 211 (tab-to-tab-stop) | |
| 212 (insert asm-comment-char comment-start)) | |
| 213 | |
| 214 ;; If all else fails, insert character | |
| 215 (t | |
| 216 (insert asm-comment-char)) | |
| 217 | |
| 218 ) | |
| 219 (end-of-line)) | |
| 220 | |
| 221 ;;; asm-mode.el ends here |
