diff options
| author | Joakim Verona | 2013-09-10 23:52:26 +0200 |
|---|---|---|
| committer | Joakim Verona | 2013-09-10 23:52:26 +0200 |
| commit | 63dae8e97d343fd4ebfe3dc08f0e8dc932630a4c (patch) | |
| tree | e5078c5545c777e21944a9ee4199a6f2c6d25ca9 /lisp/progmodes | |
| parent | 92aeabcc8a007f521a664e3aee092eb80ad0f49a (diff) | |
| download | emacs-63dae8e97d343fd4ebfe3dc08f0e8dc932630a4c.tar.gz emacs-63dae8e97d343fd4ebfe3dc08f0e8dc932630a4c.zip | |
merge upstream
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/ada-xref.el | 140 | ||||
| -rw-r--r-- | lisp/progmodes/antlr-mode.el | 4 | ||||
| -rw-r--r-- | lisp/progmodes/bat-mode.el | 1 | ||||
| -rw-r--r-- | lisp/progmodes/cc-awk.el | 1 | ||||
| -rw-r--r-- | lisp/progmodes/cc-bytecomp.el | 4 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 72 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 5 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 197 | ||||
| -rw-r--r-- | lisp/progmodes/cperl-mode.el | 18 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 141 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 54 | ||||
| -rw-r--r-- | lisp/progmodes/sh-script.el | 25 |
12 files changed, 367 insertions, 295 deletions
diff --git a/lisp/progmodes/ada-xref.el b/lisp/progmodes/ada-xref.el index d29fa8c1d36..1ca83a97a59 100644 --- a/lisp/progmodes/ada-xref.el +++ b/lisp/progmodes/ada-xref.el | |||
| @@ -342,9 +342,9 @@ CROSS-PREFIX is the prefix to use for the `gnatls' command." | |||
| 342 | ) | 342 | ) |
| 343 | (kill-buffer nil)))) | 343 | (kill-buffer nil)))) |
| 344 | 344 | ||
| 345 | (set 'ada-xref-runtime-library-specs-path | 345 | (setq ada-xref-runtime-library-specs-path |
| 346 | (reverse ada-xref-runtime-library-specs-path)) | 346 | (reverse ada-xref-runtime-library-specs-path)) |
| 347 | (set 'ada-xref-runtime-library-ali-path | 347 | (setq ada-xref-runtime-library-ali-path |
| 348 | (reverse ada-xref-runtime-library-ali-path)) | 348 | (reverse ada-xref-runtime-library-ali-path)) |
| 349 | )) | 349 | )) |
| 350 | 350 | ||
| @@ -582,8 +582,8 @@ as defined in the project file." | |||
| 582 | 582 | ||
| 583 | (while dirs | 583 | (while dirs |
| 584 | (if (file-directory-p (car dirs)) | 584 | (if (file-directory-p (car dirs)) |
| 585 | (set 'list (append list (file-name-all-completions string (car dirs))))) | 585 | (setq list (append list (file-name-all-completions string (car dirs))))) |
| 586 | (set 'dirs (cdr dirs))) | 586 | (setq dirs (cdr dirs))) |
| 587 | (cond ((equal flag 'lambda) | 587 | (cond ((equal flag 'lambda) |
| 588 | (assoc string list)) | 588 | (assoc string list)) |
| 589 | (flag | 589 | (flag |
| @@ -702,11 +702,11 @@ is non-nil, prompt the user to select one. If none are found, return | |||
| 702 | 702 | ||
| 703 | ((file-exists-p first-choice) | 703 | ((file-exists-p first-choice) |
| 704 | ;; filename.adp | 704 | ;; filename.adp |
| 705 | (set 'selected first-choice)) | 705 | (setq selected first-choice)) |
| 706 | 706 | ||
| 707 | ((= (length prj-files) 1) | 707 | ((= (length prj-files) 1) |
| 708 | ;; Exactly one project file was found in the current directory | 708 | ;; Exactly one project file was found in the current directory |
| 709 | (set 'selected (car prj-files))) | 709 | (setq selected (car prj-files))) |
| 710 | 710 | ||
| 711 | ((and (> (length prj-files) 1) (not no-user-question)) | 711 | ((and (> (length prj-files) 1) (not no-user-question)) |
| 712 | ;; multiple project files in current directory, ask the user | 712 | ;; multiple project files in current directory, ask the user |
| @@ -732,7 +732,7 @@ is non-nil, prompt the user to select one. If none are found, return | |||
| 732 | (> choice (length prj-files))) | 732 | (> choice (length prj-files))) |
| 733 | (setq choice (string-to-number | 733 | (setq choice (string-to-number |
| 734 | (read-from-minibuffer "Enter No. of your choice: ")))) | 734 | (read-from-minibuffer "Enter No. of your choice: ")))) |
| 735 | (set 'selected (nth (1- choice) prj-files)))) | 735 | (setq selected (nth (1- choice) prj-files)))) |
| 736 | 736 | ||
| 737 | ((= (length prj-files) 0) | 737 | ((= (length prj-files) 0) |
| 738 | ;; No project file in the current directory; ask user | 738 | ;; No project file in the current directory; ask user |
| @@ -742,7 +742,7 @@ is non-nil, prompt the user to select one. If none are found, return | |||
| 742 | (concat "project file [" ada-last-prj-file "]:") | 742 | (concat "project file [" ada-last-prj-file "]:") |
| 743 | nil ada-last-prj-file)) | 743 | nil ada-last-prj-file)) |
| 744 | (unless (string= ada-last-prj-file "") | 744 | (unless (string= ada-last-prj-file "") |
| 745 | (set 'selected ada-last-prj-file)))) | 745 | (setq selected ada-last-prj-file)))) |
| 746 | ))) | 746 | ))) |
| 747 | 747 | ||
| 748 | (or selected "default.adp") | 748 | (or selected "default.adp") |
| @@ -792,9 +792,9 @@ is non-nil, prompt the user to select one. If none are found, return | |||
| 792 | 792 | ||
| 793 | (setq prj-file (expand-file-name prj-file)) | 793 | (setq prj-file (expand-file-name prj-file)) |
| 794 | (if (string= (file-name-extension prj-file) "gpr") | 794 | (if (string= (file-name-extension prj-file) "gpr") |
| 795 | (set 'project (ada-gnat-parse-gpr project prj-file)) | 795 | (setq project (ada-gnat-parse-gpr project prj-file)) |
| 796 | 796 | ||
| 797 | (set 'project (ada-parse-prj-file-1 prj-file project)) | 797 | (setq project (ada-parse-prj-file-1 prj-file project)) |
| 798 | ) | 798 | ) |
| 799 | 799 | ||
| 800 | ;; Store the project properties | 800 | ;; Store the project properties |
| @@ -842,7 +842,7 @@ Return new value of PROJECT." | |||
| 842 | (substitute-in-file-name (match-string 2))))) | 842 | (substitute-in-file-name (match-string 2))))) |
| 843 | 843 | ||
| 844 | ((string= (match-string 1) "build_dir") | 844 | ((string= (match-string 1) "build_dir") |
| 845 | (set 'project | 845 | (setq project |
| 846 | (plist-put project 'build_dir | 846 | (plist-put project 'build_dir |
| 847 | (file-name-as-directory (match-string 2))))) | 847 | (file-name-as-directory (match-string 2))))) |
| 848 | 848 | ||
| @@ -884,7 +884,7 @@ Return new value of PROJECT." | |||
| 884 | 884 | ||
| 885 | (t | 885 | (t |
| 886 | ;; any other field in the file is just copied | 886 | ;; any other field in the file is just copied |
| 887 | (set 'project (plist-put project | 887 | (setq project (plist-put project |
| 888 | (intern (match-string 1)) | 888 | (intern (match-string 1)) |
| 889 | (match-string 2)))))) | 889 | (match-string 2)))))) |
| 890 | 890 | ||
| @@ -900,21 +900,21 @@ Return new value of PROJECT." | |||
| 900 | (let ((sep (plist-get project 'ada_project_path_sep))) | 900 | (let ((sep (plist-get project 'ada_project_path_sep))) |
| 901 | (setq ada_project_path (reverse ada_project_path)) | 901 | (setq ada_project_path (reverse ada_project_path)) |
| 902 | (setq ada_project_path (mapconcat 'identity ada_project_path sep)) | 902 | (setq ada_project_path (mapconcat 'identity ada_project_path sep)) |
| 903 | (set 'project (plist-put project 'ada_project_path ada_project_path)) | 903 | (setq project (plist-put project 'ada_project_path ada_project_path)) |
| 904 | ;; env var needed now for ada-gnat-parse-gpr | 904 | ;; env var needed now for ada-gnat-parse-gpr |
| 905 | (setenv "ADA_PROJECT_PATH" ada_project_path))) | 905 | (setenv "ADA_PROJECT_PATH" ada_project_path))) |
| 906 | 906 | ||
| 907 | (if debug_post_cmd (set 'project (plist-put project 'debug_post_cmd (reverse debug_post_cmd)))) | 907 | (if debug_post_cmd (setq project (plist-put project 'debug_post_cmd (reverse debug_post_cmd)))) |
| 908 | (if debug_pre_cmd (set 'project (plist-put project 'debug_pre_cmd (reverse debug_pre_cmd)))) | 908 | (if debug_pre_cmd (setq project (plist-put project 'debug_pre_cmd (reverse debug_pre_cmd)))) |
| 909 | (if casing (set 'project (plist-put project 'casing (reverse casing)))) | 909 | (if casing (setq project (plist-put project 'casing (reverse casing)))) |
| 910 | (if check_cmd (set 'project (plist-put project 'check_cmd (reverse check_cmd)))) | 910 | (if check_cmd (setq project (plist-put project 'check_cmd (reverse check_cmd)))) |
| 911 | (if comp_cmd (set 'project (plist-put project 'comp_cmd (reverse comp_cmd)))) | 911 | (if comp_cmd (setq project (plist-put project 'comp_cmd (reverse comp_cmd)))) |
| 912 | (if make_cmd (set 'project (plist-put project 'make_cmd (reverse make_cmd)))) | 912 | (if make_cmd (setq project (plist-put project 'make_cmd (reverse make_cmd)))) |
| 913 | (if run_cmd (set 'project (plist-put project 'run_cmd (reverse run_cmd)))) | 913 | (if run_cmd (setq project (plist-put project 'run_cmd (reverse run_cmd)))) |
| 914 | 914 | ||
| 915 | (if gpr_file | 915 | (if gpr_file |
| 916 | (progn | 916 | (progn |
| 917 | (set 'project (ada-gnat-parse-gpr project gpr_file)) | 917 | (setq project (ada-gnat-parse-gpr project gpr_file)) |
| 918 | ;; append Ada source and object directories to others from Emacs project file | 918 | ;; append Ada source and object directories to others from Emacs project file |
| 919 | (setq src_dir (append (plist-get project 'src_dir) src_dir)) | 919 | (setq src_dir (append (plist-get project 'src_dir) src_dir)) |
| 920 | (setq obj_dir (append (plist-get project 'obj_dir) obj_dir)) | 920 | (setq obj_dir (append (plist-get project 'obj_dir) obj_dir)) |
| @@ -930,8 +930,8 @@ Return new value of PROJECT." | |||
| 930 | (ada-initialize-runtime-library (or (ada-xref-get-project-field 'cross_prefix) "")) | 930 | (ada-initialize-runtime-library (or (ada-xref-get-project-field 'cross_prefix) "")) |
| 931 | ;;) | 931 | ;;) |
| 932 | 932 | ||
| 933 | (if obj_dir (set 'project (plist-put project 'obj_dir (reverse obj_dir)))) | 933 | (if obj_dir (setq project (plist-put project 'obj_dir (reverse obj_dir)))) |
| 934 | (if src_dir (set 'project (plist-put project 'src_dir (reverse src_dir)))) | 934 | (if src_dir (setq project (plist-put project 'src_dir (reverse src_dir)))) |
| 935 | 935 | ||
| 936 | project | 936 | project |
| 937 | )) | 937 | )) |
| @@ -1052,9 +1052,9 @@ existing buffer `*gnatfind*', if there is one." | |||
| 1052 | (if old-contents | 1052 | (if old-contents |
| 1053 | (progn | 1053 | (progn |
| 1054 | (goto-char 1) | 1054 | (goto-char 1) |
| 1055 | (set 'buffer-read-only nil) | 1055 | (setq buffer-read-only nil) |
| 1056 | (insert old-contents) | 1056 | (insert old-contents) |
| 1057 | (set 'buffer-read-only t) | 1057 | (setq buffer-read-only t) |
| 1058 | (goto-char (point-max))))) | 1058 | (goto-char (point-max))))) |
| 1059 | ) | 1059 | ) |
| 1060 | ) | 1060 | ) |
| @@ -1194,9 +1194,9 @@ project file." | |||
| 1194 | (objects (getenv "ADA_OBJECTS_PATH")) | 1194 | (objects (getenv "ADA_OBJECTS_PATH")) |
| 1195 | (build-dir (ada-xref-get-project-field 'build_dir))) | 1195 | (build-dir (ada-xref-get-project-field 'build_dir))) |
| 1196 | (if include | 1196 | (if include |
| 1197 | (set 'include (concat path-separator include))) | 1197 | (setq include (concat path-separator include))) |
| 1198 | (if objects | 1198 | (if objects |
| 1199 | (set 'objects (concat path-separator objects))) | 1199 | (setq objects (concat path-separator objects))) |
| 1200 | (cons | 1200 | (cons |
| 1201 | (concat "ADA_INCLUDE_PATH=" | 1201 | (concat "ADA_INCLUDE_PATH=" |
| 1202 | (mapconcat (lambda(x) (expand-file-name x build-dir)) | 1202 | (mapconcat (lambda(x) (expand-file-name x build-dir)) |
| @@ -1303,7 +1303,7 @@ If ARG is non-nil, ask for user confirmation." | |||
| 1303 | 1303 | ||
| 1304 | ;; Guess the command if it wasn't specified | 1304 | ;; Guess the command if it wasn't specified |
| 1305 | (if (not command) | 1305 | (if (not command) |
| 1306 | (set 'command (list (file-name-sans-extension (buffer-name))))) | 1306 | (setq command (list (file-name-sans-extension (buffer-name))))) |
| 1307 | 1307 | ||
| 1308 | ;; Modify the command to run remotely | 1308 | ;; Modify the command to run remotely |
| 1309 | (setq command (ada-remote (mapconcat 'identity command | 1309 | (setq command (ada-remote (mapconcat 'identity command |
| @@ -1316,7 +1316,7 @@ If ARG is non-nil, ask for user confirmation." | |||
| 1316 | 1316 | ||
| 1317 | ;; Run the command | 1317 | ;; Run the command |
| 1318 | (with-current-buffer (get-buffer-create "*run*") | 1318 | (with-current-buffer (get-buffer-create "*run*") |
| 1319 | (set 'buffer-read-only nil) | 1319 | (setq buffer-read-only nil) |
| 1320 | 1320 | ||
| 1321 | (erase-buffer) | 1321 | (erase-buffer) |
| 1322 | (start-process "run" (current-buffer) shell-file-name | 1322 | (start-process "run" (current-buffer) shell-file-name |
| @@ -1352,7 +1352,7 @@ project file." | |||
| 1352 | 1352 | ||
| 1353 | ;; If the command was not given in the project file, start a bare gdb | 1353 | ;; If the command was not given in the project file, start a bare gdb |
| 1354 | (if (not cmd) | 1354 | (if (not cmd) |
| 1355 | (set 'cmd (concat ada-prj-default-debugger | 1355 | (setq cmd (concat ada-prj-default-debugger |
| 1356 | " " | 1356 | " " |
| 1357 | (or executable-name | 1357 | (or executable-name |
| 1358 | (file-name-sans-extension (buffer-file-name)))))) | 1358 | (file-name-sans-extension (buffer-file-name)))))) |
| @@ -1368,18 +1368,18 @@ project file." | |||
| 1368 | ;; chance to fully manage it. Then it works fine with Enlightenment | 1368 | ;; chance to fully manage it. Then it works fine with Enlightenment |
| 1369 | ;; as well | 1369 | ;; as well |
| 1370 | (let ((frame (make-frame '((visibility . nil))))) | 1370 | (let ((frame (make-frame '((visibility . nil))))) |
| 1371 | (set 'cmd (concat | 1371 | (setq cmd (concat |
| 1372 | cmd " --editor-window=" | 1372 | cmd " --editor-window=" |
| 1373 | (cdr (assoc 'outer-window-id (frame-parameters frame))))) | 1373 | (cdr (assoc 'outer-window-id (frame-parameters frame))))) |
| 1374 | (select-frame frame))) | 1374 | (select-frame frame))) |
| 1375 | 1375 | ||
| 1376 | ;; Add a -fullname switch | 1376 | ;; Add a -fullname switch |
| 1377 | ;; Use the remote machine | 1377 | ;; Use the remote machine |
| 1378 | (set 'cmd (ada-remote (concat cmd " -fullname "))) | 1378 | (setq cmd (ada-remote (concat cmd " -fullname "))) |
| 1379 | 1379 | ||
| 1380 | ;; Ask for confirmation if required | 1380 | ;; Ask for confirmation if required |
| 1381 | (if (or arg ada-xref-confirm-compile) | 1381 | (if (or arg ada-xref-confirm-compile) |
| 1382 | (set 'cmd (read-from-minibuffer "enter command to debug: " cmd))) | 1382 | (setq cmd (read-from-minibuffer "enter command to debug: " cmd))) |
| 1383 | 1383 | ||
| 1384 | (let ((old-comint-exec (symbol-function 'comint-exec))) | 1384 | (let ((old-comint-exec (symbol-function 'comint-exec))) |
| 1385 | 1385 | ||
| @@ -1387,13 +1387,13 @@ project file." | |||
| 1387 | ;; FIXME: This is evil but luckily a nop under Emacs-21.3.50 ! -stef | 1387 | ;; FIXME: This is evil but luckily a nop under Emacs-21.3.50 ! -stef |
| 1388 | (fset 'gud-gdb-massage-args (lambda (_file args) args)) | 1388 | (fset 'gud-gdb-massage-args (lambda (_file args) args)) |
| 1389 | 1389 | ||
| 1390 | (set 'pre-cmd (mapconcat 'identity pre-cmd ada-command-separator)) | 1390 | (setq pre-cmd (mapconcat 'identity pre-cmd ada-command-separator)) |
| 1391 | (if (not (equal pre-cmd "")) | 1391 | (if (not (equal pre-cmd "")) |
| 1392 | (setq pre-cmd (concat pre-cmd ada-command-separator))) | 1392 | (setq pre-cmd (concat pre-cmd ada-command-separator))) |
| 1393 | 1393 | ||
| 1394 | (set 'post-cmd (mapconcat 'identity post-cmd "\n")) | 1394 | (setq post-cmd (mapconcat 'identity post-cmd "\n")) |
| 1395 | (if post-cmd | 1395 | (if post-cmd |
| 1396 | (set 'post-cmd (concat post-cmd "\n"))) | 1396 | (setq post-cmd (concat post-cmd "\n"))) |
| 1397 | 1397 | ||
| 1398 | 1398 | ||
| 1399 | ;; Temporarily replaces the definition of `comint-exec' so that we | 1399 | ;; Temporarily replaces the definition of `comint-exec' so that we |
| @@ -1403,7 +1403,7 @@ project file." | |||
| 1403 | `(lambda (buffer name command startfile switches) | 1403 | `(lambda (buffer name command startfile switches) |
| 1404 | (let (compilation-buffer-name-function) | 1404 | (let (compilation-buffer-name-function) |
| 1405 | (save-excursion | 1405 | (save-excursion |
| 1406 | (set 'compilation-buffer-name-function | 1406 | (setq compilation-buffer-name-function |
| 1407 | (lambda(x) (buffer-name buffer))) | 1407 | (lambda(x) (buffer-name buffer))) |
| 1408 | (compile (ada-quote-cmd | 1408 | (compile (ada-quote-cmd |
| 1409 | (concat ,pre-cmd | 1409 | (concat ,pre-cmd |
| @@ -1498,12 +1498,12 @@ by replacing the file extension with `.ali'." | |||
| 1498 | "Search for FILE in DIR-LIST." | 1498 | "Search for FILE in DIR-LIST." |
| 1499 | (let (found) | 1499 | (let (found) |
| 1500 | (while (and (not found) dir-list) | 1500 | (while (and (not found) dir-list) |
| 1501 | (set 'found (concat (file-name-as-directory (car dir-list)) | 1501 | (setq found (concat (file-name-as-directory (car dir-list)) |
| 1502 | (file-name-nondirectory file))) | 1502 | (file-name-nondirectory file))) |
| 1503 | 1503 | ||
| 1504 | (unless (file-exists-p found) | 1504 | (unless (file-exists-p found) |
| 1505 | (set 'found nil)) | 1505 | (setq found nil)) |
| 1506 | (set 'dir-list (cdr dir-list))) | 1506 | (setq dir-list (cdr dir-list))) |
| 1507 | found)) | 1507 | found)) |
| 1508 | 1508 | ||
| 1509 | (defun ada-find-ali-file-in-dir (file) | 1509 | (defun ada-find-ali-file-in-dir (file) |
| @@ -1558,11 +1558,11 @@ the project file." | |||
| 1558 | (while specs | 1558 | (while specs |
| 1559 | (if (string-match (concat (regexp-quote (car specs)) "$") | 1559 | (if (string-match (concat (regexp-quote (car specs)) "$") |
| 1560 | file) | 1560 | file) |
| 1561 | (set 'is-spec t)) | 1561 | (setq is-spec t)) |
| 1562 | (set 'specs (cdr specs))))) | 1562 | (setq specs (cdr specs))))) |
| 1563 | 1563 | ||
| 1564 | (if is-spec | 1564 | (if is-spec |
| 1565 | (set 'ali-file-name | 1565 | (setq ali-file-name |
| 1566 | (ada-find-ali-file-in-dir | 1566 | (ada-find-ali-file-in-dir |
| 1567 | (concat (file-name-base (ada-other-file-name)) ".ali")))) | 1567 | (concat (file-name-base (ada-other-file-name)) ".ali")))) |
| 1568 | 1568 | ||
| @@ -1589,8 +1589,8 @@ the project file." | |||
| 1589 | (while (and (not ali-file-name) | 1589 | (while (and (not ali-file-name) |
| 1590 | (string-match "^\\(.*\\)[.-][^.-]*" parent-name)) | 1590 | (string-match "^\\(.*\\)[.-][^.-]*" parent-name)) |
| 1591 | 1591 | ||
| 1592 | (set 'parent-name (match-string 1 parent-name)) | 1592 | (setq parent-name (match-string 1 parent-name)) |
| 1593 | (set 'ali-file-name (ada-find-ali-file-in-dir | 1593 | (setq ali-file-name (ada-find-ali-file-in-dir |
| 1594 | (concat parent-name ".ali"))) | 1594 | (concat parent-name ".ali"))) |
| 1595 | ) | 1595 | ) |
| 1596 | ali-file-name))) | 1596 | ali-file-name))) |
| @@ -1686,18 +1686,18 @@ macros `ada-name-of', `ada-line-of', `ada-column-of', `ada-file-of',..." | |||
| 1686 | (if (and (= (char-before) ?\") | 1686 | (if (and (= (char-before) ?\") |
| 1687 | (= (char-after (+ (length (match-string 0)) (point))) ?\")) | 1687 | (= (char-after (+ (length (match-string 0)) (point))) ?\")) |
| 1688 | (forward-char -1)) | 1688 | (forward-char -1)) |
| 1689 | (set 'identifier (regexp-quote (concat "\"" (match-string 0) "\"")))) | 1689 | (setq identifier (regexp-quote (concat "\"" (match-string 0) "\"")))) |
| 1690 | 1690 | ||
| 1691 | (if (ada-in-string-p) | 1691 | (if (ada-in-string-p) |
| 1692 | (error "Inside string or character constant")) | 1692 | (error "Inside string or character constant")) |
| 1693 | (if (looking-at (concat ada-keywords "[^a-zA-Z_]")) | 1693 | (if (looking-at (concat ada-keywords "[^a-zA-Z_]")) |
| 1694 | (error "No cross-reference available for reserved keyword")) | 1694 | (error "No cross-reference available for reserved keyword")) |
| 1695 | (if (looking-at "[a-zA-Z0-9_]+") | 1695 | (if (looking-at "[a-zA-Z0-9_]+") |
| 1696 | (set 'identifier (match-string 0)) | 1696 | (setq identifier (match-string 0)) |
| 1697 | (error "No identifier around"))) | 1697 | (error "No identifier around"))) |
| 1698 | 1698 | ||
| 1699 | ;; Build the identlist | 1699 | ;; Build the identlist |
| 1700 | (set 'identlist (ada-make-identlist)) | 1700 | (setq identlist (ada-make-identlist)) |
| 1701 | (ada-set-name identlist (downcase identifier)) | 1701 | (ada-set-name identlist (downcase identifier)) |
| 1702 | (ada-set-line identlist | 1702 | (ada-set-line identlist |
| 1703 | (number-to-string (count-lines 1 (point)))) | 1703 | (number-to-string (count-lines 1 (point)))) |
| @@ -1725,7 +1725,7 @@ Information is extracted from the ali file." | |||
| 1725 | (concat "^X [0-9]+ " (file-name-nondirectory (ada-file-of identlist))) | 1725 | (concat "^X [0-9]+ " (file-name-nondirectory (ada-file-of identlist))) |
| 1726 | nil t) | 1726 | nil t) |
| 1727 | (let ((bound (save-excursion (re-search-forward "^X " nil t)))) | 1727 | (let ((bound (save-excursion (re-search-forward "^X " nil t)))) |
| 1728 | (set 'declaration-found | 1728 | (setq declaration-found |
| 1729 | (re-search-forward | 1729 | (re-search-forward |
| 1730 | (concat "^" (ada-line-of identlist) | 1730 | (concat "^" (ada-line-of identlist) |
| 1731 | "." (ada-column-of identlist) | 1731 | "." (ada-column-of identlist) |
| @@ -1743,7 +1743,7 @@ Information is extracted from the ali file." | |||
| 1743 | ;; Since we already know the number of the file, search for a direct | 1743 | ;; Since we already know the number of the file, search for a direct |
| 1744 | ;; reference to it | 1744 | ;; reference to it |
| 1745 | (goto-char (point-min)) | 1745 | (goto-char (point-min)) |
| 1746 | (set 'declaration-found t) | 1746 | (setq declaration-found t) |
| 1747 | (ada-set-ali-index | 1747 | (ada-set-ali-index |
| 1748 | identlist | 1748 | identlist |
| 1749 | (number-to-string (ada-find-file-number-in-ali | 1749 | (number-to-string (ada-find-file-number-in-ali |
| @@ -1771,7 +1771,7 @@ Information is extracted from the ali file." | |||
| 1771 | ;; If still not found, then either the declaration is unknown | 1771 | ;; If still not found, then either the declaration is unknown |
| 1772 | ;; or the source file has been modified since the ali file was | 1772 | ;; or the source file has been modified since the ali file was |
| 1773 | ;; created | 1773 | ;; created |
| 1774 | (set 'declaration-found nil) | 1774 | (setq declaration-found nil) |
| 1775 | ) | 1775 | ) |
| 1776 | ) | 1776 | ) |
| 1777 | 1777 | ||
| @@ -1786,7 +1786,7 @@ Information is extracted from the ali file." | |||
| 1786 | (beginning-of-line)) | 1786 | (beginning-of-line)) |
| 1787 | (unless (looking-at (concat "[0-9]+.[0-9]+[ *]" | 1787 | (unless (looking-at (concat "[0-9]+.[0-9]+[ *]" |
| 1788 | (ada-name-of identlist) "[ <{=\(\[]")) | 1788 | (ada-name-of identlist) "[ <{=\(\[]")) |
| 1789 | (set 'declaration-found nil)))) | 1789 | (setq declaration-found nil)))) |
| 1790 | 1790 | ||
| 1791 | ;; Still no success ! The ali file must be too old, and we need to | 1791 | ;; Still no success ! The ali file must be too old, and we need to |
| 1792 | ;; use a basic algorithm based on guesses. Note that this only happens | 1792 | ;; use a basic algorithm based on guesses. Note that this only happens |
| @@ -1794,7 +1794,7 @@ Information is extracted from the ali file." | |||
| 1794 | ;; automatically | 1794 | ;; automatically |
| 1795 | (unless declaration-found | 1795 | (unless declaration-found |
| 1796 | (if (ada-xref-find-in-modified-ali identlist) | 1796 | (if (ada-xref-find-in-modified-ali identlist) |
| 1797 | (set 'declaration-found t) | 1797 | (setq declaration-found t) |
| 1798 | ;; No more idea to find the declaration. Give up | 1798 | ;; No more idea to find the declaration. Give up |
| 1799 | (progn | 1799 | (progn |
| 1800 | (kill-buffer ali-buffer) | 1800 | (kill-buffer ali-buffer) |
| @@ -1814,7 +1814,7 @@ Information is extracted from the ali file." | |||
| 1814 | (forward-line 1) | 1814 | (forward-line 1) |
| 1815 | (beginning-of-line) | 1815 | (beginning-of-line) |
| 1816 | (while (looking-at "^\\.\\(.*\\)") | 1816 | (while (looking-at "^\\.\\(.*\\)") |
| 1817 | (set 'current-line (concat current-line (match-string 1))) | 1817 | (setq current-line (concat current-line (match-string 1))) |
| 1818 | (forward-line 1)) | 1818 | (forward-line 1)) |
| 1819 | ) | 1819 | ) |
| 1820 | 1820 | ||
| @@ -1860,7 +1860,7 @@ This function is disabled for operators, and only works for identifiers." | |||
| 1860 | (goto-char (point-max)) | 1860 | (goto-char (point-max)) |
| 1861 | (while (re-search-backward my-regexp nil t) | 1861 | (while (re-search-backward my-regexp nil t) |
| 1862 | (save-excursion | 1862 | (save-excursion |
| 1863 | (set 'line-ali (count-lines 1 (point))) | 1863 | (setq line-ali (count-lines 1 (point))) |
| 1864 | (beginning-of-line) | 1864 | (beginning-of-line) |
| 1865 | ;; have a look at the line and column numbers | 1865 | ;; have a look at the line and column numbers |
| 1866 | (if (looking-at "^\\([0-9]+\\).\\([0-9]+\\)[ *]") | 1866 | (if (looking-at "^\\([0-9]+\\).\\([0-9]+\\)[ *]") |
| @@ -1948,7 +1948,7 @@ opens a new window to show the declaration." | |||
| 1948 | 1948 | ||
| 1949 | ;; Get all the possible locations | 1949 | ;; Get all the possible locations |
| 1950 | (string-match "^\\([0-9]+\\)[a-zA-Z+*]\\([0-9]+\\)[ *]" ali-line) | 1950 | (string-match "^\\([0-9]+\\)[a-zA-Z+*]\\([0-9]+\\)[ *]" ali-line) |
| 1951 | (set 'locations (list (list (match-string 1 ali-line) ;; line | 1951 | (setq locations (list (list (match-string 1 ali-line) ;; line |
| 1952 | (match-string 2 ali-line) ;; column | 1952 | (match-string 2 ali-line) ;; column |
| 1953 | (ada-declare-file-of identlist)))) | 1953 | (ada-declare-file-of identlist)))) |
| 1954 | (while (string-match "\\([0-9]+\\)[bc]\\(<[^>]+>\\)?\\([0-9]+\\)" | 1954 | (while (string-match "\\([0-9]+\\)[bc]\\(<[^>]+>\\)?\\([0-9]+\\)" |
| @@ -1968,16 +1968,16 @@ opens a new window to show the declaration." | |||
| 1968 | (goto-char (point-min)) | 1968 | (goto-char (point-min)) |
| 1969 | (re-search-forward "^D \\([a-zA-Z0-9_.-]+\\)" nil t | 1969 | (re-search-forward "^D \\([a-zA-Z0-9_.-]+\\)" nil t |
| 1970 | (string-to-number file-number)) | 1970 | (string-to-number file-number)) |
| 1971 | (set 'file (match-string 1)) | 1971 | (setq file (match-string 1)) |
| 1972 | ) | 1972 | ) |
| 1973 | ;; Else get the nearest file | 1973 | ;; Else get the nearest file |
| 1974 | (set 'file (ada-declare-file-of identlist))) | 1974 | (setq file (ada-declare-file-of identlist))) |
| 1975 | 1975 | ||
| 1976 | (set 'locations (append locations (list (list line col file))))) | 1976 | (setq locations (append locations (list (list line col file))))) |
| 1977 | 1977 | ||
| 1978 | ;; Add the specs at the end again, so that from the last body we go to | 1978 | ;; Add the specs at the end again, so that from the last body we go to |
| 1979 | ;; the specs | 1979 | ;; the specs |
| 1980 | (set 'locations (append locations (list (car locations)))) | 1980 | (setq locations (append locations (list (car locations)))) |
| 1981 | 1981 | ||
| 1982 | ;; Find the new location we want to go to. | 1982 | ;; Find the new location we want to go to. |
| 1983 | ;; If we are on none of the locations listed, we simply go to the specs. | 1983 | ;; If we are on none of the locations listed, we simply go to the specs. |
| @@ -1996,10 +1996,10 @@ opens a new window to show the declaration." | |||
| 1996 | col (nth 1 locations) | 1996 | col (nth 1 locations) |
| 1997 | file (nth 2 locations) | 1997 | file (nth 2 locations) |
| 1998 | locations nil) | 1998 | locations nil) |
| 1999 | (set 'locations (cdr locations)))) | 1999 | (setq locations (cdr locations)))) |
| 2000 | 2000 | ||
| 2001 | ;; Find the file in the source path | 2001 | ;; Find the file in the source path |
| 2002 | (set 'file (ada-get-ada-file-name file (ada-file-of identlist))) | 2002 | (setq file (ada-get-ada-file-name file (ada-file-of identlist))) |
| 2003 | 2003 | ||
| 2004 | ;; Kill the .ali buffer | 2004 | ;; Kill the .ali buffer |
| 2005 | (kill-buffer (current-buffer)) | 2005 | (kill-buffer (current-buffer)) |
| @@ -2044,10 +2044,10 @@ the declaration and documentation of the subprograms one is using." | |||
| 2044 | " " | 2044 | " " |
| 2045 | (shell-quote-argument (file-name-as-directory (car dirs))) | 2045 | (shell-quote-argument (file-name-as-directory (car dirs))) |
| 2046 | "*.ali"))) | 2046 | "*.ali"))) |
| 2047 | (set 'dirs (cdr dirs))) | 2047 | (setq dirs (cdr dirs))) |
| 2048 | 2048 | ||
| 2049 | ;; Now parse the output | 2049 | ;; Now parse the output |
| 2050 | (set 'case-fold-search t) | 2050 | (setq case-fold-search t) |
| 2051 | (goto-char (point-min)) | 2051 | (goto-char (point-min)) |
| 2052 | (while (re-search-forward regexp nil t) | 2052 | (while (re-search-forward regexp nil t) |
| 2053 | (save-excursion | 2053 | (save-excursion |
| @@ -2058,12 +2058,12 @@ the declaration and documentation of the subprograms one is using." | |||
| 2058 | (setq line (match-string 1) | 2058 | (setq line (match-string 1) |
| 2059 | column (match-string 2)) | 2059 | column (match-string 2)) |
| 2060 | (re-search-backward "^X [0-9]+ \\(.*\\)$") | 2060 | (re-search-backward "^X [0-9]+ \\(.*\\)$") |
| 2061 | (set 'file (list (match-string 1) line column)) | 2061 | (setq file (list (match-string 1) line column)) |
| 2062 | 2062 | ||
| 2063 | ;; There could be duplicate choices, because of the structure | 2063 | ;; There could be duplicate choices, because of the structure |
| 2064 | ;; of the .ali files | 2064 | ;; of the .ali files |
| 2065 | (unless (member file list) | 2065 | (unless (member file list) |
| 2066 | (set 'list (append list (list file)))))))) | 2066 | (setq list (append list (list file)))))))) |
| 2067 | 2067 | ||
| 2068 | ;; Current buffer is still "*grep*" | 2068 | ;; Current buffer is still "*grep*" |
| 2069 | (kill-buffer "*grep*") | 2069 | (kill-buffer "*grep*") |
| @@ -2078,7 +2078,7 @@ the declaration and documentation of the subprograms one is using." | |||
| 2078 | 2078 | ||
| 2079 | ;; Only one choice => Do the cross-reference | 2079 | ;; Only one choice => Do the cross-reference |
| 2080 | ((= (length list) 1) | 2080 | ((= (length list) 1) |
| 2081 | (set 'file (ada-find-src-file-in-dir (caar list))) | 2081 | (setq file (ada-find-src-file-in-dir (caar list))) |
| 2082 | (if file | 2082 | (if file |
| 2083 | (ada-xref-change-buffer file | 2083 | (ada-xref-change-buffer file |
| 2084 | (string-to-number (nth 1 (car list))) | 2084 | (string-to-number (nth 1 (car list))) |
| @@ -2117,10 +2117,10 @@ the declaration and documentation of the subprograms one is using." | |||
| 2117 | (string-to-number | 2117 | (string-to-number |
| 2118 | (read-from-minibuffer "Enter No. of your choice: ")))) | 2118 | (read-from-minibuffer "Enter No. of your choice: ")))) |
| 2119 | ) | 2119 | ) |
| 2120 | (set 'choice (1- choice)) | 2120 | (setq choice (1- choice)) |
| 2121 | (kill-buffer "*choice list*") | 2121 | (kill-buffer "*choice list*") |
| 2122 | 2122 | ||
| 2123 | (set 'file (ada-find-src-file-in-dir (car (nth choice list)))) | 2123 | (setq file (ada-find-src-file-in-dir (car (nth choice list)))) |
| 2124 | (if file | 2124 | (if file |
| 2125 | (ada-xref-change-buffer file | 2125 | (ada-xref-change-buffer file |
| 2126 | (string-to-number (nth 1 (nth choice list))) | 2126 | (string-to-number (nth 1 (nth choice list))) |
| @@ -2144,7 +2144,7 @@ If OTHER-FRAME is non-nil, creates a new frame to show the file." | |||
| 2144 | (if ada-xref-other-buffer | 2144 | (if ada-xref-other-buffer |
| 2145 | (if other-frame | 2145 | (if other-frame |
| 2146 | (find-file-other-frame file) | 2146 | (find-file-other-frame file) |
| 2147 | (set 'declaration-buffer (find-file-noselect file)) | 2147 | (setq declaration-buffer (find-file-noselect file)) |
| 2148 | (set-buffer declaration-buffer) | 2148 | (set-buffer declaration-buffer) |
| 2149 | (switch-to-buffer-other-window declaration-buffer) | 2149 | (switch-to-buffer-other-window declaration-buffer) |
| 2150 | ) | 2150 | ) |
diff --git a/lisp/progmodes/antlr-mode.el b/lisp/progmodes/antlr-mode.el index 56680f23a8e..bf90db54002 100644 --- a/lisp/progmodes/antlr-mode.el +++ b/lisp/progmodes/antlr-mode.el | |||
| @@ -178,10 +178,6 @@ | |||
| 178 | (set-buffer-modified-p nil))))))) | 178 | (set-buffer-modified-p nil))))))) |
| 179 | (put 'save-buffer-state-x 'lisp-indent-function 0) | 179 | (put 'save-buffer-state-x 'lisp-indent-function 0) |
| 180 | 180 | ||
| 181 | ;; get rid of byte-compile warnings | ||
| 182 | (eval-when-compile | ||
| 183 | (require 'cc-mode)) | ||
| 184 | |||
| 185 | (defvar outline-level) | 181 | (defvar outline-level) |
| 186 | (defvar imenu-use-markers) | 182 | (defvar imenu-use-markers) |
| 187 | (defvar imenu-create-index-function) | 183 | (defvar imenu-create-index-function) |
diff --git a/lisp/progmodes/bat-mode.el b/lisp/progmodes/bat-mode.el index 2b6f9d3434d..60b332170b0 100644 --- a/lisp/progmodes/bat-mode.el +++ b/lisp/progmodes/bat-mode.el | |||
| @@ -120,6 +120,7 @@ | |||
| 120 | (defvar bat-mode-syntax-table | 120 | (defvar bat-mode-syntax-table |
| 121 | (let ((table (make-syntax-table))) | 121 | (let ((table (make-syntax-table))) |
| 122 | (modify-syntax-entry ?\n ">" table) | 122 | (modify-syntax-entry ?\n ">" table) |
| 123 | (modify-syntax-entry ?\" "\"" table) | ||
| 123 | ;; Beware: `w' should not be used for non-alphabetic chars. | 124 | ;; Beware: `w' should not be used for non-alphabetic chars. |
| 124 | (modify-syntax-entry ?~ "_" table) | 125 | (modify-syntax-entry ?~ "_" table) |
| 125 | (modify-syntax-entry ?% "." table) | 126 | (modify-syntax-entry ?% "." table) |
diff --git a/lisp/progmodes/cc-awk.el b/lisp/progmodes/cc-awk.el index b5216b43ed9..3ef9730ecdb 100644 --- a/lisp/progmodes/cc-awk.el +++ b/lisp/progmodes/cc-awk.el | |||
| @@ -61,6 +61,7 @@ | |||
| 61 | (cc-bytecomp-defun c-backward-token-1) | 61 | (cc-bytecomp-defun c-backward-token-1) |
| 62 | (cc-bytecomp-defun c-beginning-of-statement-1) | 62 | (cc-bytecomp-defun c-beginning-of-statement-1) |
| 63 | (cc-bytecomp-defun c-backward-sws) | 63 | (cc-bytecomp-defun c-backward-sws) |
| 64 | (cc-bytecomp-defun c-forward-sws) | ||
| 64 | 65 | ||
| 65 | (defvar awk-mode-syntax-table | 66 | (defvar awk-mode-syntax-table |
| 66 | (let ((st (make-syntax-table))) | 67 | (let ((st (make-syntax-table))) |
diff --git a/lisp/progmodes/cc-bytecomp.el b/lisp/progmodes/cc-bytecomp.el index 337a5292417..c9835bbefe2 100644 --- a/lisp/progmodes/cc-bytecomp.el +++ b/lisp/progmodes/cc-bytecomp.el | |||
| @@ -244,7 +244,9 @@ Having cyclic cc-require's will result in infinite recursion. That's | |||
| 244 | somewhat intentional." | 244 | somewhat intentional." |
| 245 | `(progn | 245 | `(progn |
| 246 | (eval-when-compile | 246 | (eval-when-compile |
| 247 | (setq cc-bytecomp-noruntime-functions byte-compile-noruntime-functions) | 247 | (if (boundp 'byte-compile-noruntime-functions) ; in case load uncompiled |
| 248 | (setq cc-bytecomp-noruntime-functions | ||
| 249 | byte-compile-noruntime-functions)) | ||
| 248 | (cc-bytecomp-load (symbol-name ,cc-part))) | 250 | (cc-bytecomp-load (symbol-name ,cc-part))) |
| 249 | ;; Hack to suppress spurious "might not be defined at runtime" warnings. | 251 | ;; Hack to suppress spurious "might not be defined at runtime" warnings. |
| 250 | ;; The basic issue is that | 252 | ;; The basic issue is that |
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index b9345b2ae6a..c8a9c461a9d 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -6479,6 +6479,15 @@ comment at the start of cc-engine.el for more info." | |||
| 6479 | (c-go-list-forward) | 6479 | (c-go-list-forward) |
| 6480 | t))) | 6480 | t))) |
| 6481 | 6481 | ||
| 6482 | (defmacro c-pull-open-brace (ps) | ||
| 6483 | ;; Pull the next open brace from PS (which has the form of paren-state), | ||
| 6484 | ;; skipping over any brace pairs. Returns NIL when PS is exhausted. | ||
| 6485 | `(progn | ||
| 6486 | (while (consp (car ,ps)) | ||
| 6487 | (setq ,ps (cdr ,ps))) | ||
| 6488 | (prog1 (car ,ps) | ||
| 6489 | (setq ,ps (cdr ,ps))))) | ||
| 6490 | |||
| 6482 | (defun c-back-over-member-initializers () | 6491 | (defun c-back-over-member-initializers () |
| 6483 | ;; Test whether we are in a C++ member initializer list, and if so, go back | 6492 | ;; Test whether we are in a C++ member initializer list, and if so, go back |
| 6484 | ;; to the introducing ":", returning the position of the opening paren of | 6493 | ;; to the introducing ":", returning the position of the opening paren of |
| @@ -6896,32 +6905,38 @@ comment at the start of cc-engine.el for more info." | |||
| 6896 | 6905 | ||
| 6897 | ;; Skip over type decl prefix operators. (Note similar code in | 6906 | ;; Skip over type decl prefix operators. (Note similar code in |
| 6898 | ;; `c-font-lock-declarators'.) | 6907 | ;; `c-font-lock-declarators'.) |
| 6899 | (while (and (looking-at c-type-decl-prefix-key) | 6908 | (if (and c-recognize-typeless-decls |
| 6900 | (if (and (c-major-mode-is 'c++-mode) | 6909 | (equal c-type-decl-prefix-key "\\<\\>")) |
| 6901 | (match-beginning 3)) | 6910 | (when (eq (char-after) ?\() |
| 6902 | ;; If the third submatch matches in C++ then | ||
| 6903 | ;; we're looking at an identifier that's a | ||
| 6904 | ;; prefix only if it specifies a member pointer. | ||
| 6905 | (when (setq got-identifier (c-forward-name)) | ||
| 6906 | (if (looking-at "\\(::\\)") | ||
| 6907 | ;; We only check for a trailing "::" and | ||
| 6908 | ;; let the "*" that should follow be | ||
| 6909 | ;; matched in the next round. | ||
| 6910 | (progn (setq got-identifier nil) t) | ||
| 6911 | ;; It turned out to be the real identifier, | ||
| 6912 | ;; so stop. | ||
| 6913 | nil)) | ||
| 6914 | t)) | ||
| 6915 | |||
| 6916 | (if (eq (char-after) ?\() | ||
| 6917 | (progn | 6911 | (progn |
| 6918 | (setq paren-depth (1+ paren-depth)) | 6912 | (setq paren-depth (1+ paren-depth)) |
| 6919 | (forward-char)) | 6913 | (forward-char))) |
| 6920 | (unless got-prefix-before-parens | 6914 | (while (and (looking-at c-type-decl-prefix-key) |
| 6921 | (setq got-prefix-before-parens (= paren-depth 0))) | 6915 | (if (and (c-major-mode-is 'c++-mode) |
| 6922 | (setq got-prefix t) | 6916 | (match-beginning 3)) |
| 6923 | (goto-char (match-end 1))) | 6917 | ;; If the third submatch matches in C++ then |
| 6924 | (c-forward-syntactic-ws)) | 6918 | ;; we're looking at an identifier that's a |
| 6919 | ;; prefix only if it specifies a member pointer. | ||
| 6920 | (when (setq got-identifier (c-forward-name)) | ||
| 6921 | (if (looking-at "\\(::\\)") | ||
| 6922 | ;; We only check for a trailing "::" and | ||
| 6923 | ;; let the "*" that should follow be | ||
| 6924 | ;; matched in the next round. | ||
| 6925 | (progn (setq got-identifier nil) t) | ||
| 6926 | ;; It turned out to be the real identifier, | ||
| 6927 | ;; so stop. | ||
| 6928 | nil)) | ||
| 6929 | t)) | ||
| 6930 | |||
| 6931 | (if (eq (char-after) ?\() | ||
| 6932 | (progn | ||
| 6933 | (setq paren-depth (1+ paren-depth)) | ||
| 6934 | (forward-char)) | ||
| 6935 | (unless got-prefix-before-parens | ||
| 6936 | (setq got-prefix-before-parens (= paren-depth 0))) | ||
| 6937 | (setq got-prefix t) | ||
| 6938 | (goto-char (match-end 1))) | ||
| 6939 | (c-forward-syntactic-ws))) | ||
| 6925 | 6940 | ||
| 6926 | (setq got-parens (> paren-depth 0)) | 6941 | (setq got-parens (> paren-depth 0)) |
| 6927 | 6942 | ||
| @@ -8403,15 +8418,6 @@ comment at the start of cc-engine.el for more info." | |||
| 8403 | (back-to-indentation) | 8418 | (back-to-indentation) |
| 8404 | (vector (point) open-paren-pos)))))) | 8419 | (vector (point) open-paren-pos)))))) |
| 8405 | 8420 | ||
| 8406 | (defmacro c-pull-open-brace (ps) | ||
| 8407 | ;; Pull the next open brace from PS (which has the form of paren-state), | ||
| 8408 | ;; skipping over any brace pairs. Returns NIL when PS is exhausted. | ||
| 8409 | `(progn | ||
| 8410 | (while (consp (car ,ps)) | ||
| 8411 | (setq ,ps (cdr ,ps))) | ||
| 8412 | (prog1 (car ,ps) | ||
| 8413 | (setq ,ps (cdr ,ps))))) | ||
| 8414 | |||
| 8415 | (defun c-most-enclosing-decl-block (paren-state) | 8421 | (defun c-most-enclosing-decl-block (paren-state) |
| 8416 | ;; Return the buffer position of the most enclosing decl-block brace (in the | 8422 | ;; Return the buffer position of the most enclosing decl-block brace (in the |
| 8417 | ;; sense of c-looking-at-decl-block) in the PAREN-STATE structure, or nil if | 8423 | ;; sense of c-looking-at-decl-block) in the PAREN-STATE structure, or nil if |
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 0116e9ec3dd..80e6189822b 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el | |||
| @@ -2816,7 +2816,8 @@ is in effect when this is matched (see `c-identifier-syntax-table')." | |||
| 2816 | "\\>") | 2816 | "\\>") |
| 2817 | "") | 2817 | "") |
| 2818 | "\\)") | 2818 | "\\)") |
| 2819 | (java idl) "\\([\[\(]\\)") | 2819 | java "\\([\[\(\)]\\)" |
| 2820 | idl "\\([\[\(]\\)") | ||
| 2820 | (c-lang-defvar c-type-decl-suffix-key (c-lang-const c-type-decl-suffix-key) | 2821 | (c-lang-defvar c-type-decl-suffix-key (c-lang-const c-type-decl-suffix-key) |
| 2821 | 'dont-doc) | 2822 | 'dont-doc) |
| 2822 | 2823 | ||
| @@ -2937,7 +2938,7 @@ calls before a brace block. This setting does not affect declarations | |||
| 2937 | that are preceded by a declaration starting keyword, so | 2938 | that are preceded by a declaration starting keyword, so |
| 2938 | e.g. `c-typeless-decl-kwds' may still be used when it's set to nil." | 2939 | e.g. `c-typeless-decl-kwds' may still be used when it's set to nil." |
| 2939 | t nil | 2940 | t nil |
| 2940 | (c c++ objc) t) | 2941 | (c c++ objc java) t) |
| 2941 | (c-lang-defvar c-recognize-typeless-decls | 2942 | (c-lang-defvar c-recognize-typeless-decls |
| 2942 | (c-lang-const c-recognize-typeless-decls)) | 2943 | (c-lang-const c-recognize-typeless-decls)) |
| 2943 | 2944 | ||
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 74818b7e1ea..4c776290722 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -217,12 +217,16 @@ control). See \"cc-mode.el\" for more info." | |||
| 217 | (t (error "CC Mode is incompatible with this version of Emacs"))) | 217 | (t (error "CC Mode is incompatible with this version of Emacs"))) |
| 218 | map)) | 218 | map)) |
| 219 | 219 | ||
| 220 | (defun c-define-abbrev-table (name defs) | 220 | (defun c-define-abbrev-table (name defs &optional doc) |
| 221 | ;; Compatibility wrapper for `define-abbrev' which passes a non-nil | 221 | ;; Compatibility wrapper for `define-abbrev' which passes a non-nil |
| 222 | ;; sixth argument for SYSTEM-FLAG in emacsen that support it | 222 | ;; sixth argument for SYSTEM-FLAG in emacsen that support it |
| 223 | ;; (currently only Emacs >= 21.2). | 223 | ;; (currently only Emacs >= 21.2). |
| 224 | (let ((table (or (symbol-value name) | 224 | (let ((table (or (and (boundp name) (symbol-value name)) |
| 225 | (progn (define-abbrev-table name nil) | 225 | (progn (condition-case nil |
| 226 | (define-abbrev-table name nil doc) | ||
| 227 | (wrong-number-of-arguments ;E.g. Emacs<23. | ||
| 228 | (eval `(defvar ,name nil ,doc)) | ||
| 229 | (define-abbrev-table name nil))) | ||
| 226 | (symbol-value name))))) | 230 | (symbol-value name))))) |
| 227 | (while defs | 231 | (while defs |
| 228 | (condition-case nil | 232 | (condition-case nil |
| @@ -1241,27 +1245,22 @@ This function is called from `c-common-init', once per mode initialization." | |||
| 1241 | 1245 | ||
| 1242 | ;; Support for C | 1246 | ;; Support for C |
| 1243 | 1247 | ||
| 1244 | ;;;###autoload | 1248 | (defvar c-mode-syntax-table |
| 1245 | (defvar c-mode-syntax-table nil | 1249 | (funcall (c-lang-const c-make-mode-syntax-table c)) |
| 1246 | "Syntax table used in c-mode buffers.") | 1250 | "Syntax table used in c-mode buffers.") |
| 1247 | (or c-mode-syntax-table | ||
| 1248 | (setq c-mode-syntax-table | ||
| 1249 | (funcall (c-lang-const c-make-mode-syntax-table c)))) | ||
| 1250 | 1251 | ||
| 1251 | (defvar c-mode-abbrev-table nil | ||
| 1252 | "Abbreviation table used in c-mode buffers.") | ||
| 1253 | (c-define-abbrev-table 'c-mode-abbrev-table | 1252 | (c-define-abbrev-table 'c-mode-abbrev-table |
| 1254 | '(("else" "else" c-electric-continued-statement 0) | 1253 | '(("else" "else" c-electric-continued-statement 0) |
| 1255 | ("while" "while" c-electric-continued-statement 0))) | 1254 | ("while" "while" c-electric-continued-statement 0)) |
| 1255 | "Abbreviation table used in c-mode buffers.") | ||
| 1256 | 1256 | ||
| 1257 | (defvar c-mode-map () | 1257 | (defvar c-mode-map |
| 1258 | (let ((map (c-make-inherited-keymap))) | ||
| 1259 | ;; Add bindings which are only useful for C. | ||
| 1260 | (define-key map "\C-c\C-e" 'c-macro-expand) | ||
| 1261 | map) | ||
| 1258 | "Keymap used in c-mode buffers.") | 1262 | "Keymap used in c-mode buffers.") |
| 1259 | (if c-mode-map | 1263 | |
| 1260 | nil | ||
| 1261 | (setq c-mode-map (c-make-inherited-keymap)) | ||
| 1262 | ;; add bindings which are only useful for C | ||
| 1263 | (define-key c-mode-map "\C-c\C-e" 'c-macro-expand) | ||
| 1264 | ) | ||
| 1265 | 1264 | ||
| 1266 | (easy-menu-define c-c-menu c-mode-map "C Mode Commands" | 1265 | (easy-menu-define c-c-menu c-mode-map "C Mode Commands" |
| 1267 | (cons "C" (c-lang-const c-mode-menu c))) | 1266 | (cons "C" (c-lang-const c-mode-menu c))) |
| @@ -1326,30 +1325,25 @@ Key bindings: | |||
| 1326 | 1325 | ||
| 1327 | ;; Support for C++ | 1326 | ;; Support for C++ |
| 1328 | 1327 | ||
| 1329 | ;;;###autoload | 1328 | (defvar c++-mode-syntax-table |
| 1330 | (defvar c++-mode-syntax-table nil | 1329 | (funcall (c-lang-const c-make-mode-syntax-table c++)) |
| 1331 | "Syntax table used in c++-mode buffers.") | 1330 | "Syntax table used in c++-mode buffers.") |
| 1332 | (or c++-mode-syntax-table | ||
| 1333 | (setq c++-mode-syntax-table | ||
| 1334 | (funcall (c-lang-const c-make-mode-syntax-table c++)))) | ||
| 1335 | 1331 | ||
| 1336 | (defvar c++-mode-abbrev-table nil | ||
| 1337 | "Abbreviation table used in c++-mode buffers.") | ||
| 1338 | (c-define-abbrev-table 'c++-mode-abbrev-table | 1332 | (c-define-abbrev-table 'c++-mode-abbrev-table |
| 1339 | '(("else" "else" c-electric-continued-statement 0) | 1333 | '(("else" "else" c-electric-continued-statement 0) |
| 1340 | ("while" "while" c-electric-continued-statement 0) | 1334 | ("while" "while" c-electric-continued-statement 0) |
| 1341 | ("catch" "catch" c-electric-continued-statement 0))) | 1335 | ("catch" "catch" c-electric-continued-statement 0)) |
| 1336 | "Abbreviation table used in c++-mode buffers.") | ||
| 1342 | 1337 | ||
| 1343 | (defvar c++-mode-map () | 1338 | (defvar c++-mode-map |
| 1339 | (let ((map (c-make-inherited-keymap))) | ||
| 1340 | ;; Add bindings which are only useful for C++. | ||
| 1341 | (define-key map "\C-c\C-e" 'c-macro-expand) | ||
| 1342 | (define-key map "\C-c:" 'c-scope-operator) | ||
| 1343 | (define-key map "<" 'c-electric-lt-gt) | ||
| 1344 | (define-key map ">" 'c-electric-lt-gt) | ||
| 1345 | map) | ||
| 1344 | "Keymap used in c++-mode buffers.") | 1346 | "Keymap used in c++-mode buffers.") |
| 1345 | (if c++-mode-map | ||
| 1346 | nil | ||
| 1347 | (setq c++-mode-map (c-make-inherited-keymap)) | ||
| 1348 | ;; add bindings which are only useful for C++ | ||
| 1349 | (define-key c++-mode-map "\C-c\C-e" 'c-macro-expand) | ||
| 1350 | (define-key c++-mode-map "\C-c:" 'c-scope-operator) | ||
| 1351 | (define-key c++-mode-map "<" 'c-electric-lt-gt) | ||
| 1352 | (define-key c++-mode-map ">" 'c-electric-lt-gt)) | ||
| 1353 | 1347 | ||
| 1354 | (easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands" | 1348 | (easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands" |
| 1355 | (cons "C++" (c-lang-const c-mode-menu c++))) | 1349 | (cons "C++" (c-lang-const c-mode-menu c++))) |
| @@ -1386,26 +1380,21 @@ Key bindings: | |||
| 1386 | 1380 | ||
| 1387 | ;; Support for Objective-C | 1381 | ;; Support for Objective-C |
| 1388 | 1382 | ||
| 1389 | ;;;###autoload | 1383 | (defvar objc-mode-syntax-table |
| 1390 | (defvar objc-mode-syntax-table nil | 1384 | (funcall (c-lang-const c-make-mode-syntax-table objc)) |
| 1391 | "Syntax table used in objc-mode buffers.") | 1385 | "Syntax table used in objc-mode buffers.") |
| 1392 | (or objc-mode-syntax-table | ||
| 1393 | (setq objc-mode-syntax-table | ||
| 1394 | (funcall (c-lang-const c-make-mode-syntax-table objc)))) | ||
| 1395 | 1386 | ||
| 1396 | (defvar objc-mode-abbrev-table nil | ||
| 1397 | "Abbreviation table used in objc-mode buffers.") | ||
| 1398 | (c-define-abbrev-table 'objc-mode-abbrev-table | 1387 | (c-define-abbrev-table 'objc-mode-abbrev-table |
| 1399 | '(("else" "else" c-electric-continued-statement 0) | 1388 | '(("else" "else" c-electric-continued-statement 0) |
| 1400 | ("while" "while" c-electric-continued-statement 0))) | 1389 | ("while" "while" c-electric-continued-statement 0)) |
| 1390 | "Abbreviation table used in objc-mode buffers.") | ||
| 1401 | 1391 | ||
| 1402 | (defvar objc-mode-map () | 1392 | (defvar objc-mode-map |
| 1393 | (let ((map (c-make-inherited-keymap))) | ||
| 1394 | ;; Add bindings which are only useful for Objective-C. | ||
| 1395 | (define-key map "\C-c\C-e" 'c-macro-expand) | ||
| 1396 | map) | ||
| 1403 | "Keymap used in objc-mode buffers.") | 1397 | "Keymap used in objc-mode buffers.") |
| 1404 | (if objc-mode-map | ||
| 1405 | nil | ||
| 1406 | (setq objc-mode-map (c-make-inherited-keymap)) | ||
| 1407 | ;; add bindings which are only useful for Objective-C | ||
| 1408 | (define-key objc-mode-map "\C-c\C-e" 'c-macro-expand)) | ||
| 1409 | 1398 | ||
| 1410 | (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands" | 1399 | (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands" |
| 1411 | (cons "ObjC" (c-lang-const c-mode-menu objc))) | 1400 | (cons "ObjC" (c-lang-const c-mode-menu objc))) |
| @@ -1444,28 +1433,22 @@ Key bindings: | |||
| 1444 | 1433 | ||
| 1445 | ;; Support for Java | 1434 | ;; Support for Java |
| 1446 | 1435 | ||
| 1447 | ;;;###autoload | 1436 | (defvar java-mode-syntax-table |
| 1448 | (defvar java-mode-syntax-table nil | 1437 | (funcall (c-lang-const c-make-mode-syntax-table java)) |
| 1449 | "Syntax table used in java-mode buffers.") | 1438 | "Syntax table used in java-mode buffers.") |
| 1450 | (or java-mode-syntax-table | ||
| 1451 | (setq java-mode-syntax-table | ||
| 1452 | (funcall (c-lang-const c-make-mode-syntax-table java)))) | ||
| 1453 | 1439 | ||
| 1454 | (defvar java-mode-abbrev-table nil | ||
| 1455 | "Abbreviation table used in java-mode buffers.") | ||
| 1456 | (c-define-abbrev-table 'java-mode-abbrev-table | 1440 | (c-define-abbrev-table 'java-mode-abbrev-table |
| 1457 | '(("else" "else" c-electric-continued-statement 0) | 1441 | '(("else" "else" c-electric-continued-statement 0) |
| 1458 | ("while" "while" c-electric-continued-statement 0) | 1442 | ("while" "while" c-electric-continued-statement 0) |
| 1459 | ("catch" "catch" c-electric-continued-statement 0) | 1443 | ("catch" "catch" c-electric-continued-statement 0) |
| 1460 | ("finally" "finally" c-electric-continued-statement 0))) | 1444 | ("finally" "finally" c-electric-continued-statement 0)) |
| 1445 | "Abbreviation table used in java-mode buffers.") | ||
| 1461 | 1446 | ||
| 1462 | (defvar java-mode-map () | 1447 | (defvar java-mode-map |
| 1448 | (let ((map (c-make-inherited-keymap))) | ||
| 1449 | ;; Add bindings which are only useful for Java. | ||
| 1450 | map) | ||
| 1463 | "Keymap used in java-mode buffers.") | 1451 | "Keymap used in java-mode buffers.") |
| 1464 | (if java-mode-map | ||
| 1465 | nil | ||
| 1466 | (setq java-mode-map (c-make-inherited-keymap)) | ||
| 1467 | ;; add bindings which are only useful for Java | ||
| 1468 | ) | ||
| 1469 | 1452 | ||
| 1470 | ;; Regexp trying to describe the beginning of a Java top-level | 1453 | ;; Regexp trying to describe the beginning of a Java top-level |
| 1471 | ;; definition. This is not used by CC Mode, nor is it maintained | 1454 | ;; definition. This is not used by CC Mode, nor is it maintained |
| @@ -1510,24 +1493,18 @@ Key bindings: | |||
| 1510 | 1493 | ||
| 1511 | ;; Support for CORBA's IDL language | 1494 | ;; Support for CORBA's IDL language |
| 1512 | 1495 | ||
| 1513 | ;;;###autoload | 1496 | (defvar idl-mode-syntax-table |
| 1514 | (defvar idl-mode-syntax-table nil | 1497 | (funcall (c-lang-const c-make-mode-syntax-table idl)) |
| 1515 | "Syntax table used in idl-mode buffers.") | 1498 | "Syntax table used in idl-mode buffers.") |
| 1516 | (or idl-mode-syntax-table | ||
| 1517 | (setq idl-mode-syntax-table | ||
| 1518 | (funcall (c-lang-const c-make-mode-syntax-table idl)))) | ||
| 1519 | 1499 | ||
| 1520 | (defvar idl-mode-abbrev-table nil | 1500 | (c-define-abbrev-table 'idl-mode-abbrev-table nil |
| 1521 | "Abbreviation table used in idl-mode buffers.") | 1501 | "Abbreviation table used in idl-mode buffers.") |
| 1522 | (c-define-abbrev-table 'idl-mode-abbrev-table nil) | ||
| 1523 | 1502 | ||
| 1524 | (defvar idl-mode-map () | 1503 | (defvar idl-mode-map |
| 1504 | (let ((map (c-make-inherited-keymap))) | ||
| 1505 | ;; Add bindings which are only useful for IDL. | ||
| 1506 | map) | ||
| 1525 | "Keymap used in idl-mode buffers.") | 1507 | "Keymap used in idl-mode buffers.") |
| 1526 | (if idl-mode-map | ||
| 1527 | nil | ||
| 1528 | (setq idl-mode-map (c-make-inherited-keymap)) | ||
| 1529 | ;; add bindings which are only useful for IDL | ||
| 1530 | ) | ||
| 1531 | 1508 | ||
| 1532 | (easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands" | 1509 | (easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands" |
| 1533 | (cons "IDL" (c-lang-const c-mode-menu idl))) | 1510 | (cons "IDL" (c-lang-const c-mode-menu idl))) |
| @@ -1564,32 +1541,27 @@ Key bindings: | |||
| 1564 | 1541 | ||
| 1565 | ;; Support for Pike | 1542 | ;; Support for Pike |
| 1566 | 1543 | ||
| 1567 | ;;;###autoload | 1544 | (defvar pike-mode-syntax-table |
| 1568 | (defvar pike-mode-syntax-table nil | 1545 | (funcall (c-lang-const c-make-mode-syntax-table pike)) |
| 1569 | "Syntax table used in pike-mode buffers.") | 1546 | "Syntax table used in pike-mode buffers.") |
| 1570 | (or pike-mode-syntax-table | ||
| 1571 | (setq pike-mode-syntax-table | ||
| 1572 | (funcall (c-lang-const c-make-mode-syntax-table pike)))) | ||
| 1573 | 1547 | ||
| 1574 | (defvar pike-mode-abbrev-table nil | ||
| 1575 | "Abbreviation table used in pike-mode buffers.") | ||
| 1576 | (c-define-abbrev-table 'pike-mode-abbrev-table | 1548 | (c-define-abbrev-table 'pike-mode-abbrev-table |
| 1577 | '(("else" "else" c-electric-continued-statement 0) | 1549 | '(("else" "else" c-electric-continued-statement 0) |
| 1578 | ("while" "while" c-electric-continued-statement 0))) | 1550 | ("while" "while" c-electric-continued-statement 0)) |
| 1551 | "Abbreviation table used in pike-mode buffers.") | ||
| 1579 | 1552 | ||
| 1580 | (defvar pike-mode-map () | 1553 | (defvar pike-mode-map |
| 1554 | (let ((map (c-make-inherited-keymap))) | ||
| 1555 | ;; Additional bindings. | ||
| 1556 | (define-key map "\C-c\C-e" 'c-macro-expand) | ||
| 1557 | map) | ||
| 1581 | "Keymap used in pike-mode buffers.") | 1558 | "Keymap used in pike-mode buffers.") |
| 1582 | (if pike-mode-map | ||
| 1583 | nil | ||
| 1584 | (setq pike-mode-map (c-make-inherited-keymap)) | ||
| 1585 | ;; additional bindings | ||
| 1586 | (define-key pike-mode-map "\C-c\C-e" 'c-macro-expand)) | ||
| 1587 | 1559 | ||
| 1588 | (easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands" | 1560 | (easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands" |
| 1589 | (cons "Pike" (c-lang-const c-mode-menu pike))) | 1561 | (cons "Pike" (c-lang-const c-mode-menu pike))) |
| 1590 | 1562 | ||
| 1591 | ;;;###autoload (add-to-list 'auto-mode-alist '("\\.\\(u?lpc\\|pike\\|pmod\\(\\.in\\)?\\)\\'" . pike-mode)) | 1563 | ;;;###autoload (add-to-list 'auto-mode-alist '("\\.\\(u?lpc\\|pike\\|pmod\\(\\.in\\)?\\)\\'" . pike-mode)) |
| 1592 | ;;;###autoload (add-to-list 'interpreter-mode-alist '("pike" . pike-mode)) | 1564 | ;;;###autoload (add-to-list 'interpreter-mode-alist '("\\`pike\\'" . pike-mode)) |
| 1593 | 1565 | ||
| 1594 | ;;;###autoload | 1566 | ;;;###autoload |
| 1595 | (define-derived-mode pike-mode prog-mode "Pike" | 1567 | (define-derived-mode pike-mode prog-mode "Pike" |
| @@ -1623,37 +1595,28 @@ Key bindings: | |||
| 1623 | ;; Support for AWK | 1595 | ;; Support for AWK |
| 1624 | 1596 | ||
| 1625 | ;;;###autoload (add-to-list 'auto-mode-alist '("\\.awk\\'" . awk-mode)) | 1597 | ;;;###autoload (add-to-list 'auto-mode-alist '("\\.awk\\'" . awk-mode)) |
| 1626 | ;;;###autoload (add-to-list 'interpreter-mode-alist '("awk" . awk-mode)) | 1598 | ;;;###autoload (add-to-list 'interpreter-mode-alist '("\\`[gmn]?awk\\'" . awk-mode)) |
| 1627 | ;;;###autoload (add-to-list 'interpreter-mode-alist '("mawk" . awk-mode)) | ||
| 1628 | ;;;###autoload (add-to-list 'interpreter-mode-alist '("nawk" . awk-mode)) | ||
| 1629 | ;;;###autoload (add-to-list 'interpreter-mode-alist '("gawk" . awk-mode)) | ||
| 1630 | |||
| 1631 | ;;; Autoload directives must be on the top level, so we construct an | ||
| 1632 | ;;; autoload form instead. | ||
| 1633 | ;;;###autoload (autoload 'awk-mode "cc-mode" "Major mode for editing AWK code." t) | ||
| 1634 | 1599 | ||
| 1635 | (defvar awk-mode-abbrev-table nil | ||
| 1636 | "Abbreviation table used in awk-mode buffers.") | ||
| 1637 | (c-define-abbrev-table 'awk-mode-abbrev-table | 1600 | (c-define-abbrev-table 'awk-mode-abbrev-table |
| 1638 | '(("else" "else" c-electric-continued-statement 0) | 1601 | '(("else" "else" c-electric-continued-statement 0) |
| 1639 | ("while" "while" c-electric-continued-statement 0))) | 1602 | ("while" "while" c-electric-continued-statement 0)) |
| 1603 | "Abbreviation table used in awk-mode buffers.") | ||
| 1640 | 1604 | ||
| 1641 | (defvar awk-mode-map () | 1605 | (defvar awk-mode-map |
| 1606 | (let ((map (c-make-inherited-keymap))) | ||
| 1607 | ;; Add bindings which are only useful for awk. | ||
| 1608 | (define-key map "#" 'self-insert-command) | ||
| 1609 | (define-key map "/" 'self-insert-command) | ||
| 1610 | (define-key map "*" 'self-insert-command) | ||
| 1611 | (define-key map "\C-c\C-n" 'undefined) ; #if doesn't exist in awk. | ||
| 1612 | (define-key map "\C-c\C-p" 'undefined) | ||
| 1613 | (define-key map "\C-c\C-u" 'undefined) | ||
| 1614 | (define-key map "\M-a" 'c-beginning-of-statement) ; 2003/10/7 | ||
| 1615 | (define-key map "\M-e" 'c-end-of-statement) ; 2003/10/7 | ||
| 1616 | (define-key map "\C-\M-a" 'c-awk-beginning-of-defun) | ||
| 1617 | (define-key map "\C-\M-e" 'c-awk-end-of-defun) | ||
| 1618 | map) | ||
| 1642 | "Keymap used in awk-mode buffers.") | 1619 | "Keymap used in awk-mode buffers.") |
| 1643 | (if awk-mode-map | ||
| 1644 | nil | ||
| 1645 | (setq awk-mode-map (c-make-inherited-keymap)) | ||
| 1646 | ;; add bindings which are only useful for awk. | ||
| 1647 | (define-key awk-mode-map "#" 'self-insert-command) | ||
| 1648 | (define-key awk-mode-map "/" 'self-insert-command) | ||
| 1649 | (define-key awk-mode-map "*" 'self-insert-command) | ||
| 1650 | (define-key awk-mode-map "\C-c\C-n" 'undefined) ; #if doesn't exist in awk. | ||
| 1651 | (define-key awk-mode-map "\C-c\C-p" 'undefined) | ||
| 1652 | (define-key awk-mode-map "\C-c\C-u" 'undefined) | ||
| 1653 | (define-key awk-mode-map "\M-a" 'c-beginning-of-statement) ; 2003/10/7 | ||
| 1654 | (define-key awk-mode-map "\M-e" 'c-end-of-statement) ; 2003/10/7 | ||
| 1655 | (define-key awk-mode-map "\C-\M-a" 'c-awk-beginning-of-defun) | ||
| 1656 | (define-key awk-mode-map "\C-\M-e" 'c-awk-end-of-defun)) | ||
| 1657 | 1620 | ||
| 1658 | (easy-menu-define c-awk-menu awk-mode-map "AWK Mode Commands" | 1621 | (easy-menu-define c-awk-menu awk-mode-map "AWK Mode Commands" |
| 1659 | (cons "AWK" (c-lang-const c-mode-menu awk))) | 1622 | (cons "AWK" (c-lang-const c-mode-menu awk))) |
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 770e78bb3b1..1eea6972707 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el | |||
| @@ -412,15 +412,15 @@ Affects: `cperl-font-lock', `cperl-electric-lbrace-space', | |||
| 412 | "use cperl-vc-rcs-header or cperl-vc-sccs-header instead." | 412 | "use cperl-vc-rcs-header or cperl-vc-sccs-header instead." |
| 413 | "22.1") | 413 | "22.1") |
| 414 | 414 | ||
| 415 | (defcustom cperl-clobber-mode-lists | 415 | ;;; (defcustom cperl-clobber-mode-lists |
| 416 | (not | 416 | ;;; (not |
| 417 | (and | 417 | ;;; (and |
| 418 | (boundp 'interpreter-mode-alist) | 418 | ;;; (boundp 'interpreter-mode-alist) |
| 419 | (assoc "miniperl" interpreter-mode-alist) | 419 | ;;; (assoc "miniperl" interpreter-mode-alist) |
| 420 | (assoc "\\.\\([pP][Llm]\\|al\\)$" auto-mode-alist))) | 420 | ;;; (assoc "\\.\\([pP][Llm]\\|al\\)$" auto-mode-alist))) |
| 421 | "*Whether to install us into `interpreter-' and `extension' mode lists." | 421 | ;;; "*Whether to install us into `interpreter-' and `extension' mode lists." |
| 422 | :type 'boolean | 422 | ;;; :type 'boolean |
| 423 | :group 'cperl) | 423 | ;;; :group 'cperl) |
| 424 | 424 | ||
| 425 | (defcustom cperl-info-on-command-no-prompt nil | 425 | (defcustom cperl-info-on-command-no-prompt nil |
| 426 | "*Not-nil (and non-null) means not to prompt on C-h f. | 426 | "*Not-nil (and non-null) means not to prompt on C-h f. |
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 7004836e69f..5eecc347f03 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -52,12 +52,12 @@ | |||
| 52 | ;; Extra functions `python-nav-forward-statement', | 52 | ;; Extra functions `python-nav-forward-statement', |
| 53 | ;; `python-nav-backward-statement', | 53 | ;; `python-nav-backward-statement', |
| 54 | ;; `python-nav-beginning-of-statement', `python-nav-end-of-statement', | 54 | ;; `python-nav-beginning-of-statement', `python-nav-end-of-statement', |
| 55 | ;; `python-nav-beginning-of-block' and `python-nav-end-of-block' are | 55 | ;; `python-nav-beginning-of-block', `python-nav-end-of-block' and |
| 56 | ;; included but no bound to any key. At last but not least the | 56 | ;; `python-nav-if-name-main' are included but no bound to any key. At |
| 57 | ;; specialized `python-nav-forward-sexp' allows easy navigation | 57 | ;; last but not least the specialized `python-nav-forward-sexp' allows |
| 58 | ;; between code blocks. If you prefer `cc-mode'-like `forward-sexp' | 58 | ;; easy navigation between code blocks. If you prefer `cc-mode'-like |
| 59 | ;; movement, setting `forward-sexp-function' to nil is enough, You can | 59 | ;; `forward-sexp' movement, setting `forward-sexp-function' to nil is |
| 60 | ;; do that using the `python-mode-hook': | 60 | ;; enough, You can do that using the `python-mode-hook': |
| 61 | 61 | ||
| 62 | ;; (add-hook 'python-mode-hook | 62 | ;; (add-hook 'python-mode-hook |
| 63 | ;; (lambda () (setq forward-sexp-function nil))) | 63 | ;; (lambda () (setq forward-sexp-function nil))) |
| @@ -225,7 +225,7 @@ | |||
| 225 | ;;;###autoload | 225 | ;;;###autoload |
| 226 | (add-to-list 'auto-mode-alist (cons (purecopy "\\.py\\'") 'python-mode)) | 226 | (add-to-list 'auto-mode-alist (cons (purecopy "\\.py\\'") 'python-mode)) |
| 227 | ;;;###autoload | 227 | ;;;###autoload |
| 228 | (add-to-list 'interpreter-mode-alist (cons (purecopy "python") 'python-mode)) | 228 | (add-to-list 'interpreter-mode-alist (cons (purecopy "\\`python[0-9.]*\\'") 'python-mode)) |
| 229 | 229 | ||
| 230 | (defgroup python nil | 230 | (defgroup python nil |
| 231 | "Python Language's flying circus support for Emacs." | 231 | "Python Language's flying circus support for Emacs." |
| @@ -1327,9 +1327,7 @@ backward to previous statement." | |||
| 1327 | (defun python-nav-beginning-of-block () | 1327 | (defun python-nav-beginning-of-block () |
| 1328 | "Move to start of current block." | 1328 | "Move to start of current block." |
| 1329 | (interactive "^") | 1329 | (interactive "^") |
| 1330 | (let ((starting-pos (point)) | 1330 | (let ((starting-pos (point))) |
| 1331 | (block-regexp (python-rx | ||
| 1332 | line-start (* whitespace) block-start))) | ||
| 1333 | (if (progn | 1331 | (if (progn |
| 1334 | (python-nav-beginning-of-statement) | 1332 | (python-nav-beginning-of-statement) |
| 1335 | (looking-at (python-rx block-start))) | 1333 | (looking-at (python-rx block-start))) |
| @@ -1422,9 +1420,6 @@ backwards." | |||
| 1422 | (let* ((forward-p (if (> dir 0) | 1420 | (let* ((forward-p (if (> dir 0) |
| 1423 | (and (setq dir 1) t) | 1421 | (and (setq dir 1) t) |
| 1424 | (and (setq dir -1) nil))) | 1422 | (and (setq dir -1) nil))) |
| 1425 | (re-search-fn (if forward-p | ||
| 1426 | 're-search-forward | ||
| 1427 | 're-search-backward)) | ||
| 1428 | (context-type (python-syntax-context-type))) | 1423 | (context-type (python-syntax-context-type))) |
| 1429 | (cond | 1424 | (cond |
| 1430 | ((memq context-type '(string comment)) | 1425 | ((memq context-type '(string comment)) |
| @@ -1583,6 +1578,29 @@ This command assumes point is not in a string or comment." | |||
| 1583 | (or arg (setq arg 1)) | 1578 | (or arg (setq arg 1)) |
| 1584 | (python-nav-up-list (- arg))) | 1579 | (python-nav-up-list (- arg))) |
| 1585 | 1580 | ||
| 1581 | (defun python-nav-if-name-main () | ||
| 1582 | "Move point at the beginning the __main__ block. | ||
| 1583 | When \"if __name__ == '__main__':\" is found returns its | ||
| 1584 | position, else returns nil." | ||
| 1585 | (interactive) | ||
| 1586 | (let ((point (point)) | ||
| 1587 | (found (catch 'found | ||
| 1588 | (goto-char (point-min)) | ||
| 1589 | (while (re-search-forward | ||
| 1590 | (python-rx line-start | ||
| 1591 | "if" (+ space) | ||
| 1592 | "__name__" (+ space) | ||
| 1593 | "==" (+ space) | ||
| 1594 | (group-n 1 (or ?\" ?\')) | ||
| 1595 | "__main__" (backref 1) (* space) ":") | ||
| 1596 | nil t) | ||
| 1597 | (when (not (python-syntax-context-type)) | ||
| 1598 | (beginning-of-line) | ||
| 1599 | (throw 'found t)))))) | ||
| 1600 | (if found | ||
| 1601 | (point) | ||
| 1602 | (ignore (goto-char point))))) | ||
| 1603 | |||
| 1586 | 1604 | ||
| 1587 | ;;; Shell integration | 1605 | ;;; Shell integration |
| 1588 | 1606 | ||
| @@ -2114,17 +2132,58 @@ Returns the output. See `python-shell-send-string-no-output'." | |||
| 2114 | (define-obsolete-function-alias | 2132 | (define-obsolete-function-alias |
| 2115 | 'python-send-string 'python-shell-internal-send-string "24.3") | 2133 | 'python-send-string 'python-shell-internal-send-string "24.3") |
| 2116 | 2134 | ||
| 2135 | (defun python-shell-buffer-substring (start end &optional nomain) | ||
| 2136 | "Send buffer substring from START to END formatted for shell. | ||
| 2137 | This is a wrapper over `buffer-substring' that takes care of | ||
| 2138 | different transformations for the code sent to be evaluated in | ||
| 2139 | the python shell: | ||
| 2140 | 1. When Optional Argument NOMAIN is non-nil everything under an | ||
| 2141 | \"if __name__ == '__main__'\" block will be removed. | ||
| 2142 | 2. When a subregion of the buffer is sent, it takes care of | ||
| 2143 | appending extra empty lines so tracebacks are correct. | ||
| 2144 | 3. Wraps indented regions under an \"if True:\" block so the | ||
| 2145 | interpreter evaluates them correctly." | ||
| 2146 | (let ((substring (buffer-substring-no-properties start end)) | ||
| 2147 | (fillstr (make-string (1- (line-number-at-pos start)) ?\n)) | ||
| 2148 | (toplevel-block-p (save-excursion | ||
| 2149 | (goto-char start) | ||
| 2150 | (or (zerop (line-number-at-pos start)) | ||
| 2151 | (progn | ||
| 2152 | (python-util-forward-comment 1) | ||
| 2153 | (zerop (current-indentation))))))) | ||
| 2154 | (with-temp-buffer | ||
| 2155 | (python-mode) | ||
| 2156 | (insert fillstr) | ||
| 2157 | (insert substring) | ||
| 2158 | (goto-char (point-min)) | ||
| 2159 | (when (not toplevel-block-p) | ||
| 2160 | (insert "if True:") | ||
| 2161 | (delete-region (point) (line-end-position))) | ||
| 2162 | (when nomain | ||
| 2163 | (let* ((if-name-main-start-end | ||
| 2164 | (and nomain | ||
| 2165 | (save-excursion | ||
| 2166 | (when (python-nav-if-name-main) | ||
| 2167 | (cons (point) | ||
| 2168 | (progn (python-nav-forward-sexp) | ||
| 2169 | (point))))))) | ||
| 2170 | ;; Oh destructuring bind, how I miss you. | ||
| 2171 | (if-name-main-start (car if-name-main-start-end)) | ||
| 2172 | (if-name-main-end (cdr if-name-main-start-end))) | ||
| 2173 | (when if-name-main-start-end | ||
| 2174 | (goto-char if-name-main-start) | ||
| 2175 | (delete-region if-name-main-start if-name-main-end) | ||
| 2176 | (insert | ||
| 2177 | (make-string | ||
| 2178 | (- (line-number-at-pos if-name-main-end) | ||
| 2179 | (line-number-at-pos if-name-main-start)) ?\n))))) | ||
| 2180 | (buffer-substring-no-properties (point-min) (point-max))))) | ||
| 2181 | |||
| 2117 | (defun python-shell-send-region (start end) | 2182 | (defun python-shell-send-region (start end) |
| 2118 | "Send the region delimited by START and END to inferior Python process." | 2183 | "Send the region delimited by START and END to inferior Python process." |
| 2119 | (interactive "r") | 2184 | (interactive "r") |
| 2120 | (python-shell-send-string | 2185 | (python-shell-send-string |
| 2121 | (concat | 2186 | (python-shell-buffer-substring start end) nil t)) |
| 2122 | (let ((line-num (line-number-at-pos start))) | ||
| 2123 | ;; When sending a region, add blank lines for non sent code so | ||
| 2124 | ;; backtraces remain correct. | ||
| 2125 | (make-string (1- line-num) ?\n)) | ||
| 2126 | (buffer-substring start end)) | ||
| 2127 | nil t)) | ||
| 2128 | 2187 | ||
| 2129 | (defun python-shell-send-buffer (&optional arg) | 2188 | (defun python-shell-send-buffer (&optional arg) |
| 2130 | "Send the entire buffer to inferior Python process. | 2189 | "Send the entire buffer to inferior Python process. |
| @@ -2133,13 +2192,9 @@ by \"if __name__== '__main__':\"" | |||
| 2133 | (interactive "P") | 2192 | (interactive "P") |
| 2134 | (save-restriction | 2193 | (save-restriction |
| 2135 | (widen) | 2194 | (widen) |
| 2136 | (let ((str (buffer-substring (point-min) (point-max)))) | 2195 | (python-shell-send-string |
| 2137 | (and | 2196 | (python-shell-buffer-substring |
| 2138 | (not arg) | 2197 | (point-min) (point-max) (not arg))))) |
| 2139 | (setq str (replace-regexp-in-string | ||
| 2140 | (python-rx if-name-main) | ||
| 2141 | "if __name__ == '__main__ ':" str))) | ||
| 2142 | (python-shell-send-string str)))) | ||
| 2143 | 2198 | ||
| 2144 | (defun python-shell-send-defun (arg) | 2199 | (defun python-shell-send-defun (arg) |
| 2145 | "Send the current defun to inferior Python process. | 2200 | "Send the current defun to inferior Python process. |
| @@ -2266,13 +2321,17 @@ and use the following as the value of this variable: | |||
| 2266 | LINE is used to detect the context on how to complete given | 2321 | LINE is used to detect the context on how to complete given |
| 2267 | INPUT." | 2322 | INPUT." |
| 2268 | (let* ((prompt | 2323 | (let* ((prompt |
| 2269 | ;; Get the last prompt for the inferior process | 2324 | ;; Get last prompt of the inferior process buffer (this |
| 2270 | ;; buffer. This is used for the completion code selection | 2325 | ;; intentionally avoids using `comint-last-prompt' because |
| 2271 | ;; heuristic. | 2326 | ;; of incompatibilities with Emacs 24.x). |
| 2272 | (with-current-buffer (process-buffer process) | 2327 | (with-current-buffer (process-buffer process) |
| 2273 | (buffer-substring-no-properties | 2328 | (save-excursion |
| 2274 | (overlay-start comint-last-prompt-overlay) | 2329 | (buffer-substring-no-properties |
| 2275 | (overlay-end comint-last-prompt-overlay)))) | 2330 | (- (point) (length line)) |
| 2331 | (progn | ||
| 2332 | (re-search-backward "^") | ||
| 2333 | (python-util-forward-comment) | ||
| 2334 | (point)))))) | ||
| 2276 | (completion-context | 2335 | (completion-context |
| 2277 | ;; Check whether a prompt matches a pdb string, an import | 2336 | ;; Check whether a prompt matches a pdb string, an import |
| 2278 | ;; statement or just the standard prompt and use the | 2337 | ;; statement or just the standard prompt and use the |
| @@ -2602,8 +2661,7 @@ JUSTIFY should be used (if applicable) as in `fill-paragraph'." | |||
| 2602 | (defun python-fill-string (&optional justify) | 2661 | (defun python-fill-string (&optional justify) |
| 2603 | "String fill function for `python-fill-paragraph'. | 2662 | "String fill function for `python-fill-paragraph'. |
| 2604 | JUSTIFY should be used (if applicable) as in `fill-paragraph'." | 2663 | JUSTIFY should be used (if applicable) as in `fill-paragraph'." |
| 2605 | (let* ((marker (point-marker)) | 2664 | (let* ((str-start-pos |
| 2606 | (str-start-pos | ||
| 2607 | (set-marker | 2665 | (set-marker |
| 2608 | (make-marker) | 2666 | (make-marker) |
| 2609 | (or (python-syntax-context 'string) | 2667 | (or (python-syntax-context 'string) |
| @@ -2669,7 +2727,7 @@ JUSTIFY should be used (if applicable) as in `fill-paragraph'." | |||
| 2669 | ;; Again indent only if a newline is added. | 2727 | ;; Again indent only if a newline is added. |
| 2670 | (indent-according-to-mode))))) t) | 2728 | (indent-according-to-mode))))) t) |
| 2671 | 2729 | ||
| 2672 | (defun python-fill-decorator (&optional justify) | 2730 | (defun python-fill-decorator (&optional _justify) |
| 2673 | "Decorator fill function for `python-fill-paragraph'. | 2731 | "Decorator fill function for `python-fill-paragraph'. |
| 2674 | JUSTIFY should be used (if applicable) as in `fill-paragraph'." | 2732 | JUSTIFY should be used (if applicable) as in `fill-paragraph'." |
| 2675 | t) | 2733 | t) |
| @@ -2831,8 +2889,7 @@ The skeleton will be bound to python-skeleton-NAME." | |||
| 2831 | 2889 | ||
| 2832 | (defun python-skeleton-add-menu-items () | 2890 | (defun python-skeleton-add-menu-items () |
| 2833 | "Add menu items to Python->Skeletons menu." | 2891 | "Add menu items to Python->Skeletons menu." |
| 2834 | (let ((skeletons (sort python-skeleton-available 'string<)) | 2892 | (let ((skeletons (sort python-skeleton-available 'string<))) |
| 2835 | (items)) | ||
| 2836 | (dolist (skeleton skeletons) | 2893 | (dolist (skeleton skeletons) |
| 2837 | (easy-menu-add-item | 2894 | (easy-menu-add-item |
| 2838 | nil '("Python" "Skeletons") | 2895 | nil '("Python" "Skeletons") |
| @@ -2920,7 +2977,7 @@ Runs COMMAND, a shell command, as if by `compile'. See | |||
| 2920 | (let ((process-environment (python-shell-calculate-process-environment)) | 2977 | (let ((process-environment (python-shell-calculate-process-environment)) |
| 2921 | (exec-path (python-shell-calculate-exec-path))) | 2978 | (exec-path (python-shell-calculate-exec-path))) |
| 2922 | (compilation-start command nil | 2979 | (compilation-start command nil |
| 2923 | (lambda (mode-name) | 2980 | (lambda (_modename) |
| 2924 | (format python-check-buffer-name command))))) | 2981 | (format python-check-buffer-name command))))) |
| 2925 | 2982 | ||
| 2926 | 2983 | ||
| @@ -3031,7 +3088,7 @@ It must be a function with two arguments: TYPE and NAME.") | |||
| 3031 | "Return imenu label for parent node using TYPE and NAME." | 3088 | "Return imenu label for parent node using TYPE and NAME." |
| 3032 | (format "%s..." (python-imenu-format-item-label type name))) | 3089 | (format "%s..." (python-imenu-format-item-label type name))) |
| 3033 | 3090 | ||
| 3034 | (defun python-imenu-format-parent-item-jump-label (type name) | 3091 | (defun python-imenu-format-parent-item-jump-label (type _name) |
| 3035 | "Return imenu label for parent node jump using TYPE and NAME." | 3092 | "Return imenu label for parent node jump using TYPE and NAME." |
| 3036 | (if (string= type "class") | 3093 | (if (string= type "class") |
| 3037 | "*class definition*" | 3094 | "*class definition*" |
| @@ -3145,7 +3202,7 @@ To this: | |||
| 3145 | (cons name (cdar pos)) | 3202 | (cons name (cdar pos)) |
| 3146 | (python-imenu-create-flat-index (cddr item) name)))))) | 3203 | (python-imenu-create-flat-index (cddr item) name)))))) |
| 3147 | (or alist | 3204 | (or alist |
| 3148 | (let* ((fn (lambda (type name) name)) | 3205 | (let* ((fn (lambda (_type name) name)) |
| 3149 | (python-imenu-format-item-label-function fn) | 3206 | (python-imenu-format-item-label-function fn) |
| 3150 | (python-imenu-format-parent-item-label-function fn) | 3207 | (python-imenu-format-parent-item-label-function fn) |
| 3151 | (python-imenu-format-parent-item-jump-label-function fn)) | 3208 | (python-imenu-format-parent-item-jump-label-function fn)) |
| @@ -3550,7 +3607,7 @@ if that value is non-nil." | |||
| 3550 | 3607 | ||
| 3551 | (add-to-list 'hs-special-modes-alist | 3608 | (add-to-list 'hs-special-modes-alist |
| 3552 | `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#" | 3609 | `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#" |
| 3553 | ,(lambda (arg) | 3610 | ,(lambda (_arg) |
| 3554 | (python-nav-end-of-defun)) nil)) | 3611 | (python-nav-end-of-defun)) nil)) |
| 3555 | 3612 | ||
| 3556 | (set (make-local-variable 'mode-require-final-newline) t) | 3613 | (set (make-local-variable 'mode-require-final-newline) t) |
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index c8fae7ba1e6..9dc2c4fb6c9 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el | |||
| @@ -137,6 +137,7 @@ This should only be called after matching against `ruby-here-doc-beg-re'." | |||
| 137 | 137 | ||
| 138 | (defconst ruby-symbol-chars "a-zA-Z0-9_" | 138 | (defconst ruby-symbol-chars "a-zA-Z0-9_" |
| 139 | "List of characters that symbol names may contain.") | 139 | "List of characters that symbol names may contain.") |
| 140 | |||
| 140 | (defconst ruby-symbol-re (concat "[" ruby-symbol-chars "]") | 141 | (defconst ruby-symbol-re (concat "[" ruby-symbol-chars "]") |
| 141 | "Regexp to match symbols.") | 142 | "Regexp to match symbols.") |
| 142 | 143 | ||
| @@ -254,11 +255,13 @@ Also ignores spaces after parenthesis when 'space." | |||
| 254 | ("for" for-body "end") | 255 | ("for" for-body "end") |
| 255 | ("[" expseq "]") | 256 | ("[" expseq "]") |
| 256 | ("{" hashvals "}") | 257 | ("{" hashvals "}") |
| 258 | ("{" insts "}") | ||
| 257 | ("while" insts "end") | 259 | ("while" insts "end") |
| 258 | ("until" insts "end") | 260 | ("until" insts "end") |
| 259 | ("unless" insts "end") | 261 | ("unless" insts "end") |
| 260 | ("if" if-body "end") | 262 | ("if" if-body "end") |
| 261 | ("case" cases "end")) | 263 | ("case" cases "end")) |
| 264 | (formal-params ("opening-|" exp "|")) | ||
| 262 | (for-body (for-head ";" insts)) | 265 | (for-body (for-head ";" insts)) |
| 263 | (for-head (id "in" exp)) | 266 | (for-head (id "in" exp)) |
| 264 | (cases (exp "then" insts) ;; FIXME: Ruby also allows (exp ":" insts). | 267 | (cases (exp "then" insts) ;; FIXME: Ruby also allows (exp ":" insts). |
| @@ -285,10 +288,20 @@ Also ignores spaces after parenthesis when 'space." | |||
| 285 | (save-excursion | 288 | (save-excursion |
| 286 | (skip-chars-backward " \t") | 289 | (skip-chars-backward " \t") |
| 287 | (not (or (bolp) | 290 | (not (or (bolp) |
| 288 | (memq (char-before) '(?\; ?- ?+ ?* ?/ ?:)) | 291 | (and (memq (char-before) '(?\; ?- ?+ ?* ?/ ?: ?.)) |
| 292 | ;; Make sure it's not the end of a regexp. | ||
| 293 | (not (eq (car (syntax-after (1- (point)))) 7))) | ||
| 289 | (and (memq (char-before) '(?\? ?=)) | 294 | (and (memq (char-before) '(?\? ?=)) |
| 290 | (not (memq (char-syntax (char-before (1- (point)))) | 295 | (let ((tok (ruby-smie--backward-token))) |
| 291 | '(?w ?_)))))))) | 296 | (or (equal tok "?") |
| 297 | (string-match "\\`\\s." tok)))))))) | ||
| 298 | |||
| 299 | (defun ruby-smie--opening-pipe-p () | ||
| 300 | (save-excursion | ||
| 301 | (if (eq ?| (char-before)) (forward-char -1)) | ||
| 302 | (skip-chars-backward " \t\n") | ||
| 303 | (or (eq ?\{ (char-before)) | ||
| 304 | (looking-back "\\_<do" (- (point) 2))))) | ||
| 292 | 305 | ||
| 293 | (defun ruby-smie--forward-token () | 306 | (defun ruby-smie--forward-token () |
| 294 | (skip-chars-forward " \t") | 307 | (skip-chars-forward " \t") |
| @@ -299,12 +312,16 @@ Also ignores spaces after parenthesis when 'space." | |||
| 299 | (if (eolp) (forward-char 1) (forward-comment 1)) | 312 | (if (eolp) (forward-char 1) (forward-comment 1)) |
| 300 | ";") | 313 | ";") |
| 301 | (forward-comment (point-max)) | 314 | (forward-comment (point-max)) |
| 315 | (if (looking-at ":\\s.+") | ||
| 316 | (progn (goto-char (match-end 0)) (match-string 0)) ;; bug#15208. | ||
| 302 | (let ((tok (smie-default-forward-token))) | 317 | (let ((tok (smie-default-forward-token))) |
| 303 | (cond | 318 | (cond |
| 304 | ((member tok '("unless" "if" "while" "until")) | 319 | ((member tok '("unless" "if" "while" "until")) |
| 305 | (if (save-excursion (forward-word -1) (ruby-smie--bosp)) | 320 | (if (save-excursion (forward-word -1) (ruby-smie--bosp)) |
| 306 | tok "iuwu-mod")) | 321 | tok "iuwu-mod")) |
| 307 | (t tok))))) | 322 | ((equal tok "|") |
| 323 | (if (ruby-smie--opening-pipe-p) "opening-|" tok)) | ||
| 324 | (t tok)))))) | ||
| 308 | 325 | ||
| 309 | (defun ruby-smie--backward-token () | 326 | (defun ruby-smie--backward-token () |
| 310 | (let ((pos (point))) | 327 | (let ((pos (point))) |
| @@ -314,10 +331,14 @@ Also ignores spaces after parenthesis when 'space." | |||
| 314 | (progn (skip-chars-forward " \t") | 331 | (progn (skip-chars-forward " \t") |
| 315 | ";") | 332 | ";") |
| 316 | (let ((tok (smie-default-backward-token))) | 333 | (let ((tok (smie-default-backward-token))) |
| 334 | (when (and (eq ?: (char-before)) (string-match "\\`\\s." tok)) | ||
| 335 | (forward-char -1) (setq tok (concat ":" tok))) ;; bug#15208. | ||
| 317 | (cond | 336 | (cond |
| 318 | ((member tok '("unless" "if" "while" "until")) | 337 | ((member tok '("unless" "if" "while" "until")) |
| 319 | (if (ruby-smie--bosp) | 338 | (if (ruby-smie--bosp) |
| 320 | tok "iuwu-mod")) | 339 | tok "iuwu-mod")) |
| 340 | ((equal tok "|") | ||
| 341 | (if (ruby-smie--opening-pipe-p) "opening-|" tok)) | ||
| 321 | (t tok)))))) | 342 | (t tok)))))) |
| 322 | 343 | ||
| 323 | (defun ruby-smie-rules (kind token) | 344 | (defun ruby-smie-rules (kind token) |
| @@ -332,7 +353,19 @@ Also ignores spaces after parenthesis when 'space." | |||
| 332 | ;; For (invalid) code between switch and case. | 353 | ;; For (invalid) code between switch and case. |
| 333 | ;; (if (smie-parent-p "switch") 4) | 354 | ;; (if (smie-parent-p "switch") 4) |
| 334 | 0)) | 355 | 0)) |
| 335 | (`(:before . ,(or `"else" `"then" `"elsif")) 0) | 356 | (`(:before . "do") |
| 357 | (when | ||
| 358 | (save-excursion | ||
| 359 | (forward-word 1) ;Skip "do" | ||
| 360 | (skip-chars-forward " \t") | ||
| 361 | (and (equal (save-excursion (ruby-smie--forward-token)) "opening-|") | ||
| 362 | (save-excursion (forward-sexp 1) | ||
| 363 | (skip-chars-forward " \t") | ||
| 364 | (or (eolp) | ||
| 365 | (looking-at comment-start-skip))))) | ||
| 366 | ;; `(column . ,(smie-indent-virtual)) | ||
| 367 | (smie-rule-parent))) | ||
| 368 | (`(:before . ,(or `"else" `"then" `"elsif" `"rescue")) 0) | ||
| 336 | (`(:before . ,(or `"when")) | 369 | (`(:before . ,(or `"when")) |
| 337 | (if (not (smie-rule-sibling-p)) 0)) ;; ruby-indent-level | 370 | (if (not (smie-rule-sibling-p)) 0)) ;; ruby-indent-level |
| 338 | ;; Hack attack: Since newlines are separators, don't try to align args that | 371 | ;; Hack attack: Since newlines are separators, don't try to align args that |
| @@ -903,6 +936,10 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'." | |||
| 903 | (not (looking-at "[a-z_]")))) | 936 | (not (looking-at "[a-z_]")))) |
| 904 | (and (looking-at ruby-operator-re) | 937 | (and (looking-at ruby-operator-re) |
| 905 | (not (ruby-special-char-p)) | 938 | (not (ruby-special-char-p)) |
| 939 | (save-excursion | ||
| 940 | (forward-char -1) | ||
| 941 | (or (not (looking-at ruby-operator-re)) | ||
| 942 | (not (eq (char-before) ?:)))) | ||
| 906 | ;; Operator at the end of line. | 943 | ;; Operator at the end of line. |
| 907 | (let ((c (char-after (point)))) | 944 | (let ((c (char-after (point)))) |
| 908 | (and | 945 | (and |
| @@ -1825,11 +1862,11 @@ See `font-lock-syntax-table'.") | |||
| 1825 | "using") | 1862 | "using") |
| 1826 | 'symbols)) | 1863 | 'symbols)) |
| 1827 | 1 'font-lock-builtin-face) | 1864 | 1 'font-lock-builtin-face) |
| 1828 | ;; Perl-ish keywords | ||
| 1829 | "\\_<\\(?:BEGIN\\|END\\)\\_>\\|^__END__$" | ||
| 1830 | ;; here-doc beginnings | 1865 | ;; here-doc beginnings |
| 1831 | `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0)) | 1866 | `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0)) |
| 1832 | 'font-lock-string-face)) | 1867 | 'font-lock-string-face)) |
| 1868 | ;; Perl-ish keywords | ||
| 1869 | "\\_<\\(?:BEGIN\\|END\\)\\_>\\|^__END__$" | ||
| 1833 | ;; variables | 1870 | ;; variables |
| 1834 | `(,(concat ruby-font-lock-keyword-beg-re | 1871 | `(,(concat ruby-font-lock-keyword-beg-re |
| 1835 | "\\_<\\(nil\\|self\\|true\\|false\\)\\>") | 1872 | "\\_<\\(nil\\|self\\|true\\|false\\)\\>") |
| @@ -1931,8 +1968,7 @@ The variable `ruby-indent-level' controls the amount of indentation. | |||
| 1931 | "\\)\\'")) 'ruby-mode)) | 1968 | "\\)\\'")) 'ruby-mode)) |
| 1932 | 1969 | ||
| 1933 | ;;;###autoload | 1970 | ;;;###autoload |
| 1934 | (dolist (name (list "ruby" "rbx" "jruby" "ruby1.9" "ruby1.8")) | 1971 | (add-to-list 'interpreter-mode-alist (cons (purecopy "\\`\\(rbx\\|j?ruby\\(1\\.[89]\\)?\\)\\'") 'ruby-mode)) |
| 1935 | (add-to-list 'interpreter-mode-alist (cons (purecopy name) 'ruby-mode))) | ||
| 1936 | 1972 | ||
| 1937 | (provide 'ruby-mode) | 1973 | (provide 'ruby-mode) |
| 1938 | 1974 | ||
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index c8b65e0a029..3ea2afb6fc3 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | ;;; sh-script.el --- shell-script editing commands for Emacs | 1 | ;;; sh-script.el --- shell-script editing commands for Emacs |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1993-1997, 1999, 2001-2013 Free Software Foundation, | 3 | ;; Copyright (C) 1993-1997, 1999, 2001-2013 Free Software Foundation, Inc. |
| 4 | ;; Inc. | ||
| 5 | 4 | ||
| 6 | ;; Author: Daniel Pfeiffer <occitan@esperanto.org> | 5 | ;; Author: Daniel Pfeiffer <occitan@esperanto.org> |
| 7 | ;; Version: 2.0f | 6 | ;; Version: 2.0f |
| @@ -673,7 +672,9 @@ removed when closing the here document." | |||
| 673 | "." "alias" "bg" "bind" "builtin" "caller" "compgen" "complete" | 672 | "." "alias" "bg" "bind" "builtin" "caller" "compgen" "complete" |
| 674 | "declare" "dirs" "disown" "enable" "fc" "fg" "help" "history" | 673 | "declare" "dirs" "disown" "enable" "fc" "fg" "help" "history" |
| 675 | "jobs" "kill" "let" "local" "popd" "printf" "pushd" "shopt" | 674 | "jobs" "kill" "let" "local" "popd" "printf" "pushd" "shopt" |
| 676 | "source" "suspend" "typeset" "unalias") | 675 | "source" "suspend" "typeset" "unalias" |
| 676 | ;; bash4 | ||
| 677 | "mapfile" "readarray") | ||
| 677 | 678 | ||
| 678 | ;; The next entry is only used for defining the others | 679 | ;; The next entry is only used for defining the others |
| 679 | (bourne sh-append shell | 680 | (bourne sh-append shell |
| @@ -737,6 +738,7 @@ implemented as aliases. See `sh-feature'." | |||
| 737 | :type '(repeat (cons (symbol :tag "Shell") | 738 | :type '(repeat (cons (symbol :tag "Shell") |
| 738 | (choice (repeat string) | 739 | (choice (repeat string) |
| 739 | (sexp :format "Evaluate: %v")))) | 740 | (sexp :format "Evaluate: %v")))) |
| 741 | :version "24.4" ; bash4 additions | ||
| 740 | :group 'sh-script) | 742 | :group 'sh-script) |
| 741 | 743 | ||
| 742 | 744 | ||
| @@ -2168,11 +2170,18 @@ the visited file executable, and NO-QUERY-FLAG (the second argument) | |||
| 2168 | controls whether to query about making the visited file executable. | 2170 | controls whether to query about making the visited file executable. |
| 2169 | 2171 | ||
| 2170 | Calls the value of `sh-set-shell-hook' if set." | 2172 | Calls the value of `sh-set-shell-hook' if set." |
| 2171 | (interactive (list (completing-read (format "Shell \(default %s\): " | 2173 | (interactive (list (completing-read |
| 2172 | sh-shell-file) | 2174 | (format "Shell \(default %s\): " |
| 2173 | interpreter-mode-alist | 2175 | sh-shell-file) |
| 2174 | (lambda (x) (eq (cdr x) 'sh-mode)) | 2176 | ;; This used to use interpreter-mode-alist, but that is |
| 2175 | nil nil nil sh-shell-file) | 2177 | ;; no longer appropriate now that uses regexps. |
| 2178 | ;; Maybe there could be a separate variable that lists | ||
| 2179 | ;; the shells, used here and to construct i-mode-alist. | ||
| 2180 | ;; But the following is probably good enough: | ||
| 2181 | (append (mapcar (lambda (e) (symbol-name (car e))) | ||
| 2182 | sh-ancestor-alist) | ||
| 2183 | '("csh" "rc" "sh")) | ||
| 2184 | nil nil nil nil sh-shell-file) | ||
| 2176 | (eq executable-query 'function) | 2185 | (eq executable-query 'function) |
| 2177 | t)) | 2186 | t)) |
| 2178 | (if (string-match "\\.exe\\'" shell) | 2187 | (if (string-match "\\.exe\\'" shell) |