diff options
| author | Stefan Monnier | 2010-09-08 18:21:23 +0200 |
|---|---|---|
| committer | Stefan Monnier | 2010-09-08 18:21:23 +0200 |
| commit | b073dc4b4b21ee5885c6c8d182d915115e51419b (patch) | |
| tree | 125fc129e13ab56a466735610047a137f1ac2555 | |
| parent | c34a966941056e0f55f59cb453d31ef0870c3a58 (diff) | |
| download | emacs-b073dc4b4b21ee5885c6c8d182d915115e51419b.tar.gz emacs-b073dc4b4b21ee5885c6c8d182d915115e51419b.zip | |
Misc cleanups and simplifications.
* lisp/font-lock.el (save-buffer-state): Remove `varlist' arg.
(font-lock-unfontify-region, font-lock-default-fontify-region):
Update usage correspondingly.
(font-lock-fontify-syntactic-keywords-region):
Set parse-sexp-lookup-properties buffer-locally here.
(font-lock-fontify-syntactically-region): Remove unused `ppss' arg.
* lisp/progmodes/ada-mode.el: Replace "(set '" with setq.
(ada-mode): Simplify.
(ada-create-case-exception, ada-adjust-case-interactive)
(ada-adjust-case-region, ada-format-paramlist, ada-indent-current)
(ada-search-ignore-string-comment, ada-move-to-start)
(ada-move-to-end): Use with-syntax-table.
* lisp/progmodes/fortran.el (fortran-line-length): Don't recompute
syntactic keywords redundantly a second time.
* lisp/progmodes/js.el (require): Require is already "eval-and-compile".
(js--re-search-forward): Avoid `eval'. Preserve the error data.
(js--re-search-backward): Use js--re-search-forward.
* lisp/progmodes/octave-mod.el (electric-indent-chars): Silence bytecomp.
| -rw-r--r-- | lisp/ChangeLog | 23 | ||||
| -rw-r--r-- | lisp/font-lock.el | 25 | ||||
| -rw-r--r-- | lisp/progmodes/ada-mode.el | 607 | ||||
| -rw-r--r-- | lisp/progmodes/fortran.el | 3 | ||||
| -rw-r--r-- | lisp/progmodes/js.el | 52 | ||||
| -rw-r--r-- | lisp/progmodes/octave-mod.el | 2 |
6 files changed, 339 insertions, 373 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e445641a33c..4cfab866c82 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,28 @@ | |||
| 1 | 2010-09-08 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2010-09-08 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * progmodes/octave-mod.el (electric-indent-chars): Silence bytecomp. | ||
| 4 | |||
| 5 | * progmodes/js.el (require): Require is already "eval-and-compile". | ||
| 6 | (js--re-search-forward): Avoid `eval'. Preserve the error data. | ||
| 7 | (js--re-search-backward): Use js--re-search-forward. | ||
| 8 | |||
| 9 | * progmodes/fortran.el (fortran-line-length): Don't recompute | ||
| 10 | syntactic keywords redundantly a second time. | ||
| 11 | |||
| 12 | * progmodes/ada-mode.el: Replace "(set '" with setq. | ||
| 13 | (ada-mode): Simplify. | ||
| 14 | (ada-create-case-exception, ada-adjust-case-interactive) | ||
| 15 | (ada-adjust-case-region, ada-format-paramlist, ada-indent-current) | ||
| 16 | (ada-search-ignore-string-comment, ada-move-to-start) | ||
| 17 | (ada-move-to-end): Use with-syntax-table. | ||
| 18 | |||
| 19 | * font-lock.el (save-buffer-state): Remove `varlist' arg. | ||
| 20 | (font-lock-unfontify-region, font-lock-default-fontify-region): | ||
| 21 | Update usage correspondingly. | ||
| 22 | (font-lock-fontify-syntactic-keywords-region): | ||
| 23 | Set parse-sexp-lookup-properties buffer-locally here. | ||
| 24 | (font-lock-fontify-syntactically-region): Remove unused `ppss' arg. | ||
| 25 | |||
| 3 | * simple.el (blink-matching-open): Don't burp if we can't find a match. | 26 | * simple.el (blink-matching-open): Don't burp if we can't find a match. |
| 4 | 27 | ||
| 5 | 2010-09-08 Glenn Morris <rgm@gnu.org> | 28 | 2010-09-08 Glenn Morris <rgm@gnu.org> |
diff --git a/lisp/font-lock.el b/lisp/font-lock.el index bfea0dabfe2..7b2f0effa2c 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el | |||
| @@ -612,11 +612,10 @@ Major/minor modes can set this variable if they know which option applies.") | |||
| 612 | ;; | 612 | ;; |
| 613 | ;; Borrowed from lazy-lock.el. | 613 | ;; Borrowed from lazy-lock.el. |
| 614 | ;; We use this to preserve or protect things when modifying text properties. | 614 | ;; We use this to preserve or protect things when modifying text properties. |
| 615 | (defmacro save-buffer-state (varlist &rest body) | 615 | (defmacro save-buffer-state (&rest body) |
| 616 | "Bind variables according to VARLIST and eval BODY restoring buffer state." | 616 | "Bind variables according to VARLIST and eval BODY restoring buffer state." |
| 617 | (declare (indent 1) (debug let)) | 617 | (declare (indent 0) (debug t)) |
| 618 | `(let* ,(append varlist | 618 | `(let ((inhibit-point-motion-hooks t)) |
| 619 | `((inhibit-point-motion-hooks t))) | ||
| 620 | (with-silent-modifications | 619 | (with-silent-modifications |
| 621 | ,@body))) | 620 | ,@body))) |
| 622 | ;; | 621 | ;; |
| @@ -1020,7 +1019,7 @@ The region it returns may start or end in the middle of a line.") | |||
| 1020 | (funcall font-lock-fontify-region-function beg end loudly)) | 1019 | (funcall font-lock-fontify-region-function beg end loudly)) |
| 1021 | 1020 | ||
| 1022 | (defun font-lock-unfontify-region (beg end) | 1021 | (defun font-lock-unfontify-region (beg end) |
| 1023 | (save-buffer-state nil | 1022 | (save-buffer-state |
| 1024 | (funcall font-lock-unfontify-region-function beg end))) | 1023 | (funcall font-lock-unfontify-region-function beg end))) |
| 1025 | 1024 | ||
| 1026 | (defun font-lock-default-fontify-buffer () | 1025 | (defun font-lock-default-fontify-buffer () |
| @@ -1113,8 +1112,6 @@ Put first the functions more likely to cause a change and cheaper to compute.") | |||
| 1113 | 1112 | ||
| 1114 | (defun font-lock-default-fontify-region (beg end loudly) | 1113 | (defun font-lock-default-fontify-region (beg end loudly) |
| 1115 | (save-buffer-state | 1114 | (save-buffer-state |
| 1116 | ((parse-sexp-lookup-properties | ||
| 1117 | (or parse-sexp-lookup-properties font-lock-syntactic-keywords))) | ||
| 1118 | ;; Use the fontification syntax table, if any. | 1115 | ;; Use the fontification syntax table, if any. |
| 1119 | (with-syntax-table (or font-lock-syntax-table (syntax-table)) | 1116 | (with-syntax-table (or font-lock-syntax-table (syntax-table)) |
| 1120 | (save-restriction | 1117 | (save-restriction |
| @@ -1436,6 +1433,10 @@ LIMIT can be modified by the value of its PRE-MATCH-FORM." | |||
| 1436 | (defun font-lock-fontify-syntactic-keywords-region (start end) | 1433 | (defun font-lock-fontify-syntactic-keywords-region (start end) |
| 1437 | "Fontify according to `font-lock-syntactic-keywords' between START and END. | 1434 | "Fontify according to `font-lock-syntactic-keywords' between START and END. |
| 1438 | START should be at the beginning of a line." | 1435 | START should be at the beginning of a line." |
| 1436 | (unless parse-sexp-lookup-properties | ||
| 1437 | ;; We wouldn't go through so much trouble if we didn't intend to use those | ||
| 1438 | ;; properties, would we? | ||
| 1439 | (set (make-local-variable 'parse-sexp-lookup-properties) t)) | ||
| 1439 | ;; Ensure the beginning of the file is properly syntactic-fontified. | 1440 | ;; Ensure the beginning of the file is properly syntactic-fontified. |
| 1440 | (when (and font-lock-syntactically-fontified | 1441 | (when (and font-lock-syntactically-fontified |
| 1441 | (< font-lock-syntactically-fontified start)) | 1442 | (< font-lock-syntactically-fontified start)) |
| @@ -1483,19 +1484,17 @@ START should be at the beginning of a line." | |||
| 1483 | (defvar font-lock-comment-end-skip nil | 1484 | (defvar font-lock-comment-end-skip nil |
| 1484 | "If non-nil, Font Lock mode uses this instead of `comment-end'.") | 1485 | "If non-nil, Font Lock mode uses this instead of `comment-end'.") |
| 1485 | 1486 | ||
| 1486 | (defun font-lock-fontify-syntactically-region (start end &optional loudly ppss) | 1487 | (defun font-lock-fontify-syntactically-region (start end &optional loudly) |
| 1487 | "Put proper face on each string and comment between START and END. | 1488 | "Put proper face on each string and comment between START and END. |
| 1488 | START should be at the beginning of a line." | 1489 | START should be at the beginning of a line." |
| 1489 | (let ((comment-end-regexp | 1490 | (let ((comment-end-regexp |
| 1490 | (or font-lock-comment-end-skip | 1491 | (or font-lock-comment-end-skip |
| 1491 | (regexp-quote | 1492 | (regexp-quote |
| 1492 | (replace-regexp-in-string "^ *" "" comment-end)))) | 1493 | (replace-regexp-in-string "^ *" "" comment-end)))) |
| 1493 | state face beg) | 1494 | ;; Find the `start' state. |
| 1495 | (state (syntax-ppss start)) | ||
| 1496 | face beg) | ||
| 1494 | (if loudly (message "Fontifying %s... (syntactically...)" (buffer-name))) | 1497 | (if loudly (message "Fontifying %s... (syntactically...)" (buffer-name))) |
| 1495 | (goto-char start) | ||
| 1496 | ;; | ||
| 1497 | ;; Find the `start' state. | ||
| 1498 | (setq state (or ppss (syntax-ppss start))) | ||
| 1499 | ;; | 1498 | ;; |
| 1500 | ;; Find each interesting place between here and `end'. | 1499 | ;; Find each interesting place between here and `end'. |
| 1501 | (while | 1500 | (while |
diff --git a/lisp/progmodes/ada-mode.el b/lisp/progmodes/ada-mode.el index 227f202fef0..d402dd7b84a 100644 --- a/lisp/progmodes/ada-mode.el +++ b/lisp/progmodes/ada-mode.el | |||
| @@ -1118,7 +1118,8 @@ the file name." | |||
| 1118 | 1118 | ||
| 1119 | ;;;###autoload | 1119 | ;;;###autoload |
| 1120 | (defun ada-mode () | 1120 | (defun ada-mode () |
| 1121 | "Ada mode is the major mode for editing Ada code." | 1121 | "Ada mode is the major mode for editing Ada code. |
| 1122 | \\{ada-mode-map}" | ||
| 1122 | 1123 | ||
| 1123 | (interactive) | 1124 | (interactive) |
| 1124 | (kill-all-local-variables) | 1125 | (kill-all-local-variables) |
| @@ -1161,9 +1162,9 @@ the file name." | |||
| 1161 | (set (make-local-variable 'comment-padding) 0) | 1162 | (set (make-local-variable 'comment-padding) 0) |
| 1162 | (set (make-local-variable 'parse-sexp-lookup-properties) t)) | 1163 | (set (make-local-variable 'parse-sexp-lookup-properties) t)) |
| 1163 | 1164 | ||
| 1164 | (set 'case-fold-search t) | 1165 | (setq case-fold-search t) |
| 1165 | (if (boundp 'imenu-case-fold-search) | 1166 | (if (boundp 'imenu-case-fold-search) |
| 1166 | (set 'imenu-case-fold-search t)) | 1167 | (setq imenu-case-fold-search t)) |
| 1167 | 1168 | ||
| 1168 | (set (make-local-variable 'fill-paragraph-function) | 1169 | (set (make-local-variable 'fill-paragraph-function) |
| 1169 | 'ada-fill-comment-paragraph) | 1170 | 'ada-fill-comment-paragraph) |
| @@ -1322,10 +1323,10 @@ the file name." | |||
| 1322 | 1323 | ||
| 1323 | ;; To be run after the hook, in case the user modified | 1324 | ;; To be run after the hook, in case the user modified |
| 1324 | ;; ada-fill-comment-prefix | 1325 | ;; ada-fill-comment-prefix |
| 1325 | (make-local-variable 'comment-start) | 1326 | ;; FIXME: if the user modified ada-fill-comment-prefix in his .emacs |
| 1326 | (if ada-fill-comment-prefix | 1327 | ;; then it was already available before running the hook, and if he |
| 1327 | (set 'comment-start ada-fill-comment-prefix) | 1328 | ;; modifies it in the hook, he might as well modify comment-start instead. |
| 1328 | (set 'comment-start "-- ")) | 1329 | (set (make-local-variable 'comment-start) (or ada-fill-comment-prefix "-- ")) |
| 1329 | 1330 | ||
| 1330 | ;; Run this after the hook to give the users a chance to activate | 1331 | ;; Run this after the hook to give the users a chance to activate |
| 1331 | ;; font-lock-mode | 1332 | ;; font-lock-mode |
| @@ -1337,7 +1338,8 @@ the file name." | |||
| 1337 | ;; the following has to be done after running the ada-mode-hook | 1338 | ;; the following has to be done after running the ada-mode-hook |
| 1338 | ;; because users might want to set the values of these variable | 1339 | ;; because users might want to set the values of these variable |
| 1339 | ;; inside the hook | 1340 | ;; inside the hook |
| 1340 | 1341 | ;; FIXME: it might even be set later on via file-local vars, no? | |
| 1342 | ;; so maybe ada-keywords should be set lazily. | ||
| 1341 | (cond ((eq ada-language-version 'ada83) | 1343 | (cond ((eq ada-language-version 'ada83) |
| 1342 | (setq ada-keywords ada-83-keywords)) | 1344 | (setq ada-keywords ada-83-keywords)) |
| 1343 | ((eq ada-language-version 'ada95) | 1345 | ((eq ada-language-version 'ada95) |
| @@ -1397,25 +1399,21 @@ If WORD is not given, then the current word in the buffer is used instead. | |||
| 1397 | The new word is added to the first file in `ada-case-exception-file'. | 1399 | The new word is added to the first file in `ada-case-exception-file'. |
| 1398 | The standard casing rules will no longer apply to this word." | 1400 | The standard casing rules will no longer apply to this word." |
| 1399 | (interactive) | 1401 | (interactive) |
| 1400 | (let ((previous-syntax-table (syntax-table)) | 1402 | (let ((file-name |
| 1401 | file-name | 1403 | (cond ((stringp ada-case-exception-file) |
| 1402 | ) | 1404 | ada-case-exception-file) |
| 1403 | 1405 | ((listp ada-case-exception-file) | |
| 1404 | (cond ((stringp ada-case-exception-file) | 1406 | (car ada-case-exception-file)) |
| 1405 | (setq file-name ada-case-exception-file)) | 1407 | (t |
| 1406 | ((listp ada-case-exception-file) | 1408 | (error (concat "No exception file specified. " |
| 1407 | (setq file-name (car ada-case-exception-file))) | 1409 | "See variable ada-case-exception-file")))))) |
| 1408 | (t | ||
| 1409 | (error (concat "No exception file specified. " | ||
| 1410 | "See variable ada-case-exception-file")))) | ||
| 1411 | 1410 | ||
| 1412 | (set-syntax-table ada-mode-symbol-syntax-table) | ||
| 1413 | (unless word | 1411 | (unless word |
| 1414 | (save-excursion | 1412 | (with-syntax-table ada-mode-symbol-syntax-table |
| 1415 | (skip-syntax-backward "w") | 1413 | (save-excursion |
| 1416 | (setq word (buffer-substring-no-properties | 1414 | (skip-syntax-backward "w") |
| 1417 | (point) (save-excursion (forward-word 1) (point)))))) | 1415 | (setq word (buffer-substring-no-properties |
| 1418 | (set-syntax-table previous-syntax-table) | 1416 | (point) (save-excursion (forward-word 1) (point))))))) |
| 1419 | 1417 | ||
| 1420 | ;; Reread the exceptions file, in case it was modified by some other, | 1418 | ;; Reread the exceptions file, in case it was modified by some other, |
| 1421 | (ada-case-read-exceptions-from-file file-name) | 1419 | (ada-case-read-exceptions-from-file file-name) |
| @@ -1425,11 +1423,9 @@ The standard casing rules will no longer apply to this word." | |||
| 1425 | (if (and (not (equal ada-case-exception '())) | 1423 | (if (and (not (equal ada-case-exception '())) |
| 1426 | (assoc-string word ada-case-exception t)) | 1424 | (assoc-string word ada-case-exception t)) |
| 1427 | (setcar (assoc-string word ada-case-exception t) word) | 1425 | (setcar (assoc-string word ada-case-exception t) word) |
| 1428 | (add-to-list 'ada-case-exception (cons word t)) | 1426 | (add-to-list 'ada-case-exception (cons word t))) |
| 1429 | ) | ||
| 1430 | 1427 | ||
| 1431 | (ada-save-exceptions-to-file file-name) | 1428 | (ada-save-exceptions-to-file file-name))) |
| 1432 | )) | ||
| 1433 | 1429 | ||
| 1434 | (defun ada-create-case-exception-substring (&optional word) | 1430 | (defun ada-create-case-exception-substring (&optional word) |
| 1435 | "Define the substring WORD as an exception for the casing system. | 1431 | "Define the substring WORD as an exception for the casing system. |
| @@ -1464,7 +1460,7 @@ word itself has a special casing." | |||
| 1464 | (modify-syntax-entry ?_ "." (syntax-table)) | 1460 | (modify-syntax-entry ?_ "." (syntax-table)) |
| 1465 | (save-excursion | 1461 | (save-excursion |
| 1466 | (skip-syntax-backward "w") | 1462 | (skip-syntax-backward "w") |
| 1467 | (set 'word (buffer-substring-no-properties | 1463 | (setq word (buffer-substring-no-properties |
| 1468 | (point) | 1464 | (point) |
| 1469 | (save-excursion (forward-word 1) (point)))))) | 1465 | (save-excursion (forward-word 1) (point)))))) |
| 1470 | (modify-syntax-entry ?_ (make-string 1 underscore-syntax) | 1466 | (modify-syntax-entry ?_ (make-string 1 underscore-syntax) |
| @@ -1633,37 +1629,30 @@ ARG is the prefix the user entered with \\[universal-argument]." | |||
| 1633 | (interactive "P") | 1629 | (interactive "P") |
| 1634 | 1630 | ||
| 1635 | (if ada-auto-case | 1631 | (if ada-auto-case |
| 1636 | (let ((lastk last-command-event) | 1632 | (let ((lastk last-command-event)) |
| 1637 | (previous-syntax-table (syntax-table))) | 1633 | |
| 1638 | 1634 | (with-syntax-table ada-mode-symbol-syntax-table | |
| 1639 | (unwind-protect | 1635 | (cond ((or (eq lastk ?\n) |
| 1640 | (progn | 1636 | (eq lastk ?\r)) |
| 1641 | (set-syntax-table ada-mode-symbol-syntax-table) | 1637 | ;; horrible kludge |
| 1642 | (cond ((or (eq lastk ?\n) | 1638 | (insert " ") |
| 1643 | (eq lastk ?\r)) | 1639 | (ada-adjust-case) |
| 1644 | ;; horrible kludge | 1640 | ;; horrible dekludge |
| 1645 | (insert " ") | 1641 | (delete-char -1) |
| 1646 | (ada-adjust-case) | 1642 | ;; some special keys and their bindings |
| 1647 | ;; horrible dekludge | 1643 | (cond |
| 1648 | (delete-char -1) | 1644 | ((eq lastk ?\n) |
| 1649 | ;; some special keys and their bindings | 1645 | (funcall ada-lfd-binding)) |
| 1650 | (cond | 1646 | ((eq lastk ?\r) |
| 1651 | ((eq lastk ?\n) | 1647 | (funcall ada-ret-binding)))) |
| 1652 | (funcall ada-lfd-binding)) | 1648 | ((eq lastk ?\C-i) (ada-tab)) |
| 1653 | ((eq lastk ?\r) | 1649 | ;; Else just insert the character |
| 1654 | (funcall ada-ret-binding)))) | 1650 | ((self-insert-command (prefix-numeric-value arg)))) |
| 1655 | ((eq lastk ?\C-i) (ada-tab)) | 1651 | ;; if there is a keyword in front of the underscore |
| 1656 | ;; Else just insert the character | 1652 | ;; then it should be part of an identifier (MH) |
| 1657 | ((self-insert-command (prefix-numeric-value arg)))) | 1653 | (if (eq lastk ?_) |
| 1658 | ;; if there is a keyword in front of the underscore | 1654 | (ada-adjust-case t) |
| 1659 | ;; then it should be part of an identifier (MH) | 1655 | (ada-adjust-case)))) |
| 1660 | (if (eq lastk ?_) | ||
| 1661 | (ada-adjust-case t) | ||
| 1662 | (ada-adjust-case)) | ||
| 1663 | ) | ||
| 1664 | ;; Restore the syntax table | ||
| 1665 | (set-syntax-table previous-syntax-table)) | ||
| 1666 | ) | ||
| 1667 | 1656 | ||
| 1668 | ;; Else, no auto-casing | 1657 | ;; Else, no auto-casing |
| 1669 | (cond | 1658 | (cond |
| @@ -1672,10 +1661,10 @@ ARG is the prefix the user entered with \\[universal-argument]." | |||
| 1672 | ((eq last-command-event ?\r) | 1661 | ((eq last-command-event ?\r) |
| 1673 | (funcall ada-ret-binding)) | 1662 | (funcall ada-ret-binding)) |
| 1674 | (t | 1663 | (t |
| 1675 | (self-insert-command (prefix-numeric-value arg)))) | 1664 | (self-insert-command (prefix-numeric-value arg)))))) |
| 1676 | )) | ||
| 1677 | 1665 | ||
| 1678 | (defun ada-activate-keys-for-case () | 1666 | (defun ada-activate-keys-for-case () |
| 1667 | ;; FIXME: Use post-self-insert-hook instead of changing key bindings. | ||
| 1679 | "Modify the key bindings for all the keys that should readjust the casing." | 1668 | "Modify the key bindings for all the keys that should readjust the casing." |
| 1680 | (interactive) | 1669 | (interactive) |
| 1681 | ;; Save original key-bindings to allow swapping ret/lfd | 1670 | ;; Save original key-bindings to allow swapping ret/lfd |
| @@ -1735,44 +1724,41 @@ Attention: This function might take very long for big regions!" | |||
| 1735 | (let ((begin nil) | 1724 | (let ((begin nil) |
| 1736 | (end nil) | 1725 | (end nil) |
| 1737 | (keywordp nil) | 1726 | (keywordp nil) |
| 1738 | (attribp nil) | 1727 | (attribp nil)) |
| 1739 | (previous-syntax-table (syntax-table))) | ||
| 1740 | (message "Adjusting case ...") | 1728 | (message "Adjusting case ...") |
| 1741 | (unwind-protect | 1729 | (with-syntax-table ada-mode-symbol-syntax-table |
| 1742 | (save-excursion | 1730 | (save-excursion |
| 1743 | (set-syntax-table ada-mode-symbol-syntax-table) | 1731 | (goto-char to) |
| 1744 | (goto-char to) | 1732 | ;; |
| 1745 | ;; | 1733 | ;; loop: look for all identifiers, keywords, and attributes |
| 1746 | ;; loop: look for all identifiers, keywords, and attributes | 1734 | ;; |
| 1747 | ;; | 1735 | (while (re-search-backward "\\<\\(\\sw+\\)\\>" from t) |
| 1748 | (while (re-search-backward "\\<\\(\\sw+\\)\\>" from t) | 1736 | (setq end (match-end 1)) |
| 1749 | (setq end (match-end 1)) | 1737 | (setq attribp |
| 1750 | (setq attribp | 1738 | (and (> (point) from) |
| 1751 | (and (> (point) from) | 1739 | (save-excursion |
| 1752 | (save-excursion | 1740 | (forward-char -1) |
| 1753 | (forward-char -1) | 1741 | (setq attribp (looking-at "'.[^']"))))) |
| 1754 | (setq attribp (looking-at "'.[^']"))))) | 1742 | (or |
| 1755 | (or | 1743 | ;; do nothing if it is a string or comment |
| 1756 | ;; do nothing if it is a string or comment | 1744 | (ada-in-string-or-comment-p) |
| 1757 | (ada-in-string-or-comment-p) | 1745 | (progn |
| 1758 | (progn | 1746 | ;; |
| 1759 | ;; | 1747 | ;; get the identifier or keyword or attribute |
| 1760 | ;; get the identifier or keyword or attribute | 1748 | ;; |
| 1761 | ;; | 1749 | (setq begin (point)) |
| 1762 | (setq begin (point)) | 1750 | (setq keywordp (looking-at ada-keywords)) |
| 1763 | (setq keywordp (looking-at ada-keywords)) | 1751 | (goto-char end) |
| 1764 | (goto-char end) | 1752 | ;; |
| 1765 | ;; | 1753 | ;; casing according to user-option |
| 1766 | ;; casing according to user-option | 1754 | ;; |
| 1767 | ;; | 1755 | (if attribp |
| 1768 | (if attribp | 1756 | (funcall ada-case-attribute -1) |
| 1769 | (funcall ada-case-attribute -1) | 1757 | (if keywordp |
| 1770 | (if keywordp | 1758 | (funcall ada-case-keyword -1) |
| 1771 | (funcall ada-case-keyword -1) | 1759 | (ada-adjust-case-identifier))) |
| 1772 | (ada-adjust-case-identifier))) | 1760 | (goto-char begin)))) |
| 1773 | (goto-char begin)))) | 1761 | (message "Adjusting case ... Done"))))) |
| 1774 | (message "Adjusting case ... Done")) | ||
| 1775 | (set-syntax-table previous-syntax-table)))) | ||
| 1776 | 1762 | ||
| 1777 | (defun ada-adjust-case-buffer () | 1763 | (defun ada-adjust-case-buffer () |
| 1778 | "Adjust the case of all words in the whole buffer. | 1764 | "Adjust the case of all words in the whole buffer. |
| @@ -1803,46 +1789,39 @@ ATTENTION: This function might take very long for big buffers!" | |||
| 1803 | (let ((begin nil) | 1789 | (let ((begin nil) |
| 1804 | (end nil) | 1790 | (end nil) |
| 1805 | (delend nil) | 1791 | (delend nil) |
| 1806 | (paramlist nil) | 1792 | (paramlist nil)) |
| 1807 | (previous-syntax-table (syntax-table))) | 1793 | (with-syntax-table ada-mode-symbol-syntax-table |
| 1808 | (unwind-protect | ||
| 1809 | (progn | ||
| 1810 | (set-syntax-table ada-mode-symbol-syntax-table) | ||
| 1811 | 1794 | ||
| 1812 | ;; check if really inside parameter list | 1795 | ;; check if really inside parameter list |
| 1813 | (or (ada-in-paramlist-p) | 1796 | (or (ada-in-paramlist-p) |
| 1814 | (error "Not in parameter list")) | 1797 | (error "Not in parameter list")) |
| 1815 | 1798 | ||
| 1816 | ;; find start of current parameter-list | 1799 | ;; find start of current parameter-list |
| 1817 | (ada-search-ignore-string-comment | 1800 | (ada-search-ignore-string-comment |
| 1818 | (concat ada-subprog-start-re "\\|\\<body\\>" ) t nil) | 1801 | (concat ada-subprog-start-re "\\|\\<body\\>" ) t nil) |
| 1819 | (down-list 1) | 1802 | (down-list 1) |
| 1820 | (backward-char 1) | 1803 | (backward-char 1) |
| 1821 | (setq begin (point)) | 1804 | (setq begin (point)) |
| 1822 | 1805 | ||
| 1823 | ;; find end of parameter-list | 1806 | ;; find end of parameter-list |
| 1824 | (forward-sexp 1) | 1807 | (forward-sexp 1) |
| 1825 | (setq delend (point)) | 1808 | (setq delend (point)) |
| 1826 | (delete-char -1) | 1809 | (delete-char -1) |
| 1827 | (insert "\n") | 1810 | (insert "\n") |
| 1828 | 1811 | ||
| 1829 | ;; find end of last parameter-declaration | 1812 | ;; find end of last parameter-declaration |
| 1830 | (forward-comment -1000) | 1813 | (forward-comment -1000) |
| 1831 | (setq end (point)) | 1814 | (setq end (point)) |
| 1832 | |||
| 1833 | ;; build a list of all elements of the parameter-list | ||
| 1834 | (setq paramlist (ada-scan-paramlist (1+ begin) end)) | ||
| 1835 | 1815 | ||
| 1836 | ;; delete the original parameter-list | 1816 | ;; build a list of all elements of the parameter-list |
| 1837 | (delete-region begin delend) | 1817 | (setq paramlist (ada-scan-paramlist (1+ begin) end)) |
| 1838 | 1818 | ||
| 1839 | ;; insert the new parameter-list | 1819 | ;; delete the original parameter-list |
| 1840 | (goto-char begin) | 1820 | (delete-region begin delend) |
| 1841 | (ada-insert-paramlist paramlist)) | ||
| 1842 | 1821 | ||
| 1843 | ;; restore syntax-table | 1822 | ;; insert the new parameter-list |
| 1844 | (set-syntax-table previous-syntax-table) | 1823 | (goto-char begin) |
| 1845 | ))) | 1824 | (ada-insert-paramlist paramlist)))) |
| 1846 | 1825 | ||
| 1847 | (defun ada-scan-paramlist (begin end) | 1826 | (defun ada-scan-paramlist (begin end) |
| 1848 | "Scan the parameter list found in between BEGIN and END. | 1827 | "Scan the parameter list found in between BEGIN and END. |
| @@ -2186,14 +2165,12 @@ Return the new position of point or nil if not found." | |||
| 2186 | Return the calculation that was done, including the reference point | 2165 | Return the calculation that was done, including the reference point |
| 2187 | and the offset." | 2166 | and the offset." |
| 2188 | (interactive) | 2167 | (interactive) |
| 2189 | (let ((previous-syntax-table (syntax-table)) | 2168 | (let ((orgpoint (point-marker)) |
| 2190 | (orgpoint (point-marker)) | ||
| 2191 | cur-indent tmp-indent | 2169 | cur-indent tmp-indent |
| 2192 | prev-indent) | 2170 | prev-indent) |
| 2193 | 2171 | ||
| 2194 | (unwind-protect | 2172 | (unwind-protect |
| 2195 | (progn | 2173 | (with-syntax-table ada-mode-symbol-syntax-table |
| 2196 | (set-syntax-table ada-mode-symbol-syntax-table) | ||
| 2197 | 2174 | ||
| 2198 | ;; This need to be done here so that the advice is not always | 2175 | ;; This need to be done here so that the advice is not always |
| 2199 | ;; activated (this might interact badly with other modes) | 2176 | ;; activated (this might interact badly with other modes) |
| @@ -2203,14 +2180,14 @@ and the offset." | |||
| 2203 | (save-excursion | 2180 | (save-excursion |
| 2204 | (setq cur-indent | 2181 | (setq cur-indent |
| 2205 | 2182 | ||
| 2206 | ;; Not First line in the buffer ? | 2183 | ;; Not First line in the buffer ? |
| 2207 | (if (save-excursion (zerop (forward-line -1))) | 2184 | (if (save-excursion (zerop (forward-line -1))) |
| 2208 | (progn | 2185 | (progn |
| 2209 | (back-to-indentation) | 2186 | (back-to-indentation) |
| 2210 | (ada-get-current-indent)) | 2187 | (ada-get-current-indent)) |
| 2211 | 2188 | ||
| 2212 | ;; first line in the buffer | 2189 | ;; first line in the buffer |
| 2213 | (list (point-min) 0)))) | 2190 | (list (point-min) 0)))) |
| 2214 | 2191 | ||
| 2215 | ;; Evaluate the list to get the column to indent to | 2192 | ;; Evaluate the list to get the column to indent to |
| 2216 | ;; prev-indent contains the column to indent to | 2193 | ;; prev-indent contains the column to indent to |
| @@ -2242,14 +2219,10 @@ and the offset." | |||
| 2242 | (if (< (current-column) (current-indentation)) | 2219 | (if (< (current-column) (current-indentation)) |
| 2243 | (back-to-indentation))) | 2220 | (back-to-indentation))) |
| 2244 | 2221 | ||
| 2245 | ;; restore syntax-table | ||
| 2246 | (set-syntax-table previous-syntax-table) | ||
| 2247 | (if (featurep 'xemacs) | 2222 | (if (featurep 'xemacs) |
| 2248 | (ad-deactivate 'parse-partial-sexp)) | 2223 | (ad-deactivate 'parse-partial-sexp))) |
| 2249 | ) | ||
| 2250 | 2224 | ||
| 2251 | cur-indent | 2225 | cur-indent)) |
| 2252 | )) | ||
| 2253 | 2226 | ||
| 2254 | (defun ada-get-current-indent () | 2227 | (defun ada-get-current-indent () |
| 2255 | "Return the indentation to use for the current line." | 2228 | "Return the indentation to use for the current line." |
| @@ -2512,11 +2485,11 @@ and the offset." | |||
| 2512 | (if (looking-at "renames") | 2485 | (if (looking-at "renames") |
| 2513 | (let (pos) | 2486 | (let (pos) |
| 2514 | (save-excursion | 2487 | (save-excursion |
| 2515 | (set 'pos (ada-search-ignore-string-comment ";\\|return\\>" t))) | 2488 | (setq pos (ada-search-ignore-string-comment ";\\|return\\>" t))) |
| 2516 | (if (and pos | 2489 | (if (and pos |
| 2517 | (= (downcase (char-after (car pos))) ?r)) | 2490 | (= (downcase (char-after (car pos))) ?r)) |
| 2518 | (goto-char (car pos))) | 2491 | (goto-char (car pos))) |
| 2519 | (set 'var 'ada-indent-renames))) | 2492 | (setq var 'ada-indent-renames))) |
| 2520 | 2493 | ||
| 2521 | (forward-comment -1000) | 2494 | (forward-comment -1000) |
| 2522 | (if (= (char-before) ?\)) | 2495 | (if (= (char-before) ?\)) |
| @@ -2533,7 +2506,7 @@ and the offset." | |||
| 2533 | (looking-at "\\(function\\|procedure\\)\\>")) | 2506 | (looking-at "\\(function\\|procedure\\)\\>")) |
| 2534 | (progn | 2507 | (progn |
| 2535 | (backward-word 1) | 2508 | (backward-word 1) |
| 2536 | (set 'num-back 2) | 2509 | (setq num-back 2) |
| 2537 | (looking-at "\\(function\\|procedure\\)\\>"))))) | 2510 | (looking-at "\\(function\\|procedure\\)\\>"))))) |
| 2538 | 2511 | ||
| 2539 | ;; The indentation depends of the value of ada-indent-return | 2512 | ;; The indentation depends of the value of ada-indent-return |
| @@ -4046,8 +4019,7 @@ Point is moved at the beginning of the SEARCH-RE." | |||
| 4046 | (let (found | 4019 | (let (found |
| 4047 | begin | 4020 | begin |
| 4048 | end | 4021 | end |
| 4049 | parse-result | 4022 | parse-result) |
| 4050 | (previous-syntax-table (syntax-table))) | ||
| 4051 | 4023 | ||
| 4052 | ;; FIXME: need to pass BACKWARD to search-func! | 4024 | ;; FIXME: need to pass BACKWARD to search-func! |
| 4053 | (unless search-func | 4025 | (unless search-func |
| @@ -4057,67 +4029,65 @@ Point is moved at the beginning of the SEARCH-RE." | |||
| 4057 | ;; search until found or end-of-buffer | 4029 | ;; search until found or end-of-buffer |
| 4058 | ;; We have to test that we do not look further than limit | 4030 | ;; We have to test that we do not look further than limit |
| 4059 | ;; | 4031 | ;; |
| 4060 | (set-syntax-table ada-mode-symbol-syntax-table) | 4032 | (with-syntax-table ada-mode-symbol-syntax-table |
| 4061 | (while (and (not found) | 4033 | (while (and (not found) |
| 4062 | (or (not limit) | 4034 | (or (not limit) |
| 4063 | (or (and backward (<= limit (point))) | 4035 | (or (and backward (<= limit (point))) |
| 4064 | (>= limit (point)))) | 4036 | (>= limit (point)))) |
| 4065 | (funcall search-func search-re limit 1)) | 4037 | (funcall search-func search-re limit 1)) |
| 4066 | (setq begin (match-beginning 0)) | 4038 | (setq begin (match-beginning 0)) |
| 4067 | (setq end (match-end 0)) | 4039 | (setq end (match-end 0)) |
| 4068 | 4040 | ||
| 4069 | (setq parse-result (parse-partial-sexp | 4041 | (setq parse-result (parse-partial-sexp |
| 4070 | (save-excursion (beginning-of-line) (point)) | 4042 | (save-excursion (beginning-of-line) (point)) |
| 4071 | (point))) | 4043 | (point))) |
| 4072 | 4044 | ||
| 4073 | (cond | 4045 | (cond |
| 4074 | ;; | 4046 | ;; |
| 4075 | ;; If inside a string, skip it (and the following comments) | 4047 | ;; If inside a string, skip it (and the following comments) |
| 4076 | ;; | 4048 | ;; |
| 4077 | ((ada-in-string-p parse-result) | 4049 | ((ada-in-string-p parse-result) |
| 4078 | (if (featurep 'xemacs) | 4050 | (if (featurep 'xemacs) |
| 4079 | (search-backward "\"" nil t) | 4051 | (search-backward "\"" nil t) |
| 4080 | (goto-char (nth 8 parse-result))) | 4052 | (goto-char (nth 8 parse-result))) |
| 4081 | (unless backward (forward-sexp 1))) | 4053 | (unless backward (forward-sexp 1))) |
| 4082 | ;; | 4054 | ;; |
| 4083 | ;; If inside a comment, skip it (and the following comments) | 4055 | ;; If inside a comment, skip it (and the following comments) |
| 4084 | ;; There is a special code for comments at the end of the file | 4056 | ;; There is a special code for comments at the end of the file |
| 4085 | ;; | 4057 | ;; |
| 4086 | ((ada-in-comment-p parse-result) | 4058 | ((ada-in-comment-p parse-result) |
| 4087 | (if (featurep 'xemacs) | 4059 | (if (featurep 'xemacs) |
| 4088 | (progn | 4060 | (progn |
| 4089 | (forward-line 1) | 4061 | (forward-line 1) |
| 4090 | (beginning-of-line) | 4062 | (beginning-of-line) |
| 4091 | (forward-comment -1)) | 4063 | (forward-comment -1)) |
| 4092 | (goto-char (nth 8 parse-result))) | 4064 | (goto-char (nth 8 parse-result))) |
| 4093 | (unless backward | 4065 | (unless backward |
| 4094 | ;; at the end of the file, it is not possible to skip a comment | 4066 | ;; at the end of the file, it is not possible to skip a comment |
| 4095 | ;; so we just go at the end of the line | 4067 | ;; so we just go at the end of the line |
| 4096 | (if (forward-comment 1) | 4068 | (if (forward-comment 1) |
| 4097 | (progn | 4069 | (progn |
| 4098 | (forward-comment 1000) | 4070 | (forward-comment 1000) |
| 4099 | (beginning-of-line)) | 4071 | (beginning-of-line)) |
| 4100 | (end-of-line)))) | 4072 | (end-of-line)))) |
| 4101 | ;; | 4073 | ;; |
| 4102 | ;; directly in front of a comment => skip it, if searching forward | 4074 | ;; directly in front of a comment => skip it, if searching forward |
| 4103 | ;; | 4075 | ;; |
| 4104 | ((and (= (char-after begin) ?-) (= (char-after (1+ begin)) ?-)) | 4076 | ((and (= (char-after begin) ?-) (= (char-after (1+ begin)) ?-)) |
| 4105 | (unless backward (progn (forward-char -1) (forward-comment 1000)))) | 4077 | (unless backward (progn (forward-char -1) (forward-comment 1000)))) |
| 4106 | 4078 | ||
| 4107 | ;; | 4079 | ;; |
| 4108 | ;; found a parameter-list but should ignore it => skip it | 4080 | ;; found a parameter-list but should ignore it => skip it |
| 4109 | ;; | 4081 | ;; |
| 4110 | ((and (not paramlists) (ada-in-paramlist-p)) | 4082 | ((and (not paramlists) (ada-in-paramlist-p)) |
| 4111 | (if backward | 4083 | (if backward |
| 4112 | (search-backward "(" nil t) | 4084 | (search-backward "(" nil t) |
| 4113 | (search-forward ")" nil t))) | 4085 | (search-forward ")" nil t))) |
| 4114 | ;; | 4086 | ;; |
| 4115 | ;; found what we were looking for | 4087 | ;; found what we were looking for |
| 4116 | ;; | 4088 | ;; |
| 4117 | (t | 4089 | (t |
| 4118 | (setq found t)))) ; end of loop | 4090 | (setq found t))))) ; end of loop |
| 4119 | |||
| 4120 | (set-syntax-table previous-syntax-table) | ||
| 4121 | 4091 | ||
| 4122 | (if found | 4092 | (if found |
| 4123 | (cons begin end) | 4093 | (cons begin end) |
| @@ -4398,122 +4368,109 @@ of the region. Otherwise, operate only on the current line." | |||
| 4398 | (defun ada-move-to-start () | 4368 | (defun ada-move-to-start () |
| 4399 | "Move point to the matching start of the current Ada structure." | 4369 | "Move point to the matching start of the current Ada structure." |
| 4400 | (interactive) | 4370 | (interactive) |
| 4401 | (let ((pos (point)) | 4371 | (let ((pos (point))) |
| 4402 | (previous-syntax-table (syntax-table))) | 4372 | (with-syntax-table ada-mode-symbol-syntax-table |
| 4403 | (unwind-protect | ||
| 4404 | (progn | ||
| 4405 | (set-syntax-table ada-mode-symbol-syntax-table) | ||
| 4406 | 4373 | ||
| 4407 | (save-excursion | 4374 | (save-excursion |
| 4408 | ;; | 4375 | ;; |
| 4409 | ;; do nothing if in string or comment or not on 'end ...;' | 4376 | ;; do nothing if in string or comment or not on 'end ...;' |
| 4410 | ;; or if an error occurs during processing | 4377 | ;; or if an error occurs during processing |
| 4411 | ;; | 4378 | ;; |
| 4412 | (or | 4379 | (or |
| 4413 | (ada-in-string-or-comment-p) | 4380 | (ada-in-string-or-comment-p) |
| 4414 | (and (progn | 4381 | (and (progn |
| 4415 | (or (looking-at "[ \t]*\\<end\\>") | 4382 | (or (looking-at "[ \t]*\\<end\\>") |
| 4416 | (backward-word 1)) | 4383 | (backward-word 1)) |
| 4417 | (or (looking-at "[ \t]*\\<end\\>") | 4384 | (or (looking-at "[ \t]*\\<end\\>") |
| 4418 | (backward-word 1)) | 4385 | (backward-word 1)) |
| 4419 | (or (looking-at "[ \t]*\\<end\\>") | 4386 | (or (looking-at "[ \t]*\\<end\\>") |
| 4420 | (error "Not on end ...;"))) | 4387 | (error "Not on end ...;"))) |
| 4421 | (ada-goto-matching-start 1) | 4388 | (ada-goto-matching-start 1) |
| 4422 | (setq pos (point)) | 4389 | (setq pos (point)) |
| 4423 | 4390 | ||
| 4424 | ;; | 4391 | ;; |
| 4425 | ;; on 'begin' => go on, according to user option | 4392 | ;; on 'begin' => go on, according to user option |
| 4426 | ;; | 4393 | ;; |
| 4427 | ada-move-to-declaration | 4394 | ada-move-to-declaration |
| 4428 | (looking-at "\\<begin\\>") | 4395 | (looking-at "\\<begin\\>") |
| 4429 | (ada-goto-decl-start) | 4396 | (ada-goto-decl-start) |
| 4430 | (setq pos (point)))) | 4397 | (setq pos (point)))) |
| 4431 | 4398 | ||
| 4432 | ) ; end of save-excursion | 4399 | ) ; end of save-excursion |
| 4433 | 4400 | ||
| 4434 | ;; now really move to the found position | 4401 | ;; now really move to the found position |
| 4435 | (goto-char pos)) | 4402 | (goto-char pos)))) |
| 4436 | |||
| 4437 | ;; restore syntax-table | ||
| 4438 | (set-syntax-table previous-syntax-table)))) | ||
| 4439 | 4403 | ||
| 4440 | (defun ada-move-to-end () | 4404 | (defun ada-move-to-end () |
| 4441 | "Move point to the end of the block around point. | 4405 | "Move point to the end of the block around point. |
| 4442 | Moves to 'begin' if in a declarative part." | 4406 | Moves to 'begin' if in a declarative part." |
| 4443 | (interactive) | 4407 | (interactive) |
| 4444 | (let ((pos (point)) | 4408 | (let ((pos (point)) |
| 4445 | decl-start | 4409 | decl-start) |
| 4446 | (previous-syntax-table (syntax-table))) | 4410 | (with-syntax-table ada-mode-symbol-syntax-table |
| 4447 | (unwind-protect | ||
| 4448 | (progn | ||
| 4449 | (set-syntax-table ada-mode-symbol-syntax-table) | ||
| 4450 | |||
| 4451 | (save-excursion | ||
| 4452 | |||
| 4453 | (cond | ||
| 4454 | ;; Go to the beginning of the current word, and check if we are | ||
| 4455 | ;; directly on 'begin' | ||
| 4456 | ((save-excursion | ||
| 4457 | (skip-syntax-backward "w") | ||
| 4458 | (looking-at "\\<begin\\>")) | ||
| 4459 | (ada-goto-matching-end 1) | ||
| 4460 | ) | ||
| 4461 | 4411 | ||
| 4462 | ;; on first line of subprogram body | 4412 | (save-excursion |
| 4463 | ;; Do nothing for specs or generic instantion, since these are | ||
| 4464 | ;; handled as the general case (find the enclosing block) | ||
| 4465 | ;; We also need to make sure that we ignore nested subprograms | ||
| 4466 | ((save-excursion | ||
| 4467 | (and (skip-syntax-backward "w") | ||
| 4468 | (looking-at "\\<function\\>\\|\\<procedure\\>" ) | ||
| 4469 | (ada-search-ignore-string-comment "is\\|;") | ||
| 4470 | (not (= (char-before) ?\;)) | ||
| 4471 | )) | ||
| 4472 | (skip-syntax-backward "w") | ||
| 4473 | (ada-goto-matching-end 0 t)) | ||
| 4474 | |||
| 4475 | ;; on first line of task declaration | ||
| 4476 | ((save-excursion | ||
| 4477 | (and (ada-goto-stmt-start) | ||
| 4478 | (looking-at "\\<task\\>" ) | ||
| 4479 | (forward-word 1) | ||
| 4480 | (ada-goto-next-non-ws) | ||
| 4481 | (looking-at "\\<body\\>"))) | ||
| 4482 | (ada-search-ignore-string-comment "begin" nil nil nil | ||
| 4483 | 'word-search-forward)) | ||
| 4484 | ;; accept block start | ||
| 4485 | ((save-excursion | ||
| 4486 | (and (ada-goto-stmt-start) | ||
| 4487 | (looking-at "\\<accept\\>" ))) | ||
| 4488 | (ada-goto-matching-end 0)) | ||
| 4489 | ;; package start | ||
| 4490 | ((save-excursion | ||
| 4491 | (setq decl-start (and (ada-goto-decl-start t) (point))) | ||
| 4492 | (and decl-start (looking-at "\\<package\\>"))) | ||
| 4493 | (ada-goto-matching-end 1)) | ||
| 4494 | |||
| 4495 | ;; On a "declare" keyword | ||
| 4496 | ((save-excursion | ||
| 4497 | (skip-syntax-backward "w") | ||
| 4498 | (looking-at "\\<declare\\>")) | ||
| 4499 | (ada-goto-matching-end 0 t)) | ||
| 4500 | |||
| 4501 | ;; inside a 'begin' ... 'end' block | ||
| 4502 | (decl-start | ||
| 4503 | (goto-char decl-start) | ||
| 4504 | (ada-goto-matching-end 0 t)) | ||
| 4505 | |||
| 4506 | ;; (hopefully ;-) everything else | ||
| 4507 | (t | ||
| 4508 | (ada-goto-matching-end 1))) | ||
| 4509 | (setq pos (point)) | ||
| 4510 | ) | ||
| 4511 | |||
| 4512 | ;; now really move to the position found | ||
| 4513 | (goto-char pos)) | ||
| 4514 | 4413 | ||
| 4515 | ;; restore syntax-table | 4414 | (cond |
| 4516 | (set-syntax-table previous-syntax-table)))) | 4415 | ;; Go to the beginning of the current word, and check if we are |
| 4416 | ;; directly on 'begin' | ||
| 4417 | ((save-excursion | ||
| 4418 | (skip-syntax-backward "w") | ||
| 4419 | (looking-at "\\<begin\\>")) | ||
| 4420 | (ada-goto-matching-end 1)) | ||
| 4421 | |||
| 4422 | ;; on first line of subprogram body | ||
| 4423 | ;; Do nothing for specs or generic instantion, since these are | ||
| 4424 | ;; handled as the general case (find the enclosing block) | ||
| 4425 | ;; We also need to make sure that we ignore nested subprograms | ||
| 4426 | ((save-excursion | ||
| 4427 | (and (skip-syntax-backward "w") | ||
| 4428 | (looking-at "\\<function\\>\\|\\<procedure\\>" ) | ||
| 4429 | (ada-search-ignore-string-comment "is\\|;") | ||
| 4430 | (not (= (char-before) ?\;)) | ||
| 4431 | )) | ||
| 4432 | (skip-syntax-backward "w") | ||
| 4433 | (ada-goto-matching-end 0 t)) | ||
| 4434 | |||
| 4435 | ;; on first line of task declaration | ||
| 4436 | ((save-excursion | ||
| 4437 | (and (ada-goto-stmt-start) | ||
| 4438 | (looking-at "\\<task\\>" ) | ||
| 4439 | (forward-word 1) | ||
| 4440 | (ada-goto-next-non-ws) | ||
| 4441 | (looking-at "\\<body\\>"))) | ||
| 4442 | (ada-search-ignore-string-comment "begin" nil nil nil | ||
| 4443 | 'word-search-forward)) | ||
| 4444 | ;; accept block start | ||
| 4445 | ((save-excursion | ||
| 4446 | (and (ada-goto-stmt-start) | ||
| 4447 | (looking-at "\\<accept\\>" ))) | ||
| 4448 | (ada-goto-matching-end 0)) | ||
| 4449 | ;; package start | ||
| 4450 | ((save-excursion | ||
| 4451 | (setq decl-start (and (ada-goto-decl-start t) (point))) | ||
| 4452 | (and decl-start (looking-at "\\<package\\>"))) | ||
| 4453 | (ada-goto-matching-end 1)) | ||
| 4454 | |||
| 4455 | ;; On a "declare" keyword | ||
| 4456 | ((save-excursion | ||
| 4457 | (skip-syntax-backward "w") | ||
| 4458 | (looking-at "\\<declare\\>")) | ||
| 4459 | (ada-goto-matching-end 0 t)) | ||
| 4460 | |||
| 4461 | ;; inside a 'begin' ... 'end' block | ||
| 4462 | (decl-start | ||
| 4463 | (goto-char decl-start) | ||
| 4464 | (ada-goto-matching-end 0 t)) | ||
| 4465 | |||
| 4466 | ;; (hopefully ;-) everything else | ||
| 4467 | (t | ||
| 4468 | (ada-goto-matching-end 1))) | ||
| 4469 | (setq pos (point)) | ||
| 4470 | ) | ||
| 4471 | |||
| 4472 | ;; now really move to the position found | ||
| 4473 | (goto-char pos)))) | ||
| 4517 | 4474 | ||
| 4518 | (defun ada-next-procedure () | 4475 | (defun ada-next-procedure () |
| 4519 | "Move point to next procedure." | 4476 | "Move point to next procedure." |
| @@ -4818,7 +4775,7 @@ Moves to 'begin' if in a declarative part." | |||
| 4818 | (if (featurep 'xemacs) | 4775 | (if (featurep 'xemacs) |
| 4819 | (progn | 4776 | (progn |
| 4820 | (define-key ada-mode-map [menu-bar] ada-mode-menu) | 4777 | (define-key ada-mode-map [menu-bar] ada-mode-menu) |
| 4821 | (set 'mode-popup-menu (cons "Ada mode" ada-mode-menu)))))) | 4778 | (setq mode-popup-menu (cons "Ada mode" ada-mode-menu)))))) |
| 4822 | 4779 | ||
| 4823 | 4780 | ||
| 4824 | ;; ------------------------------------------------------- | 4781 | ;; ------------------------------------------------------- |
| @@ -5040,7 +4997,7 @@ or the spec otherwise." | |||
| 5040 | (ada-find-src-file-in-dir | 4997 | (ada-find-src-file-in-dir |
| 5041 | (file-name-nondirectory (concat name (car suffixes)))))) | 4998 | (file-name-nondirectory (concat name (car suffixes)))))) |
| 5042 | (if other | 4999 | (if other |
| 5043 | (set 'is-spec other))) | 5000 | (setq is-spec other))) |
| 5044 | 5001 | ||
| 5045 | ;; Else search in the current directory | 5002 | ;; Else search in the current directory |
| 5046 | (if (file-exists-p (concat name (car suffixes))) | 5003 | (if (file-exists-p (concat name (car suffixes))) |
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el index c37744bfe45..2002f05003d 100644 --- a/lisp/progmodes/fortran.el +++ b/lisp/progmodes/fortran.el | |||
| @@ -920,8 +920,7 @@ affects all Fortran buffers, and also the default." | |||
| 920 | new (fortran-font-lock-syntactic-keywords)) | 920 | new (fortran-font-lock-syntactic-keywords)) |
| 921 | ;; Refontify only if necessary. | 921 | ;; Refontify only if necessary. |
| 922 | (unless (equal new font-lock-syntactic-keywords) | 922 | (unless (equal new font-lock-syntactic-keywords) |
| 923 | (setq font-lock-syntactic-keywords | 923 | (setq font-lock-syntactic-keywords new) |
| 924 | (fortran-font-lock-syntactic-keywords)) | ||
| 925 | (if font-lock-mode (font-lock-mode 1)))))) | 924 | (if font-lock-mode (font-lock-mode 1)))))) |
| 926 | (if global | 925 | (if global |
| 927 | (buffer-list) | 926 | (buffer-list) |
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 5e854f852e1..c49f86e2d0b 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el | |||
| @@ -45,16 +45,16 @@ | |||
| 45 | 45 | ||
| 46 | ;;; Code: | 46 | ;;; Code: |
| 47 | 47 | ||
| 48 | (eval-and-compile | 48 | |
| 49 | (require 'cc-mode) | 49 | (require 'cc-mode) |
| 50 | (require 'font-lock) | 50 | (require 'font-lock) |
| 51 | (require 'newcomment) | 51 | (require 'newcomment) |
| 52 | (require 'imenu) | 52 | (require 'imenu) |
| 53 | (require 'etags) | 53 | (require 'etags) |
| 54 | (require 'thingatpt) | 54 | (require 'thingatpt) |
| 55 | (require 'easymenu) | 55 | (require 'easymenu) |
| 56 | (require 'moz nil t) | 56 | (require 'moz nil t) |
| 57 | (require 'json nil t)) | 57 | (require 'json nil t) |
| 58 | 58 | ||
| 59 | (eval-when-compile | 59 | (eval-when-compile |
| 60 | (require 'cl) | 60 | (require 'cl) |
| @@ -725,20 +725,19 @@ as if strings, cpp macros, and comments have been removed. | |||
| 725 | 725 | ||
| 726 | If invoked while inside a macro, it treats the contents of the | 726 | If invoked while inside a macro, it treats the contents of the |
| 727 | macro as normal text." | 727 | macro as normal text." |
| 728 | (unless count (setq count 1)) | ||
| 728 | (let ((saved-point (point)) | 729 | (let ((saved-point (point)) |
| 729 | (search-expr | 730 | (search-fun |
| 730 | (cond ((null count) | 731 | (cond ((< count 0) (setq count (- count)) |
| 731 | '(js--re-search-forward-inner regexp bound 1)) | 732 | #'js--re-search-backward-inner) |
| 732 | ((< count 0) | 733 | ((> count 0) #'js--re-search-forward-inner) |
| 733 | '(js--re-search-backward-inner regexp bound (- count))) | 734 | (t #'ignore)))) |
| 734 | ((> count 0) | ||
| 735 | '(js--re-search-forward-inner regexp bound count))))) | ||
| 736 | (condition-case err | 735 | (condition-case err |
| 737 | (eval search-expr) | 736 | (funcall search-fun regexp bound count) |
| 738 | (search-failed | 737 | (search-failed |
| 739 | (goto-char saved-point) | 738 | (goto-char saved-point) |
| 740 | (unless noerror | 739 | (unless noerror |
| 741 | (error (error-message-string err))))))) | 740 | (signal (car err) (cdr err))))))) |
| 742 | 741 | ||
| 743 | 742 | ||
| 744 | (defun js--re-search-backward-inner (regexp &optional bound count) | 743 | (defun js--re-search-backward-inner (regexp &optional bound count) |
| @@ -782,20 +781,7 @@ as if strings, preprocessor macros, and comments have been | |||
| 782 | removed. | 781 | removed. |
| 783 | 782 | ||
| 784 | If invoked while inside a macro, treat the macro as normal text." | 783 | If invoked while inside a macro, treat the macro as normal text." |
| 785 | (let ((saved-point (point)) | 784 | (js--re-search-forward regexp bound noerror (if count (- count) -1))) |
| 786 | (search-expr | ||
| 787 | (cond ((null count) | ||
| 788 | '(js--re-search-backward-inner regexp bound 1)) | ||
| 789 | ((< count 0) | ||
| 790 | '(js--re-search-forward-inner regexp bound (- count))) | ||
| 791 | ((> count 0) | ||
| 792 | '(js--re-search-backward-inner regexp bound count))))) | ||
| 793 | (condition-case err | ||
| 794 | (eval search-expr) | ||
| 795 | (search-failed | ||
| 796 | (goto-char saved-point) | ||
| 797 | (unless noerror | ||
| 798 | (error (error-message-string err))))))) | ||
| 799 | 785 | ||
| 800 | (defun js--forward-expression () | 786 | (defun js--forward-expression () |
| 801 | "Move forward over a whole JavaScript expression. | 787 | "Move forward over a whole JavaScript expression. |
diff --git a/lisp/progmodes/octave-mod.el b/lisp/progmodes/octave-mod.el index ede850f87ab..5d17e48ada7 100644 --- a/lisp/progmodes/octave-mod.el +++ b/lisp/progmodes/octave-mod.el | |||
| @@ -544,6 +544,8 @@ Non-nil means always go to the next Octave code line after sending." | |||
| 544 | 0) | 544 | 0) |
| 545 | ((:before . "case") octave-block-offset))) | 545 | ((:before . "case") octave-block-offset))) |
| 546 | 546 | ||
| 547 | (defvar electric-indent-chars) | ||
| 548 | |||
| 547 | ;;;###autoload | 549 | ;;;###autoload |
| 548 | (define-derived-mode octave-mode prog-mode "Octave" | 550 | (define-derived-mode octave-mode prog-mode "Octave" |
| 549 | "Major mode for editing Octave code. | 551 | "Major mode for editing Octave code. |