diff options
| author | Stefan Monnier | 2003-05-26 21:56:41 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2003-05-26 21:56:41 +0000 |
| commit | 326bc73d3e9476a73d8023bf898820481d5d844f (patch) | |
| tree | 2ffbfd0ab5849432448293b77d284dfe75eddff8 | |
| parent | 97bc76d4423bfc485dbe3cc4e48aabae35a34cc8 (diff) | |
| download | emacs-326bc73d3e9476a73d8023bf898820481d5d844f.tar.gz emacs-326bc73d3e9476a73d8023bf898820481d5d844f.zip | |
(gud-find-class): Remove unused var `pos'.
(gdb-script-mode-syntax-table, gdb-script-font-lock-keywords)
(gdb-script-font-lock-syntactic-keywords)
(gdb-script-font-lock-syntactic-face, gdb-script-basic-indent)
(gdb-script-skip-to-head, gdb-script-calculate-indentation)
(gdb-script-indent-line, gdb-script-mode): New mode to edit
.gdbinit-like scripts.
| -rw-r--r-- | lisp/gud.el | 97 |
1 files changed, 94 insertions, 3 deletions
diff --git a/lisp/gud.el b/lisp/gud.el index 00117829bbc..7cd11a40477 100644 --- a/lisp/gud.el +++ b/lisp/gud.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | ;; Maintainer: FSF | 4 | ;; Maintainer: FSF |
| 5 | ;; Keywords: unix, tools | 5 | ;; Keywords: unix, tools |
| 6 | 6 | ||
| 7 | ;; Copyright (C) 1992,93,94,95,96,1998,2000,2002 Free Software Foundation, Inc. | 7 | ;; Copyright (C) 1992,93,94,95,96,1998,2000,02,2003 Free Software Foundation, Inc. |
| 8 | 8 | ||
| 9 | ;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| 10 | 10 | ||
| @@ -2831,8 +2831,7 @@ class of the file (using s to separate nested class ids)." | |||
| 2831 | (if (and fbuffer (equal (symbol-file 'java-mode) "cc-mode")) | 2831 | (if (and fbuffer (equal (symbol-file 'java-mode) "cc-mode")) |
| 2832 | (save-excursion | 2832 | (save-excursion |
| 2833 | (set-buffer fbuffer) | 2833 | (set-buffer fbuffer) |
| 2834 | (let ((nclass) (syntax) | 2834 | (let ((nclass) (syntax)) |
| 2835 | (pos (point))) | ||
| 2836 | ;; While the c-syntactic information does not start | 2835 | ;; While the c-syntactic information does not start |
| 2837 | ;; with the 'topmost-intro symbol, there may be | 2836 | ;; with the 'topmost-intro symbol, there may be |
| 2838 | ;; nested classes... | 2837 | ;; nested classes... |
| @@ -2874,6 +2873,98 @@ class of the file (using s to separate nested class ids)." | |||
| 2874 | (message "gud-find-class: class for file %s not found in gud-jdb-class-source-alist!" f) | 2873 | (message "gud-find-class: class for file %s not found in gud-jdb-class-source-alist!" f) |
| 2875 | nil)))) | 2874 | nil)))) |
| 2876 | 2875 | ||
| 2876 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 2877 | ;;; GDB script mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 2878 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 2879 | |||
| 2880 | (defvar gdb-script-mode-syntax-table | ||
| 2881 | (let ((st (make-syntax-table))) | ||
| 2882 | (modify-syntax-entry ?' "\"" st) | ||
| 2883 | (modify-syntax-entry ?# "<" st) | ||
| 2884 | (modify-syntax-entry ?\n ">" st) | ||
| 2885 | st)) | ||
| 2886 | |||
| 2887 | (defvar gdb-script-font-lock-keywords | ||
| 2888 | '(("^define\\s-+\\(\\w+\\)" (1 font-lock-function-name-face)) | ||
| 2889 | ("^\\s-*\\([a-z]+\\)" (1 font-lock-keyword-face)))) | ||
| 2890 | |||
| 2891 | (defvar gdb-script-font-lock-syntactic-keywords | ||
| 2892 | '(("^document\\s-.*\\(\n\\)" (1 "< b")) | ||
| 2893 | ;; It would be best to change the \n in front, but it's more difficult. | ||
| 2894 | ("^en\\(d\\)\\>" (1 "> b")))) | ||
| 2895 | |||
| 2896 | (defun gdb-script-font-lock-syntactic-face (state) | ||
| 2897 | (cond | ||
| 2898 | ((nth 3 state) font-lock-string-face) | ||
| 2899 | ((nth 7 state) font-lock-doc-face) | ||
| 2900 | (t font-lock-comment-face))) | ||
| 2901 | |||
| 2902 | (defvar gdb-script-basic-indent 2) | ||
| 2903 | |||
| 2904 | (defun gdb-script-skip-to-head () | ||
| 2905 | "We're just in front of an `end' and we need to go to its head." | ||
| 2906 | (while (and (re-search-backward "^\\s-*\\(\\(end\\)\\|define\\|document\\|if\\|while\\)\\>" nil 'move) | ||
| 2907 | (match-end 2)) | ||
| 2908 | (gdb-script-skip-to-head))) | ||
| 2909 | |||
| 2910 | (defun gdb-script-calculate-indentation () | ||
| 2911 | (cond | ||
| 2912 | ((looking-at "end\\>") | ||
| 2913 | (gdb-script-skip-to-head) | ||
| 2914 | (current-indentation)) | ||
| 2915 | ((looking-at "else\\>") | ||
| 2916 | (while (and (re-search-backward "^\\s-*\\(if\\|\\(end\\)\\)\\>" nil 'move) | ||
| 2917 | (match-end 2)) | ||
| 2918 | (gdb-script-skip-to-head)) | ||
| 2919 | (current-indentation)) | ||
| 2920 | (t | ||
| 2921 | (forward-comment (- (point-max))) | ||
| 2922 | (forward-line 0) | ||
| 2923 | (skip-chars-forward " \t") | ||
| 2924 | (+ (current-indentation) | ||
| 2925 | (if (looking-at "\\(if\\|while\\|define\\|else\\)\\>") | ||
| 2926 | gdb-script-basic-indent 0))))) | ||
| 2927 | |||
| 2928 | (defun gdb-script-indent-line () | ||
| 2929 | "Indent current line of GDB script." | ||
| 2930 | (interactive) | ||
| 2931 | (if (and (eq (get-text-property (point) 'face) font-lock-doc-face) | ||
| 2932 | (save-excursion | ||
| 2933 | (forward-line 0) | ||
| 2934 | (skip-chars-forward " \t") | ||
| 2935 | (not (looking-at "end\\>")))) | ||
| 2936 | 'noindent | ||
| 2937 | (let* ((savep (point)) | ||
| 2938 | (indent (condition-case nil | ||
| 2939 | (save-excursion | ||
| 2940 | (forward-line 0) | ||
| 2941 | (skip-chars-forward " \t") | ||
| 2942 | (if (>= (point) savep) (setq savep nil)) | ||
| 2943 | (max (gdb-script-calculate-indentation) 0)) | ||
| 2944 | (error 0)))) | ||
| 2945 | (if savep | ||
| 2946 | (save-excursion (indent-line-to indent)) | ||
| 2947 | (indent-line-to indent))))) | ||
| 2948 | |||
| 2949 | ;;;###autoload | ||
| 2950 | (add-to-list 'auto-mode-alist '("/\\.gdbinit" . gdb-script-mode)) | ||
| 2951 | |||
| 2952 | ;;;###autoload | ||
| 2953 | (define-derived-mode gdb-script-mode nil "GDB-Script" | ||
| 2954 | "Major mode for editing GDB scripts" | ||
| 2955 | (set (make-local-variable 'comment-start) "#") | ||
| 2956 | (set (make-local-variable 'comment-start-skip) "#+\\s-*") | ||
| 2957 | (set (make-local-variable 'outline-regexp) "[ \t]") | ||
| 2958 | (set (make-local-variable 'imenu-generic-expression) | ||
| 2959 | '((nil "^define[ \t]+\\(\\w+\\)" 1))) | ||
| 2960 | (set (make-local-variable 'indent-line-function) 'gdb-script-indent-line) | ||
| 2961 | (set (make-local-variable 'font-lock-defaults) | ||
| 2962 | '(gdb-script-font-lock-keywords nil nil ((?_ . "w")) nil | ||
| 2963 | (font-lock-syntactic-keywords | ||
| 2964 | . gdb-script-font-lock-syntactic-keywords) | ||
| 2965 | (font-lock-syntactic-face-function | ||
| 2966 | . gdb-script-font-lock-syntactic-face)))) | ||
| 2967 | |||
| 2877 | (provide 'gud) | 2968 | (provide 'gud) |
| 2878 | 2969 | ||
| 2879 | ;;; gud.el ends here | 2970 | ;;; gud.el ends here |