diff options
| author | Stefan Monnier | 2010-09-03 13:26:08 +0200 |
|---|---|---|
| committer | Stefan Monnier | 2010-09-03 13:26:08 +0200 |
| commit | 0da208548b7029e608567112c0f4613613aae688 (patch) | |
| tree | 13a4c17fc2ce9a6b4edca885eda9fb20b1ccb980 | |
| parent | a49e651ea930f912d48259b2eccfe8735b0b885a (diff) | |
| download | emacs-0da208548b7029e608567112c0f4613613aae688.tar.gz emacs-0da208548b7029e608567112c0f4613613aae688.zip | |
* lisp/calc/calc-aent.el (calcAlg-blink-matching-check): New fun, to replace
calcAlg-blink-matching-open.
(calc-alg-ent-map, calc-alg-ent-esc-map): Initialize in the declaration.
(calc-do-alg-entry): Only touch the part of the keymap that varies.
Use the new blink-matching-check-function.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/calc/calc-aent.el | 63 |
2 files changed, 29 insertions, 40 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 09424462f21..1c83ea2ad61 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2010-09-03 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2010-09-03 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * calc/calc-aent.el (calcAlg-blink-matching-check): New fun, to replace | ||
| 4 | calcAlg-blink-matching-open. | ||
| 5 | (calc-alg-ent-map, calc-alg-ent-esc-map): Initialize in the declaration. | ||
| 6 | (calc-do-alg-entry): Only touch the part of the keymap that varies. | ||
| 7 | Use the new blink-matching-check-function. | ||
| 8 | |||
| 3 | Provide blink-matching support to SMIE. | 9 | Provide blink-matching support to SMIE. |
| 4 | * emacs-lisp/smie.el (smie-bnf-closer-alist): New function. | 10 | * emacs-lisp/smie.el (smie-bnf-closer-alist): New function. |
| 5 | (smie-blink-matching-triggers, smie-blink-matching-inners): New vars. | 11 | (smie-blink-matching-triggers, smie-blink-matching-inners): New vars. |
diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el index 30f15f04905..472133be84f 100644 --- a/lisp/calc/calc-aent.el +++ b/lisp/calc/calc-aent.el | |||
| @@ -315,10 +315,24 @@ The value t means abort and give an error message.") | |||
| 315 | calc-dollar-used 0))) | 315 | calc-dollar-used 0))) |
| 316 | (calc-handle-whys)))) | 316 | (calc-handle-whys)))) |
| 317 | 317 | ||
| 318 | (defvar calc-alg-ent-map nil | 318 | (defvar calc-alg-ent-map |
| 319 | (let ((map (make-sparse-keymap))) | ||
| 320 | (set-keymap-parent map minibuffer-local-map) | ||
| 321 | (define-key map "'" 'calcAlg-previous) | ||
| 322 | (define-key map "`" 'calcAlg-edit) | ||
| 323 | (define-key map "\C-m" 'calcAlg-enter) | ||
| 324 | (define-key map "\C-j" 'calcAlg-enter) | ||
| 325 | map) | ||
| 319 | "The keymap used for algebraic entry.") | 326 | "The keymap used for algebraic entry.") |
| 320 | 327 | ||
| 321 | (defvar calc-alg-ent-esc-map nil | 328 | (defvar calc-alg-ent-esc-map |
| 329 | (let ((map (make-keymap)) | ||
| 330 | (i 33)) | ||
| 331 | (set-keymap-parent map esc-map) | ||
| 332 | (while (< i 127) | ||
| 333 | (define-key map (vector i) 'calcAlg-escape) | ||
| 334 | (setq i (1+ i))) | ||
| 335 | map) | ||
| 322 | "The keymap used for escapes in algebraic entry.") | 336 | "The keymap used for escapes in algebraic entry.") |
| 323 | 337 | ||
| 324 | (defvar calc-alg-exp) | 338 | (defvar calc-alg-exp) |
| @@ -326,19 +340,8 @@ The value t means abort and give an error message.") | |||
| 326 | ;;;###autoload | 340 | ;;;###autoload |
| 327 | (defun calc-do-alg-entry (&optional initial prompt no-normalize history) | 341 | (defun calc-do-alg-entry (&optional initial prompt no-normalize history) |
| 328 | (let* ((calc-buffer (current-buffer)) | 342 | (let* ((calc-buffer (current-buffer)) |
| 329 | (blink-paren-function 'calcAlg-blink-matching-open) | 343 | (blink-matching-check-function 'calcAlg-blink-matching-check) |
| 330 | (calc-alg-exp 'error)) | 344 | (calc-alg-exp 'error)) |
| 331 | (unless calc-alg-ent-map | ||
| 332 | (setq calc-alg-ent-map (copy-keymap minibuffer-local-map)) | ||
| 333 | (define-key calc-alg-ent-map "'" 'calcAlg-previous) | ||
| 334 | (define-key calc-alg-ent-map "`" 'calcAlg-edit) | ||
| 335 | (define-key calc-alg-ent-map "\C-m" 'calcAlg-enter) | ||
| 336 | (define-key calc-alg-ent-map "\C-j" 'calcAlg-enter) | ||
| 337 | (let ((i 33)) | ||
| 338 | (setq calc-alg-ent-esc-map (copy-keymap esc-map)) | ||
| 339 | (while (< i 127) | ||
| 340 | (aset (nth 1 calc-alg-ent-esc-map) i 'calcAlg-escape) | ||
| 341 | (setq i (1+ i))))) | ||
| 342 | (define-key calc-alg-ent-map "\e" nil) | 345 | (define-key calc-alg-ent-map "\e" nil) |
| 343 | (if (eq calc-algebraic-mode 'total) | 346 | (if (eq calc-algebraic-mode 'total) |
| 344 | (define-key calc-alg-ent-map "\e" calc-alg-ent-esc-map) | 347 | (define-key calc-alg-ent-map "\e" calc-alg-ent-esc-map) |
| @@ -430,18 +433,9 @@ The value t means abort and give an error message.") | |||
| 430 | exp)) | 433 | exp)) |
| 431 | (exit-minibuffer)))) | 434 | (exit-minibuffer)))) |
| 432 | 435 | ||
| 433 | (defun calcAlg-blink-matching-open () | 436 | (defun calcAlg-blink-matching-check (leftpt rightpt) |
| 434 | (let ((rightpt (point)) | 437 | (let ((rightchar (char-before rightpt)) |
| 435 | (leftpt nil) | 438 | (leftchar (if leftpt (char-after leftpt)))) |
| 436 | (rightchar (preceding-char)) | ||
| 437 | leftchar | ||
| 438 | rightsyntax | ||
| 439 | leftsyntax) | ||
| 440 | (save-excursion | ||
| 441 | (condition-case () | ||
| 442 | (setq leftpt (scan-sexps rightpt -1) | ||
| 443 | leftchar (char-after leftpt)) | ||
| 444 | (error nil))) | ||
| 445 | (if (and leftpt | 439 | (if (and leftpt |
| 446 | (or (and (= rightchar ?\)) | 440 | (or (and (= rightchar ?\)) |
| 447 | (= leftchar ?\[)) | 441 | (= leftchar ?\[)) |
| @@ -450,20 +444,9 @@ The value t means abort and give an error message.") | |||
| 450 | (save-excursion | 444 | (save-excursion |
| 451 | (goto-char leftpt) | 445 | (goto-char leftpt) |
| 452 | (looking-at ".+\\(\\.\\.\\|\\\\dots\\|\\\\ldots\\)"))) | 446 | (looking-at ".+\\(\\.\\.\\|\\\\dots\\|\\\\ldots\\)"))) |
| 453 | (let ((leftsaved (aref (syntax-table) leftchar)) | 447 | ;; [2..5) perfectly valid! |
| 454 | (rightsaved (aref (syntax-table) rightchar))) | 448 | nil |
| 455 | (unwind-protect | 449 | (blink-matching-check-mismatch leftpt rightpt)))) |
| 456 | (progn | ||
| 457 | (cond ((= leftchar ?\[) | ||
| 458 | (aset (syntax-table) leftchar (cons 4 ?\))) | ||
| 459 | (aset (syntax-table) rightchar (cons 5 ?\[))) | ||
| 460 | (t | ||
| 461 | (aset (syntax-table) leftchar (cons 4 ?\])) | ||
| 462 | (aset (syntax-table) rightchar (cons 5 ?\()))) | ||
| 463 | (blink-matching-open)) | ||
| 464 | (aset (syntax-table) leftchar leftsaved) | ||
| 465 | (aset (syntax-table) rightchar rightsaved))) | ||
| 466 | (blink-matching-open)))) | ||
| 467 | 450 | ||
| 468 | ;;;###autoload | 451 | ;;;###autoload |
| 469 | (defun calc-alg-digit-entry () | 452 | (defun calc-alg-digit-entry () |