diff options
| -rw-r--r-- | lisp/progmodes/scheme.el | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el index 1fbc87e748d..c621758a8b6 100644 --- a/lisp/progmodes/scheme.el +++ b/lisp/progmodes/scheme.el | |||
| @@ -54,7 +54,7 @@ | |||
| 54 | 54 | ||
| 55 | (defvar scheme-mode-syntax-table | 55 | (defvar scheme-mode-syntax-table |
| 56 | (let ((st (make-syntax-table)) | 56 | (let ((st (make-syntax-table)) |
| 57 | (i 0)) | 57 | (i 0)) |
| 58 | ;; Symbol constituents | 58 | ;; Symbol constituents |
| 59 | ;; We used to treat chars 128-256 as symbol-constituent, but they | 59 | ;; We used to treat chars 128-256 as symbol-constituent, but they |
| 60 | ;; should be valid word constituents (Bug#8843). Note that valid | 60 | ;; should be valid word constituents (Bug#8843). Note that valid |
| @@ -116,11 +116,11 @@ | |||
| 116 | 116 | ||
| 117 | (defvar scheme-imenu-generic-expression | 117 | (defvar scheme-imenu-generic-expression |
| 118 | '((nil | 118 | '((nil |
| 119 | "^(define\\(\\|-\\(generic\\(\\|-procedure\\)\\|method\\)\\)*\\s-+(?\\(\\sw+\\)" 4) | 119 | "^(define\\(\\|-\\(generic\\(\\|-procedure\\)\\|method\\)\\)*\\s-+(?\\(\\sw+\\)" 4) |
| 120 | ("Types" | 120 | ("Types" |
| 121 | "^(define-class\\s-+(?\\(\\sw+\\)" 1) | 121 | "^(define-class\\s-+(?\\(\\sw+\\)" 1) |
| 122 | ("Macros" | 122 | ("Macros" |
| 123 | "^(\\(defmacro\\|define-macro\\|define-syntax\\)\\s-+(?\\(\\sw+\\)" 2)) | 123 | "^(\\(defmacro\\|define-macro\\|define-syntax\\)\\s-+(?\\(\\sw+\\)" 2)) |
| 124 | "Imenu generic expression for Scheme mode. See `imenu-generic-expression'.") | 124 | "Imenu generic expression for Scheme mode. See `imenu-generic-expression'.") |
| 125 | 125 | ||
| 126 | (defun scheme-mode-variables () | 126 | (defun scheme-mode-variables () |
| @@ -151,11 +151,11 @@ | |||
| 151 | (setq-local imenu-syntax-alist '(("+-*/.<>=?!$%_&~^:" . "w"))) | 151 | (setq-local imenu-syntax-alist '(("+-*/.<>=?!$%_&~^:" . "w"))) |
| 152 | (setq-local syntax-propertize-function #'scheme-syntax-propertize) | 152 | (setq-local syntax-propertize-function #'scheme-syntax-propertize) |
| 153 | (setq font-lock-defaults | 153 | (setq font-lock-defaults |
| 154 | '((scheme-font-lock-keywords | 154 | '((scheme-font-lock-keywords |
| 155 | scheme-font-lock-keywords-1 scheme-font-lock-keywords-2) | 155 | scheme-font-lock-keywords-1 scheme-font-lock-keywords-2) |
| 156 | nil t (("+-*/.<>=!?$%_&~^:" . "w") (?#. "w 14")) | 156 | nil t (("+-*/.<>=!?$%_&~^:" . "w") (?#. "w 14")) |
| 157 | beginning-of-defun | 157 | beginning-of-defun |
| 158 | (font-lock-mark-block-function . mark-defun))) | 158 | (font-lock-mark-block-function . mark-defun))) |
| 159 | (setq-local prettify-symbols-alist lisp-prettify-symbols-alist) | 159 | (setq-local prettify-symbols-alist lisp-prettify-symbols-alist) |
| 160 | (setq-local lisp-doc-string-elt-property 'scheme-doc-string-elt)) | 160 | (setq-local lisp-doc-string-elt-property 'scheme-doc-string-elt)) |
| 161 | 161 | ||
| @@ -163,7 +163,7 @@ | |||
| 163 | 163 | ||
| 164 | (defvar scheme-mode-map | 164 | (defvar scheme-mode-map |
| 165 | (let ((smap (make-sparse-keymap)) | 165 | (let ((smap (make-sparse-keymap)) |
| 166 | (map (make-sparse-keymap "Scheme"))) | 166 | (map (make-sparse-keymap "Scheme"))) |
| 167 | (set-keymap-parent smap lisp-mode-shared-map) | 167 | (set-keymap-parent smap lisp-mode-shared-map) |
| 168 | (define-key smap [menu-bar scheme] (cons "Scheme" map)) | 168 | (define-key smap [menu-bar scheme] (cons "Scheme" map)) |
| 169 | (define-key map [run-scheme] '("Run Inferior Scheme" . run-scheme)) | 169 | (define-key map [run-scheme] '("Run Inferior Scheme" . run-scheme)) |
| @@ -271,25 +271,25 @@ See `run-hooks'." | |||
| 271 | ;; Declarations. Hannes Haug <hannes.haug@student.uni-tuebingen.de> says | 271 | ;; Declarations. Hannes Haug <hannes.haug@student.uni-tuebingen.de> says |
| 272 | ;; this works for SOS, STklos, SCOOPS, Meroon and Tiny CLOS. | 272 | ;; this works for SOS, STklos, SCOOPS, Meroon and Tiny CLOS. |
| 273 | (list (concat "(\\(define\\*?\\(" | 273 | (list (concat "(\\(define\\*?\\(" |
| 274 | ;; Function names. | 274 | ;; Function names. |
| 275 | "\\(\\|-public\\|-method\\|-generic\\(-procedure\\)?\\)\\|" | 275 | "\\(\\|-public\\|-method\\|-generic\\(-procedure\\)?\\)\\|" |
| 276 | ;; Macro names, as variable names. A bit dubious, this. | 276 | ;; Macro names, as variable names. A bit dubious, this. |
| 277 | "\\(-syntax\\|-macro\\)\\|" | 277 | "\\(-syntax\\|-macro\\)\\|" |
| 278 | ;; Class names. | 278 | ;; Class names. |
| 279 | "-class" | 279 | "-class" |
| 280 | ;; Guile modules. | 280 | ;; Guile modules. |
| 281 | "\\|-module" | 281 | "\\|-module" |
| 282 | "\\)\\)\\>" | 282 | "\\)\\)\\>" |
| 283 | ;; Any whitespace and declared object. | 283 | ;; Any whitespace and declared object. |
| 284 | ;; The "(*" is for curried definitions, e.g., | 284 | ;; The "(*" is for curried definitions, e.g., |
| 285 | ;; (define ((sum a) b) (+ a b)) | 285 | ;; (define ((sum a) b) (+ a b)) |
| 286 | "[ \t]*(*" | 286 | "[ \t]*(*" |
| 287 | "\\(\\sw+\\)?") | 287 | "\\(\\sw+\\)?") |
| 288 | '(1 font-lock-keyword-face) | 288 | '(1 font-lock-keyword-face) |
| 289 | '(6 (cond ((match-beginning 3) font-lock-function-name-face) | 289 | '(6 (cond ((match-beginning 3) font-lock-function-name-face) |
| 290 | ((match-beginning 5) font-lock-variable-name-face) | 290 | ((match-beginning 5) font-lock-variable-name-face) |
| 291 | (t font-lock-type-face)) | 291 | (t font-lock-type-face)) |
| 292 | nil t)) | 292 | nil t)) |
| 293 | )) | 293 | )) |
| 294 | "Subdued expressions to highlight in Scheme modes.") | 294 | "Subdued expressions to highlight in Scheme modes.") |
| 295 | 295 | ||
| @@ -301,21 +301,21 @@ See `run-hooks'." | |||
| 301 | ;; Control structures. | 301 | ;; Control structures. |
| 302 | (cons | 302 | (cons |
| 303 | (concat | 303 | (concat |
| 304 | "(" (regexp-opt | 304 | "(" (regexp-opt |
| 305 | '("begin" "call-with-current-continuation" "call/cc" | 305 | '("begin" "call-with-current-continuation" "call/cc" |
| 306 | "call-with-input-file" "call-with-output-file" "case" "cond" | 306 | "call-with-input-file" "call-with-output-file" "case" "cond" |
| 307 | "do" "else" "for-each" "if" "lambda" "λ" | 307 | "do" "else" "for-each" "if" "lambda" "λ" |
| 308 | "let" "let*" "let-syntax" "letrec" "letrec-syntax" | 308 | "let" "let*" "let-syntax" "letrec" "letrec-syntax" |
| 309 | ;; R6RS library subforms. | 309 | ;; R6RS library subforms. |
| 310 | "export" "import" | 310 | "export" "import" |
| 311 | ;; SRFI 11 usage comes up often enough. | 311 | ;; SRFI 11 usage comes up often enough. |
| 312 | "let-values" "let*-values" | 312 | "let-values" "let*-values" |
| 313 | ;; Hannes Haug <hannes.haug@student.uni-tuebingen.de> wants: | 313 | ;; Hannes Haug <hannes.haug@student.uni-tuebingen.de> wants: |
| 314 | "and" "or" "delay" "force" | 314 | "and" "or" "delay" "force" |
| 315 | ;; Stefan Monnier <stefan.monnier@epfl.ch> says don't bother: | 315 | ;; Stefan Monnier <stefan.monnier@epfl.ch> says don't bother: |
| 316 | ;;"quasiquote" "quote" "unquote" "unquote-splicing" | 316 | ;;"quasiquote" "quote" "unquote" "unquote-splicing" |
| 317 | "map" "syntax" "syntax-rules") t) | 317 | "map" "syntax" "syntax-rules") t) |
| 318 | "\\>") 1) | 318 | "\\>") 1) |
| 319 | ;; | 319 | ;; |
| 320 | ;; It wouldn't be Scheme w/o named-let. | 320 | ;; It wouldn't be Scheme w/o named-let. |
| 321 | '("(let\\s-+\\(\\sw+\\)" | 321 | '("(let\\s-+\\(\\sw+\\)" |
| @@ -328,8 +328,8 @@ See `run-hooks'." | |||
| 328 | '("\\<#?:\\sw+\\>" . font-lock-builtin-face) | 328 | '("\\<#?:\\sw+\\>" . font-lock-builtin-face) |
| 329 | ;; R6RS library declarations. | 329 | ;; R6RS library declarations. |
| 330 | '("(\\(\\<library\\>\\)\\s-*(?\\(\\sw+\\)?" | 330 | '("(\\(\\<library\\>\\)\\s-*(?\\(\\sw+\\)?" |
| 331 | (1 font-lock-keyword-face) | 331 | (1 font-lock-keyword-face) |
| 332 | (2 font-lock-type-face)) | 332 | (2 font-lock-type-face)) |
| 333 | ))) | 333 | ))) |
| 334 | "Gaudy expressions to highlight in Scheme modes.") | 334 | "Gaudy expressions to highlight in Scheme modes.") |
| 335 | 335 | ||
| @@ -394,9 +394,9 @@ that variable's value is a string." | |||
| 394 | (not buffer-read-only) | 394 | (not buffer-read-only) |
| 395 | (insert dsssl-sgml-declaration)) | 395 | (insert dsssl-sgml-declaration)) |
| 396 | (setq font-lock-defaults '(dsssl-font-lock-keywords | 396 | (setq font-lock-defaults '(dsssl-font-lock-keywords |
| 397 | nil t (("+-*/.<>=?$%_&~^:" . "w")) | 397 | nil t (("+-*/.<>=?$%_&~^:" . "w")) |
| 398 | beginning-of-defun | 398 | beginning-of-defun |
| 399 | (font-lock-mark-block-function . mark-defun))) | 399 | (font-lock-mark-block-function . mark-defun))) |
| 400 | (setq-local add-log-current-defun-function #'lisp-current-defun-name) | 400 | (setq-local add-log-current-defun-function #'lisp-current-defun-name) |
| 401 | (setq-local imenu-case-fold-search nil) | 401 | (setq-local imenu-case-fold-search nil) |
| 402 | (setq imenu-generic-expression dsssl-imenu-generic-expression) | 402 | (setq imenu-generic-expression dsssl-imenu-generic-expression) |
| @@ -416,22 +416,22 @@ that variable's value is a string." | |||
| 416 | (eval-when-compile | 416 | (eval-when-compile |
| 417 | (list | 417 | (list |
| 418 | ;; Similar to Scheme | 418 | ;; Similar to Scheme |
| 419 | (list "(\\(define\\(-\\w+\\)?\\)\\>[ ]*\\((?\\)\\(\\sw+\\)\\>" | 419 | (list "(\\(define\\(-\\w+\\)?\\)\\>[ ]*\\((?\\)\\(\\sw+\\)\\>" |
| 420 | '(1 font-lock-keyword-face) | 420 | '(1 font-lock-keyword-face) |
| 421 | '(4 font-lock-function-name-face)) | 421 | '(4 font-lock-function-name-face)) |
| 422 | (cons | 422 | (cons |
| 423 | (concat "(\\(" | 423 | (concat "(\\(" |
| 424 | ;; (make-regexp '("case" "cond" "else" "if" "lambda" | 424 | ;; (make-regexp '("case" "cond" "else" "if" "lambda" |
| 425 | ;; "let" "let*" "letrec" "and" "or" "map" "with-mode")) | 425 | ;; "let" "let*" "letrec" "and" "or" "map" "with-mode")) |
| 426 | "and\\|c\\(ase\\|ond\\)\\|else\\|if\\|" | 426 | "and\\|c\\(ase\\|ond\\)\\|else\\|if\\|" |
| 427 | "l\\(ambda\\|et\\(\\|*\\|rec\\)\\)\\|map\\|or\\|with-mode" | 427 | "l\\(ambda\\|et\\(\\|*\\|rec\\)\\)\\|map\\|or\\|with-mode" |
| 428 | "\\)\\>") | 428 | "\\)\\>") |
| 429 | 1) | 429 | 1) |
| 430 | ;; DSSSL syntax | 430 | ;; DSSSL syntax |
| 431 | '("(\\(element\\|mode\\|declare-\\w+\\)\\>[ ]*\\(\\sw+\\)" | 431 | '("(\\(element\\|mode\\|declare-\\w+\\)\\>[ ]*\\(\\sw+\\)" |
| 432 | (1 font-lock-keyword-face) | 432 | (1 font-lock-keyword-face) |
| 433 | (2 font-lock-type-face)) | 433 | (2 font-lock-type-face)) |
| 434 | '("(\\(element\\)\\>[ ]*(\\(\\S)+\\))" | 434 | '("(\\(element\\)\\>[ ]*(\\(\\S)+\\))" |
| 435 | (1 font-lock-keyword-face) | 435 | (1 font-lock-keyword-face) |
| 436 | (2 font-lock-type-face)) | 436 | (2 font-lock-type-face)) |
| 437 | '("\\<\\sw+:\\>" . font-lock-constant-face) ; trailing `:' c.f. scheme | 437 | '("\\<\\sw+:\\>" . font-lock-constant-face) ; trailing `:' c.f. scheme |
| @@ -468,7 +468,7 @@ indentation." | |||
| 468 | (progn (goto-char calculate-lisp-indent-last-sexp) | 468 | (progn (goto-char calculate-lisp-indent-last-sexp) |
| 469 | (beginning-of-line) | 469 | (beginning-of-line) |
| 470 | (parse-partial-sexp (point) | 470 | (parse-partial-sexp (point) |
| 471 | calculate-lisp-indent-last-sexp 0 t))) | 471 | calculate-lisp-indent-last-sexp 0 t))) |
| 472 | ;; Indent under the list or under the first sexp on the same | 472 | ;; Indent under the list or under the first sexp on the same |
| 473 | ;; line as calculate-lisp-indent-last-sexp. Note that first | 473 | ;; line as calculate-lisp-indent-last-sexp. Note that first |
| 474 | ;; thing on that line has to be complete sexp since we are | 474 | ;; thing on that line has to be complete sexp since we are |
| @@ -476,20 +476,20 @@ indentation." | |||
| 476 | (backward-prefix-chars) | 476 | (backward-prefix-chars) |
| 477 | (current-column)) | 477 | (current-column)) |
| 478 | (let ((function (buffer-substring (point) | 478 | (let ((function (buffer-substring (point) |
| 479 | (progn (forward-sexp 1) (point)))) | 479 | (progn (forward-sexp 1) (point)))) |
| 480 | method) | 480 | method) |
| 481 | (setq method (or (get (intern-soft function) 'scheme-indent-function) | 481 | (setq method (or (get (intern-soft function) 'scheme-indent-function) |
| 482 | (get (intern-soft function) 'scheme-indent-hook))) | 482 | (get (intern-soft function) 'scheme-indent-hook))) |
| 483 | (cond ((or (eq method 'defun) | 483 | (cond ((or (eq method 'defun) |
| 484 | (and (null method) | 484 | (and (null method) |
| 485 | (> (length function) 3) | 485 | (> (length function) 3) |
| 486 | (string-match "\\`def" function))) | 486 | (string-match "\\`def" function))) |
| 487 | (lisp-indent-defform state indent-point)) | 487 | (lisp-indent-defform state indent-point)) |
| 488 | ((integerp method) | 488 | ((integerp method) |
| 489 | (lisp-indent-specform method state | 489 | (lisp-indent-specform method state |
| 490 | indent-point normal-indent)) | 490 | indent-point normal-indent)) |
| 491 | (method | 491 | (method |
| 492 | (funcall method state indent-point normal-indent))))))) | 492 | (funcall method state indent-point normal-indent))))))) |
| 493 | 493 | ||
| 494 | 494 | ||
| 495 | ;;; Let is different in Scheme | 495 | ;;; Let is different in Scheme |