aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorXue Fuqiao2013-09-04 08:39:34 +0800
committerXue Fuqiao2013-09-04 08:39:34 +0800
commitadf2fc4a01efe77d73cd52bc9173914ed56ff531 (patch)
treea5a280a5554a7bffeaf94fccae29fa3ac1a5d066 /lisp/progmodes
parent63191d9f2043d2e67657e85a7b3842805dd1dad6 (diff)
parent38726039b77db432989fed106c88e9f1aa463281 (diff)
downloademacs-adf2fc4a01efe77d73cd52bc9173914ed56ff531.tar.gz
emacs-adf2fc4a01efe77d73cd52bc9173914ed56ff531.zip
Merge from mainline.
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/ada-mode.el2
-rw-r--r--lisp/progmodes/ada-xref.el156
-rw-r--r--lisp/progmodes/antlr-mode.el4
-rw-r--r--lisp/progmodes/bat-mode.el186
-rw-r--r--lisp/progmodes/cc-awk.el81
-rw-r--r--lisp/progmodes/cc-bytecomp.el4
-rw-r--r--lisp/progmodes/cc-engine.el85
-rw-r--r--lisp/progmodes/cc-langs.el3
-rw-r--r--lisp/progmodes/cc-mode.el186
-rw-r--r--lisp/progmodes/compile.el6
-rw-r--r--lisp/progmodes/ebrowse.el2
-rw-r--r--lisp/progmodes/etags.el2
-rw-r--r--lisp/progmodes/f90.el2
-rw-r--r--lisp/progmodes/flymake.el2
-rw-r--r--lisp/progmodes/fortran.el3
-rw-r--r--lisp/progmodes/gdb-mi.el2
-rw-r--r--lisp/progmodes/idlw-toolbar.el2
-rw-r--r--lisp/progmodes/js.el7
-rw-r--r--lisp/progmodes/mixal-mode.el6
-rw-r--r--lisp/progmodes/python.el259
-rw-r--r--lisp/progmodes/ruby-mode.el47
-rw-r--r--lisp/progmodes/sh-script.el67
-rw-r--r--lisp/progmodes/verilog-mode.el2
23 files changed, 708 insertions, 408 deletions
diff --git a/lisp/progmodes/ada-mode.el b/lisp/progmodes/ada-mode.el
index 805444d08b9..33b21d6cc07 100644
--- a/lisp/progmodes/ada-mode.el
+++ b/lisp/progmodes/ada-mode.el
@@ -130,6 +130,8 @@
130(defvar ispell-check-comments) 130(defvar ispell-check-comments)
131(defvar skeleton-further-elements) 131(defvar skeleton-further-elements)
132 132
133(define-error 'ada-mode-errors nil)
134
133(defun ada-mode-version () 135(defun ada-mode-version ()
134 "Return Ada mode version." 136 "Return Ada mode version."
135 (interactive) 137 (interactive)
diff --git a/lisp/progmodes/ada-xref.el b/lisp/progmodes/ada-xref.el
index e44b7c191bf..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 )
@@ -1142,7 +1142,7 @@ If OTHER-FRAME is non-nil, display the cross-reference in another frame."
1142 (condition-case err 1142 (condition-case err
1143 (ada-find-in-ali identlist other-frame) 1143 (ada-find-in-ali identlist other-frame)
1144 ;; File not found: print explicit error message 1144 ;; File not found: print explicit error message
1145 (error-file-not-found 1145 (ada-error-file-not-found
1146 (message (concat (error-message-string err) 1146 (message (concat (error-message-string err)
1147 (nthcdr 1 err)))) 1147 (nthcdr 1 err))))
1148 1148
@@ -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)))
@@ -1637,7 +1637,7 @@ Search in project file for possible paths."
1637 (let ((filename (ada-find-src-file-in-dir file))) 1637 (let ((filename (ada-find-src-file-in-dir file)))
1638 (if filename 1638 (if filename
1639 (expand-file-name filename) 1639 (expand-file-name filename)
1640 (signal 'error-file-not-found (file-name-nondirectory file))) 1640 (signal 'ada-error-file-not-found (file-name-nondirectory file)))
1641 ))) 1641 )))
1642 1642
1643(defun ada-find-file-number-in-ali (file) 1643(defun ada-find-file-number-in-ali (file)
@@ -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
@@ -1828,7 +1828,7 @@ Information is extracted from the ali file."
1828 (ada-file-of identlist))) 1828 (ada-file-of identlist)))
1829 1829
1830 ;; Else clean up the ali file 1830 ;; Else clean up the ali file
1831 (error-file-not-found 1831 (ada-error-file-not-found
1832 (signal (car err) (cdr err))) 1832 (signal (car err) (cdr err)))
1833 (error 1833 (error
1834 (kill-buffer ali-buffer) 1834 (kill-buffer ali-buffer)
@@ -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,17 +2117,17 @@ 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)))
2127 (string-to-number (nth 2 (nth choice list))) 2127 (string-to-number (nth 2 (nth choice list)))
2128 identlist 2128 identlist
2129 other-frame) 2129 other-frame)
2130 (signal 'error-file-not-found (car (nth choice list)))) 2130 (signal 'ada-error-file-not-found (car (nth choice list))))
2131 (message "This is only a (good) guess at the cross-reference.") 2131 (message "This is only a (good) guess at the cross-reference.")
2132 )))) 2132 ))))
2133 2133
@@ -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 )
@@ -2362,12 +2362,8 @@ For instance, it creates the gnat-specific menus, sets some hooks for
2362(add-hook 'ada-mode-hook 'ada-xref-initialize) 2362(add-hook 'ada-mode-hook 'ada-xref-initialize)
2363 2363
2364;; Define a new error type 2364;; Define a new error type
2365(put 'error-file-not-found 2365(define-error 'ada-error-file-not-found
2366 'error-conditions 2366 "File not found in src-dir (check project file): " 'ada-mode-errors)
2367 '(error ada-mode-errors error-file-not-found))
2368(put 'error-file-not-found
2369 'error-message
2370 "File not found in src-dir (check project file): ")
2371 2367
2372(provide 'ada-xref) 2368(provide 'ada-xref)
2373 2369
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
new file mode 100644
index 00000000000..60b332170b0
--- /dev/null
+++ b/lisp/progmodes/bat-mode.el
@@ -0,0 +1,186 @@
1;;; bat-mode.el --- Major mode for editing DOS/Windows scripts
2
3;; Copyright (C) 2003, 2008-2013 Free Software Foundation, Inc.
4
5;; Author: Arni Magnusson <arnima@hafro.is>
6;; Keywords: languages
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software: you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22
23;;; Commentary:
24;;
25;; Major mode for editing DOS/Windows scripts (batch files). Provides syntax
26;; highlighting, a basic template, access to DOS help pages, imenu/outline
27;; navigation, and the ability to run scripts from within Emacs. The syntax
28;; groups for highlighting are:
29;;
30;; Face Example
31;; bat-label-face :LABEL
32;; font-lock-comment-face rem
33;; font-lock-builtin-face copy
34;; font-lock-keyword-face goto
35;; font-lock-warning-face cp
36;; font-lock-constant-face [call] prog
37;; font-lock-variable-name-face %var%
38;; font-lock-type-face -option
39;;
40;; Usage:
41;;
42;; See documentation of function `bat-mode'.
43;;
44;; Separate package `dos-indent' (Matthew Fidler) provides rudimentary
45;; indentation, see http://www.emacswiki.org/emacs/dos-indent.el.
46;;
47;; Acknowledgements:
48;;
49;; Inspired by `batch-mode' (Agnar Renolen) and `cmd-mode' (Tadamegu Furukawa).
50
51;;; Code:
52
53;; 1 Preamble
54
55(defgroup bat-mode nil
56 "Major mode for editing DOS/Windows batch files."
57 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
58 :group 'languages)
59
60;; 2 User variables
61
62(defface bat-label-face '((t :weight bold))
63 "Font Lock mode face used to highlight labels in batch files.")
64
65;; 3 Internal variables
66
67(defvar bat-font-lock-keywords
68 (eval-when-compile
69 (let ((COMMANDS
70 '("assoc" "at" "attrib" "cd" "cls" "color" "copy" "date" "del" "dir"
71 "doskey" "echo" "endlocal" "erase" "fc" "find" "findstr" "format"
72 "ftype" "label" "md" "mkdir" "more" "move" "net" "path" "pause"
73 "popd" "prompt" "pushd" "rd" "ren" "rename" "replace" "rmdir" "set"
74 "setlocal" "shift" "sort" "subst" "time" "title" "tree" "type"
75 "ver" "vol" "xcopy"))
76 (CONTROLFLOW
77 '("call" "cmd" "defined" "do" "else" "equ" "exist" "exit" "for" "geq"
78 "goto" "gtr" "if" "in" "leq" "lss" "neq" "not" "start"))
79 (UNIX
80 '("bash" "cat" "cp" "fgrep" "grep" "ls" "sed" "sh" "mv" "rm")))
81 `(("\\<_\\(call\\|goto\\)\\_>[ \t]+%?\\([A-Za-z0-9-_\\:.]+\\)%?"
82 (2 font-lock-constant-face t))
83 ("^:[^:].*"
84 . 'bat-label-face)
85 ("\\<_\\(defined\\|set\\)\\_>[ \t]*\\(\\w+\\)"
86 (2 font-lock-variable-name-face))
87 ("%\\(\\w+\\)%?"
88 (1 font-lock-variable-name-face))
89 ("!\\(\\w+\\)!?" ; delayed-expansion !variable!
90 (1 font-lock-variable-name-face))
91 ("[ =][-/]+\\(\\w+\\)"
92 (1 font-lock-type-face append))
93 (,(concat "\\_<" (regexp-opt COMMANDS) "\\_>") . font-lock-builtin-face)
94 (,(concat "\\_<" (regexp-opt CONTROLFLOW) "\\_>")
95 . font-lock-keyword-face)
96 (,(concat "\\_<" (regexp-opt UNIX) "\\_>")
97 . font-lock-warning-face)))))
98
99(defvar bat-menu
100 '("Bat"
101 ["Run" bat-run :help "Run script"]
102 ["Run with Args" bat-run-args :help "Run script with args"]
103 "--"
104 ["Imenu" imenu :help "Navigate with imenu"]
105 "--"
106 ["Template" bat-template :help "Insert template"]
107 "--"
108 ["Help (Command)" bat-cmd-help :help "Show help page for DOS command"]))
109
110(defvar bat-mode-map
111 (let ((map (make-sparse-keymap)))
112 (easy-menu-define nil map nil bat-menu)
113 (define-key map [?\C-c ?\C-/] 'bat-cmd-help) ;FIXME: Why not C-c C-? ?
114 (define-key map [?\C-c ?\C-a] 'bat-run-args)
115 (define-key map [?\C-c ?\C-c] 'bat-run)
116 (define-key map [?\C-c ?\C-t] 'bat-template)
117 (define-key map [?\C-c ?\C-v] 'bat-run)
118 map))
119
120(defvar bat-mode-syntax-table
121 (let ((table (make-syntax-table)))
122 (modify-syntax-entry ?\n ">" table)
123 (modify-syntax-entry ?\" "\"" table)
124 ;; Beware: `w' should not be used for non-alphabetic chars.
125 (modify-syntax-entry ?~ "_" table)
126 (modify-syntax-entry ?% "." table)
127 (modify-syntax-entry ?- "_" table)
128 (modify-syntax-entry ?_ "_" table)
129 ;; FIXME: { and } can appear in identifiers? Really?
130 (modify-syntax-entry ?{ "_" table)
131 (modify-syntax-entry ?} "_" table)
132 (modify-syntax-entry ?\\ "." table)
133 table))
134
135(defconst bat--syntax-propertize
136 (syntax-propertize-rules
137 ("^[ \t]*\\(?:\\(@?r\\)em\\_>\\|\\(?1::\\):\\).*" (1 "<"))))
138
139;; 4 User functions
140
141(defun bat-cmd-help (cmd)
142 "Show help for batch file command CMD."
143 (interactive "sHelp: ")
144 (if (string-equal cmd "net")
145 ;; FIXME: liable to quoting nightmare. Use call-process?
146 (shell-command "net /?") (shell-command (concat "help " cmd))))
147
148(defun bat-run ()
149 "Run a batch file."
150 (interactive)
151 ;; FIXME: liable to quoting nightmare. Use call/start-process?
152 (save-buffer) (shell-command buffer-file-name))
153
154(defun bat-run-args (args)
155 "Run a batch file with ARGS."
156 (interactive "sArgs: ")
157 ;; FIXME: Use `compile'?
158 (shell-command (concat buffer-file-name " " args)))
159
160(defun bat-template ()
161 "Insert minimal batch file template."
162 (interactive)
163 (goto-char (point-min)) (insert "@echo off\nsetlocal\n\n"))
164
165;;;###autoload
166(add-to-list 'auto-mode-alist '("\\.\\(bat\\|cmd\\)\\'" . bat-mode))
167
168;; 5 Main function
169
170;;;###autoload
171(define-derived-mode bat-mode prog-mode "Bat"
172 "Major mode for editing DOS/Windows batch files.\n
173Start a new script from `bat-template'. Read help pages for DOS commands
174with `bat-cmd-help'. Navigate between sections using `imenu'.
175Run script using `bat-run' and `bat-run-args'.\n
176\\{bat-mode-map}"
177 (setq-local comment-start "rem ")
178 (setq-local syntax-propertize-function bat--syntax-propertize)
179 (setq-local font-lock-defaults
180 '(bat-font-lock-keywords nil t)) ; case-insensitive keywords
181 (setq-local imenu-generic-expression '((nil "^:[^:].*" 0)))
182 (setq-local outline-regexp ":[^:]"))
183
184(provide 'bat-mode)
185
186;;; bat-mode.el ends here
diff --git a/lisp/progmodes/cc-awk.el b/lisp/progmodes/cc-awk.el
index 4b3fc91b0ff..b5216b43ed9 100644
--- a/lisp/progmodes/cc-awk.el
+++ b/lisp/progmodes/cc-awk.el
@@ -169,9 +169,9 @@
169 (concat "\\=_?\"" c-awk-string-innards-re)) 169 (concat "\\=_?\"" c-awk-string-innards-re))
170;; Matches an AWK string at point up to, but not including, any terminator. 170;; Matches an AWK string at point up to, but not including, any terminator.
171;; A gawk 3.1+ string may look like _"localizable string". 171;; A gawk 3.1+ string may look like _"localizable string".
172(defconst c-awk-one-line-possibly-open-string-re 172(defconst c-awk-possibly-open-string-re
173 (concat "\"\\(" c-awk-string-ch-re "\\|" c-awk-non-eol-esc-pair-re "\\)*" 173 (concat "\"\\(" c-awk-string-ch-re "\\|" c-awk-esc-pair-re "\\)*"
174 "\\(\"\\|\\\\?$\\|\\'\\)")) 174 "\\(\"\\|$\\|\\'\\)"))
175 175
176;; REGEXPS FOR AWK REGEXPS. 176;; REGEXPS FOR AWK REGEXPS.
177(defconst c-awk-regexp-normal-re "[^[/\\\n\r]") 177(defconst c-awk-regexp-normal-re "[^[/\\\n\r]")
@@ -192,25 +192,13 @@
192 "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)")) 192 "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)"))
193;; Matches a regexp char list, up to (but not including) EOL if the ] is 193;; Matches a regexp char list, up to (but not including) EOL if the ] is
194;; missing. 194;; missing.
195(defconst c-awk-regexp-one-line-possibly-open-char-list-re
196 (concat "\\[\\]?\\(" c-awk-non-eol-esc-pair-re "\\|" "[^]\n\r]" "\\)*"
197 "\\(]\\|\\\\?$\\|\\'\\)"))
198;; Matches the head (or all) of a regexp char class, up to (but not
199;; including) the first EOL.
200(defconst c-awk-regexp-innards-re 195(defconst c-awk-regexp-innards-re
201 (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-list-re 196 (concat "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-list-re
202 "\\|" c-awk-regexp-normal-re "\\)*")) 197 "\\|" c-awk-regexp-normal-re "\\)*"))
203;; Matches the inside of an AWK regexp (i.e. without the enclosing /s) 198;; Matches the inside of an AWK regexp (i.e. without the enclosing /s)
204(defconst c-awk-regexp-without-end-re 199(defconst c-awk-regexp-without-end-re
205 (concat "/" c-awk-regexp-innards-re)) 200 (concat "/" c-awk-regexp-innards-re))
206;; Matches an AWK regexp up to, but not including, any terminating /. 201;; Matches an AWK regexp up to, but not including, any terminating /.
207(defconst c-awk-one-line-possibly-open-regexp-re
208 (concat "/\\(" c-awk-non-eol-esc-pair-re
209 "\\|" c-awk-regexp-one-line-possibly-open-char-list-re
210 "\\|" c-awk-regexp-normal-re "\\)*"
211 "\\(/\\|\\\\?$\\|\\'\\)"))
212;; Matches as much of the head of an AWK regexp which fits on one line,
213;; possibly all of it.
214 202
215;; REGEXPS used for scanning an AWK buffer in order to decide IF A '/' IS A 203;; REGEXPS used for scanning an AWK buffer in order to decide IF A '/' IS A
216;; REGEXP OPENER OR A DIVISION SIGN. By "state" in the following is meant 204;; REGEXP OPENER OR A DIVISION SIGN. By "state" in the following is meant
@@ -262,15 +250,24 @@
262 250
263;; REGEXPS USED FOR FINDING THE POSITION OF A "virtual semicolon" 251;; REGEXPS USED FOR FINDING THE POSITION OF A "virtual semicolon"
264(defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\\\n\r \t]") 252(defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\\\n\r \t]")
265;; NEW VERSION! (which will be restricted to the current line) 253(defconst c-awk-non-/-syn-ws*-re
266(defconst c-awk-one-line-non-syn-ws*-re 254 (concat
267 (concat "\\([ \t]*" 255 "\\(" c-awk-escaped-nls*-with-space*
268 "\\(" c-awk-_-harmless-nonws-char-re "\\|" 256 "\\(" c-awk-_-harmless-nonws-char-re "\\|"
269 c-awk-non-eol-esc-pair-re "\\|" 257 c-awk-non-eol-esc-pair-re "\\|"
270 c-awk-one-line-possibly-open-string-re "\\|" 258 c-awk-possibly-open-string-re
271 c-awk-one-line-possibly-open-regexp-re 259 "\\)"
272 "\\)" 260 "\\)*"))
273 "\\)*")) 261(defconst c-awk-space*-/-re (concat c-awk-escaped-nls*-with-space* "/"))
262;; Matches optional whitespace followed by "/".
263(defconst c-awk-space*-regexp-/-re
264 (concat c-awk-escaped-nls*-with-space* "\\s\""))
265;; Matches optional whitespace followed by a "/" with string syntax (a matched
266;; regexp delimiter).
267(defconst c-awk-space*-unclosed-regexp-/-re
268 (concat c-awk-escaped-nls*-with-space* "\\s\|"))
269;; Matches optional whitespace followed by a "/" with string fence syntax (an
270;; unmatched regexp delimiter).
274 271
275 272
276;; ACM, 2002/5/29: 273;; ACM, 2002/5/29:
@@ -549,10 +546,36 @@
549(defun c-awk-at-vsemi-p (&optional pos) 546(defun c-awk-at-vsemi-p (&optional pos)
550 ;; Is there a virtual semicolon at POS (or POINT)? 547 ;; Is there a virtual semicolon at POS (or POINT)?
551 (save-excursion 548 (save-excursion
552 (let (nl-prop 549 (let* (nl-prop
553 (pos-or-point (progn (if pos (goto-char pos)) (point)))) 550 (pos-or-point (progn (if pos (goto-char pos)) (point)))
554 (forward-line 0) 551 (bol (c-point 'bol)) (eol (c-point 'eol)))
555 (search-forward-regexp c-awk-one-line-non-syn-ws*-re) 552 (c-awk-beginning-of-logical-line)
553 ;; Next `while' goes round one logical line (ending in, e.g. "\\") per
554 ;; iteration. Such a line is rare, and can only be an open string
555 ;; ending in an escaped \.
556 (while
557 (progn
558 ;; Next `while' goes over a division sign or /regexp/ per iteration.
559 (while
560 (and
561 (< (point) eol)
562 (progn
563 (search-forward-regexp c-awk-non-/-syn-ws*-re eol)
564 (looking-at c-awk-space*-/-re)))
565 (cond
566 ((looking-at c-awk-space*-regexp-/-re) ; /regexp/
567 (forward-sexp))
568 ((looking-at c-awk-space*-unclosed-regexp-/-re) ; Unclosed /regexp
569 (condition-case nil
570 (progn
571 (forward-sexp)
572 (backward-char)) ; Move to end of (logical) line.
573 (error (end-of-line)))) ; Happens at EOB.
574 (t ; division sign
575 (c-forward-syntactic-ws)
576 (forward-char))))
577 (< (point) bol))
578 (forward-line))
556 (and (eq (point) pos-or-point) 579 (and (eq (point) pos-or-point)
557 (progn 580 (progn
558 (while (and (eq (setq nl-prop (c-awk-get-NL-prop-cur-line)) ?\\) 581 (while (and (eq (setq nl-prop (c-awk-get-NL-prop-cur-line)) ?\\)
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
244somewhat intentional." 244somewhat 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 c2ff5011a0e..db2a6c68539 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -1271,6 +1271,9 @@ comment at the start of cc-engine.el for more info."
1271 (throw 'done (point))))) 1271 (throw 'done (point)))))
1272 ;; In trailing space after an as yet undetected virtual semicolon? 1272 ;; In trailing space after an as yet undetected virtual semicolon?
1273 (c-backward-syntactic-ws from) 1273 (c-backward-syntactic-ws from)
1274 (when (and (bolp) (not (bobp))) ; Can happen in AWK Mode with an
1275 ; unterminated string/regexp.
1276 (backward-char))
1274 (if (and (< (point) to) 1277 (if (and (< (point) to)
1275 (c-at-vsemi-p)) 1278 (c-at-vsemi-p))
1276 (point) 1279 (point)
@@ -6476,6 +6479,15 @@ comment at the start of cc-engine.el for more info."
6476 (c-go-list-forward) 6479 (c-go-list-forward)
6477 t))) 6480 t)))
6478 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
6479(defun c-back-over-member-initializers () 6491(defun c-back-over-member-initializers ()
6480 ;; 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
6481 ;; to the introducing ":", returning the position of the opening paren of 6493 ;; to the introducing ":", returning the position of the opening paren of
@@ -8400,15 +8412,6 @@ comment at the start of cc-engine.el for more info."
8400 (back-to-indentation) 8412 (back-to-indentation)
8401 (vector (point) open-paren-pos)))))) 8413 (vector (point) open-paren-pos))))))
8402 8414
8403(defmacro c-pull-open-brace (ps)
8404 ;; Pull the next open brace from PS (which has the form of paren-state),
8405 ;; skipping over any brace pairs. Returns NIL when PS is exhausted.
8406 `(progn
8407 (while (consp (car ,ps))
8408 (setq ,ps (cdr ,ps)))
8409 (prog1 (car ,ps)
8410 (setq ,ps (cdr ,ps)))))
8411
8412(defun c-most-enclosing-decl-block (paren-state) 8415(defun c-most-enclosing-decl-block (paren-state)
8413 ;; Return the buffer position of the most enclosing decl-block brace (in the 8416 ;; Return the buffer position of the most enclosing decl-block brace (in the
8414 ;; sense of c-looking-at-decl-block) in the PAREN-STATE structure, or nil if 8417 ;; sense of c-looking-at-decl-block) in the PAREN-STATE structure, or nil if
@@ -8473,10 +8476,10 @@ comment at the start of cc-engine.el for more info."
8473 ;; check for the class key here. 8476 ;; check for the class key here.
8474 (and (c-major-mode-is 'pike-mode) 8477 (and (c-major-mode-is 'pike-mode)
8475 c-decl-block-key)) 8478 c-decl-block-key))
8476 bufpos braceassignp lim next-containing) 8479 bufpos braceassignp lim next-containing macro-start)
8477 (while (and (not bufpos) 8480 (while (and (not bufpos)
8478 containing-sexp) 8481 containing-sexp)
8479 (when paren-state 8482 (when paren-state
8480 (if (consp (car paren-state)) 8483 (if (consp (car paren-state))
8481 (setq lim (cdr (car paren-state)) 8484 (setq lim (cdr (car paren-state))
8482 paren-state (cdr paren-state)) 8485 paren-state (cdr paren-state))
@@ -8557,22 +8560,38 @@ comment at the start of cc-engine.el for more info."
8557 )))) 8560 ))))
8558 nil) 8561 nil)
8559 (t t)))))) 8562 (t t))))))
8560 (if (and (eq braceassignp 'dontknow) 8563 (if (and (eq braceassignp 'dontknow)
8561 (/= (c-backward-token-2 1 t lim) 0)) 8564 (/= (c-backward-token-2 1 t lim) 0))
8562 (setq braceassignp nil))) 8565 (setq braceassignp nil)))
8563 (if (not braceassignp) 8566 (cond
8564 (if (eq (char-after) ?\;) 8567 (braceassignp
8565 ;; Brace lists can't contain a semicolon, so we're done. 8568 ;; We've hit the beginning of the aggregate list.
8566 (setq containing-sexp nil) 8569 (c-beginning-of-statement-1
8567 ;; Go up one level. 8570 (c-most-enclosing-brace paren-state))
8568 (setq containing-sexp next-containing 8571 (setq bufpos (point)))
8569 lim nil 8572 ((eq (char-after) ?\;)
8570 next-containing nil)) 8573 ;; Brace lists can't contain a semicolon, so we're done.
8571 ;; we've hit the beginning of the aggregate list 8574 (setq containing-sexp nil))
8572 (c-beginning-of-statement-1 8575 ((and (setq macro-start (point))
8573 (c-most-enclosing-brace paren-state)) 8576 (c-forward-to-cpp-define-body)
8574 (setq bufpos (point)))) 8577 (eq (point) containing-sexp))
8575 ) 8578 ;; We've a macro whose expansion starts with the '{'.
8579 ;; Heuristically, if we have a ';' in it we've not got a
8580 ;; brace list, otherwise we have.
8581 (let ((macro-end (progn (c-end-of-macro) (point))))
8582 (goto-char containing-sexp)
8583 (forward-char)
8584 (if (and (c-syntactic-re-search-forward "[;,]" macro-end t t)
8585 (eq (char-before) ?\;))
8586 (setq bufpos nil
8587 containing-sexp nil)
8588 (setq bufpos macro-start))))
8589 (t
8590 ;; Go up one level
8591 (setq containing-sexp next-containing
8592 lim nil
8593 next-containing nil)))))
8594
8576 bufpos)) 8595 bufpos))
8577 )) 8596 ))
8578 8597
@@ -9796,12 +9815,12 @@ comment at the start of cc-engine.el for more info."
9796 (not (eq (char-after) ?:)) 9815 (not (eq (char-after) ?:))
9797 ))) 9816 )))
9798 (save-excursion 9817 (save-excursion
9799 (c-backward-syntactic-ws lim) 9818 (c-beginning-of-statement-1 lim)
9800 (if (eq char-before-ip ?:) 9819 (when (looking-at c-opt-<>-sexp-key)
9801 (progn 9820 (goto-char (match-end 1))
9802 (forward-char -1) 9821 (c-forward-syntactic-ws)
9803 (c-backward-syntactic-ws lim))) 9822 (c-forward-<>-arglist nil)
9804 (back-to-indentation) 9823 (c-forward-syntactic-ws))
9805 (looking-at c-class-key))) 9824 (looking-at c-class-key)))
9806 ;; for Java 9825 ;; for Java
9807 (and (c-major-mode-is 'java-mode) 9826 (and (c-major-mode-is 'java-mode)
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 2c0a1317b04..0116e9ec3dd 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -2163,8 +2163,7 @@ assumed to be set if this isn't nil."
2163(c-lang-defconst c-opt-<>-sexp-key 2163(c-lang-defconst c-opt-<>-sexp-key
2164 ;; Adorned regexp matching keywords that can be followed by an angle 2164 ;; Adorned regexp matching keywords that can be followed by an angle
2165 ;; bracket sexp. Always set when `c-recognize-<>-arglists' is. 2165 ;; bracket sexp. Always set when `c-recognize-<>-arglists' is.
2166 t (if (c-lang-const c-recognize-<>-arglists) 2166 t (c-make-keywords-re t (c-lang-const c-<>-sexp-kwds)))
2167 (c-make-keywords-re t (c-lang-const c-<>-sexp-kwds))))
2168(c-lang-defvar c-opt-<>-sexp-key (c-lang-const c-opt-<>-sexp-key)) 2167(c-lang-defvar c-opt-<>-sexp-key (c-lang-const c-opt-<>-sexp-key))
2169 2168
2170(c-lang-defconst c-brace-id-list-kwds 2169(c-lang-defconst c-brace-id-list-kwds
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 36c9f72fa18..1e8d6cba8c4 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
@@ -1235,27 +1239,22 @@ This function is called from `c-common-init', once per mode initialization."
1235 1239
1236;; Support for C 1240;; Support for C
1237 1241
1238;;;###autoload 1242(defvar c-mode-syntax-table
1239(defvar c-mode-syntax-table nil 1243 (funcall (c-lang-const c-make-mode-syntax-table c))
1240 "Syntax table used in c-mode buffers.") 1244 "Syntax table used in c-mode buffers.")
1241(or c-mode-syntax-table
1242 (setq c-mode-syntax-table
1243 (funcall (c-lang-const c-make-mode-syntax-table c))))
1244 1245
1245(defvar c-mode-abbrev-table nil
1246 "Abbreviation table used in c-mode buffers.")
1247(c-define-abbrev-table 'c-mode-abbrev-table 1246(c-define-abbrev-table 'c-mode-abbrev-table
1248 '(("else" "else" c-electric-continued-statement 0) 1247 '(("else" "else" c-electric-continued-statement 0)
1249 ("while" "while" c-electric-continued-statement 0))) 1248 ("while" "while" c-electric-continued-statement 0))
1249 "Abbreviation table used in c-mode buffers.")
1250 1250
1251(defvar c-mode-map () 1251(defvar c-mode-map
1252 (let ((map (c-make-inherited-keymap)))
1253 ;; Add bindings which are only useful for C.
1254 (define-key map "\C-c\C-e" 'c-macro-expand)
1255 map)
1252 "Keymap used in c-mode buffers.") 1256 "Keymap used in c-mode buffers.")
1253(if c-mode-map 1257
1254 nil
1255 (setq c-mode-map (c-make-inherited-keymap))
1256 ;; add bindings which are only useful for C
1257 (define-key c-mode-map "\C-c\C-e" 'c-macro-expand)
1258 )
1259 1258
1260(easy-menu-define c-c-menu c-mode-map "C Mode Commands" 1259(easy-menu-define c-c-menu c-mode-map "C Mode Commands"
1261 (cons "C" (c-lang-const c-mode-menu c))) 1260 (cons "C" (c-lang-const c-mode-menu c)))
@@ -1320,30 +1319,25 @@ Key bindings:
1320 1319
1321;; Support for C++ 1320;; Support for C++
1322 1321
1323;;;###autoload 1322(defvar c++-mode-syntax-table
1324(defvar c++-mode-syntax-table nil 1323 (funcall (c-lang-const c-make-mode-syntax-table c++))
1325 "Syntax table used in c++-mode buffers.") 1324 "Syntax table used in c++-mode buffers.")
1326(or c++-mode-syntax-table
1327 (setq c++-mode-syntax-table
1328 (funcall (c-lang-const c-make-mode-syntax-table c++))))
1329 1325
1330(defvar c++-mode-abbrev-table nil
1331 "Abbreviation table used in c++-mode buffers.")
1332(c-define-abbrev-table 'c++-mode-abbrev-table 1326(c-define-abbrev-table 'c++-mode-abbrev-table
1333 '(("else" "else" c-electric-continued-statement 0) 1327 '(("else" "else" c-electric-continued-statement 0)
1334 ("while" "while" c-electric-continued-statement 0) 1328 ("while" "while" c-electric-continued-statement 0)
1335 ("catch" "catch" c-electric-continued-statement 0))) 1329 ("catch" "catch" c-electric-continued-statement 0))
1330 "Abbreviation table used in c++-mode buffers.")
1336 1331
1337(defvar c++-mode-map () 1332(defvar c++-mode-map
1333 (let ((map (c-make-inherited-keymap)))
1334 ;; Add bindings which are only useful for C++.
1335 (define-key map "\C-c\C-e" 'c-macro-expand)
1336 (define-key map "\C-c:" 'c-scope-operator)
1337 (define-key map "<" 'c-electric-lt-gt)
1338 (define-key map ">" 'c-electric-lt-gt)
1339 map)
1338 "Keymap used in c++-mode buffers.") 1340 "Keymap used in c++-mode buffers.")
1339(if c++-mode-map
1340 nil
1341 (setq c++-mode-map (c-make-inherited-keymap))
1342 ;; add bindings which are only useful for C++
1343 (define-key c++-mode-map "\C-c\C-e" 'c-macro-expand)
1344 (define-key c++-mode-map "\C-c:" 'c-scope-operator)
1345 (define-key c++-mode-map "<" 'c-electric-lt-gt)
1346 (define-key c++-mode-map ">" 'c-electric-lt-gt))
1347 1341
1348(easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands" 1342(easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands"
1349 (cons "C++" (c-lang-const c-mode-menu c++))) 1343 (cons "C++" (c-lang-const c-mode-menu c++)))
@@ -1380,26 +1374,21 @@ Key bindings:
1380 1374
1381;; Support for Objective-C 1375;; Support for Objective-C
1382 1376
1383;;;###autoload 1377(defvar objc-mode-syntax-table
1384(defvar objc-mode-syntax-table nil 1378 (funcall (c-lang-const c-make-mode-syntax-table objc))
1385 "Syntax table used in objc-mode buffers.") 1379 "Syntax table used in objc-mode buffers.")
1386(or objc-mode-syntax-table
1387 (setq objc-mode-syntax-table
1388 (funcall (c-lang-const c-make-mode-syntax-table objc))))
1389 1380
1390(defvar objc-mode-abbrev-table nil
1391 "Abbreviation table used in objc-mode buffers.")
1392(c-define-abbrev-table 'objc-mode-abbrev-table 1381(c-define-abbrev-table 'objc-mode-abbrev-table
1393 '(("else" "else" c-electric-continued-statement 0) 1382 '(("else" "else" c-electric-continued-statement 0)
1394 ("while" "while" c-electric-continued-statement 0))) 1383 ("while" "while" c-electric-continued-statement 0))
1384 "Abbreviation table used in objc-mode buffers.")
1395 1385
1396(defvar objc-mode-map () 1386(defvar objc-mode-map
1387 (let ((map (c-make-inherited-keymap)))
1388 ;; Add bindings which are only useful for Objective-C.
1389 (define-key map "\C-c\C-e" 'c-macro-expand)
1390 map)
1397 "Keymap used in objc-mode buffers.") 1391 "Keymap used in objc-mode buffers.")
1398(if objc-mode-map
1399 nil
1400 (setq objc-mode-map (c-make-inherited-keymap))
1401 ;; add bindings which are only useful for Objective-C
1402 (define-key objc-mode-map "\C-c\C-e" 'c-macro-expand))
1403 1392
1404(easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands" 1393(easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands"
1405 (cons "ObjC" (c-lang-const c-mode-menu objc))) 1394 (cons "ObjC" (c-lang-const c-mode-menu objc)))
@@ -1438,28 +1427,22 @@ Key bindings:
1438 1427
1439;; Support for Java 1428;; Support for Java
1440 1429
1441;;;###autoload 1430(defvar java-mode-syntax-table
1442(defvar java-mode-syntax-table nil 1431 (funcall (c-lang-const c-make-mode-syntax-table java))
1443 "Syntax table used in java-mode buffers.") 1432 "Syntax table used in java-mode buffers.")
1444(or java-mode-syntax-table
1445 (setq java-mode-syntax-table
1446 (funcall (c-lang-const c-make-mode-syntax-table java))))
1447 1433
1448(defvar java-mode-abbrev-table nil
1449 "Abbreviation table used in java-mode buffers.")
1450(c-define-abbrev-table 'java-mode-abbrev-table 1434(c-define-abbrev-table 'java-mode-abbrev-table
1451 '(("else" "else" c-electric-continued-statement 0) 1435 '(("else" "else" c-electric-continued-statement 0)
1452 ("while" "while" c-electric-continued-statement 0) 1436 ("while" "while" c-electric-continued-statement 0)
1453 ("catch" "catch" c-electric-continued-statement 0) 1437 ("catch" "catch" c-electric-continued-statement 0)
1454 ("finally" "finally" c-electric-continued-statement 0))) 1438 ("finally" "finally" c-electric-continued-statement 0))
1439 "Abbreviation table used in java-mode buffers.")
1455 1440
1456(defvar java-mode-map () 1441(defvar java-mode-map
1442 (let ((map (c-make-inherited-keymap)))
1443 ;; Add bindings which are only useful for Java.
1444 map)
1457 "Keymap used in java-mode buffers.") 1445 "Keymap used in java-mode buffers.")
1458(if java-mode-map
1459 nil
1460 (setq java-mode-map (c-make-inherited-keymap))
1461 ;; add bindings which are only useful for Java
1462 )
1463 1446
1464;; Regexp trying to describe the beginning of a Java top-level 1447;; Regexp trying to describe the beginning of a Java top-level
1465;; definition. This is not used by CC Mode, nor is it maintained 1448;; definition. This is not used by CC Mode, nor is it maintained
@@ -1504,24 +1487,18 @@ Key bindings:
1504 1487
1505;; Support for CORBA's IDL language 1488;; Support for CORBA's IDL language
1506 1489
1507;;;###autoload 1490(defvar idl-mode-syntax-table
1508(defvar idl-mode-syntax-table nil 1491 (funcall (c-lang-const c-make-mode-syntax-table idl))
1509 "Syntax table used in idl-mode buffers.") 1492 "Syntax table used in idl-mode buffers.")
1510(or idl-mode-syntax-table
1511 (setq idl-mode-syntax-table
1512 (funcall (c-lang-const c-make-mode-syntax-table idl))))
1513 1493
1514(defvar idl-mode-abbrev-table nil 1494(c-define-abbrev-table 'idl-mode-abbrev-table nil
1515 "Abbreviation table used in idl-mode buffers.") 1495 "Abbreviation table used in idl-mode buffers.")
1516(c-define-abbrev-table 'idl-mode-abbrev-table nil)
1517 1496
1518(defvar idl-mode-map () 1497(defvar idl-mode-map
1498 (let ((map (c-make-inherited-keymap)))
1499 ;; Add bindings which are only useful for IDL.
1500 map)
1519 "Keymap used in idl-mode buffers.") 1501 "Keymap used in idl-mode buffers.")
1520(if idl-mode-map
1521 nil
1522 (setq idl-mode-map (c-make-inherited-keymap))
1523 ;; add bindings which are only useful for IDL
1524 )
1525 1502
1526(easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands" 1503(easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands"
1527 (cons "IDL" (c-lang-const c-mode-menu idl))) 1504 (cons "IDL" (c-lang-const c-mode-menu idl)))
@@ -1558,26 +1535,21 @@ Key bindings:
1558 1535
1559;; Support for Pike 1536;; Support for Pike
1560 1537
1561;;;###autoload 1538(defvar pike-mode-syntax-table
1562(defvar pike-mode-syntax-table nil 1539 (funcall (c-lang-const c-make-mode-syntax-table pike))
1563 "Syntax table used in pike-mode buffers.") 1540 "Syntax table used in pike-mode buffers.")
1564(or pike-mode-syntax-table
1565 (setq pike-mode-syntax-table
1566 (funcall (c-lang-const c-make-mode-syntax-table pike))))
1567 1541
1568(defvar pike-mode-abbrev-table nil
1569 "Abbreviation table used in pike-mode buffers.")
1570(c-define-abbrev-table 'pike-mode-abbrev-table 1542(c-define-abbrev-table 'pike-mode-abbrev-table
1571 '(("else" "else" c-electric-continued-statement 0) 1543 '(("else" "else" c-electric-continued-statement 0)
1572 ("while" "while" c-electric-continued-statement 0))) 1544 ("while" "while" c-electric-continued-statement 0))
1545 "Abbreviation table used in pike-mode buffers.")
1573 1546
1574(defvar pike-mode-map () 1547(defvar pike-mode-map
1548 (let ((map (c-make-inherited-keymap)))
1549 ;; Additional bindings.
1550 (define-key map "\C-c\C-e" 'c-macro-expand)
1551 map)
1575 "Keymap used in pike-mode buffers.") 1552 "Keymap used in pike-mode buffers.")
1576(if pike-mode-map
1577 nil
1578 (setq pike-mode-map (c-make-inherited-keymap))
1579 ;; additional bindings
1580 (define-key pike-mode-map "\C-c\C-e" 'c-macro-expand))
1581 1553
1582(easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands" 1554(easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands"
1583 (cons "Pike" (c-lang-const c-mode-menu pike))) 1555 (cons "Pike" (c-lang-const c-mode-menu pike)))
@@ -1626,28 +1598,26 @@ Key bindings:
1626;;; autoload form instead. 1598;;; autoload form instead.
1627;;;###autoload (autoload 'awk-mode "cc-mode" "Major mode for editing AWK code." t) 1599;;;###autoload (autoload 'awk-mode "cc-mode" "Major mode for editing AWK code." t)
1628 1600
1629(defvar awk-mode-abbrev-table nil
1630 "Abbreviation table used in awk-mode buffers.")
1631(c-define-abbrev-table 'awk-mode-abbrev-table 1601(c-define-abbrev-table 'awk-mode-abbrev-table
1632 '(("else" "else" c-electric-continued-statement 0) 1602 '(("else" "else" c-electric-continued-statement 0)
1633 ("while" "while" c-electric-continued-statement 0))) 1603 ("while" "while" c-electric-continued-statement 0))
1604 "Abbreviation table used in awk-mode buffers.")
1634 1605
1635(defvar awk-mode-map () 1606(defvar awk-mode-map
1607 (let ((map (c-make-inherited-keymap)))
1608 ;; Add bindings which are only useful for awk.
1609 (define-key map "#" 'self-insert-command)
1610 (define-key map "/" 'self-insert-command)
1611 (define-key map "*" 'self-insert-command)
1612 (define-key map "\C-c\C-n" 'undefined) ; #if doesn't exist in awk.
1613 (define-key map "\C-c\C-p" 'undefined)
1614 (define-key map "\C-c\C-u" 'undefined)
1615 (define-key map "\M-a" 'c-beginning-of-statement) ; 2003/10/7
1616 (define-key map "\M-e" 'c-end-of-statement) ; 2003/10/7
1617 (define-key map "\C-\M-a" 'c-awk-beginning-of-defun)
1618 (define-key map "\C-\M-e" 'c-awk-end-of-defun)
1619 map)
1636 "Keymap used in awk-mode buffers.") 1620 "Keymap used in awk-mode buffers.")
1637(if awk-mode-map
1638 nil
1639 (setq awk-mode-map (c-make-inherited-keymap))
1640 ;; add bindings which are only useful for awk.
1641 (define-key awk-mode-map "#" 'self-insert-command)
1642 (define-key awk-mode-map "/" 'self-insert-command)
1643 (define-key awk-mode-map "*" 'self-insert-command)
1644 (define-key awk-mode-map "\C-c\C-n" 'undefined) ; #if doesn't exist in awk.
1645 (define-key awk-mode-map "\C-c\C-p" 'undefined)
1646 (define-key awk-mode-map "\C-c\C-u" 'undefined)
1647 (define-key awk-mode-map "\M-a" 'c-beginning-of-statement) ; 2003/10/7
1648 (define-key awk-mode-map "\M-e" 'c-end-of-statement) ; 2003/10/7
1649 (define-key awk-mode-map "\C-\M-a" 'c-awk-beginning-of-defun)
1650 (define-key awk-mode-map "\C-\M-e" 'c-awk-end-of-defun))
1651 1621
1652(easy-menu-define c-awk-menu awk-mode-map "AWK Mode Commands" 1622(easy-menu-define c-awk-menu awk-mode-map "AWK Mode Commands"
1653 (cons "AWK" (c-lang-const c-mode-menu awk))) 1623 (cons "AWK" (c-lang-const c-mode-menu awk)))
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index d9c482330cc..8c981b36e56 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -624,7 +624,9 @@ You might also use mode hooks to specify it in certain modes, like this:
624 (file-exists-p \"Makefile\")) 624 (file-exists-p \"Makefile\"))
625 (set (make-local-variable 'compile-command) 625 (set (make-local-variable 'compile-command)
626 (concat \"make -k \" 626 (concat \"make -k \"
627 (file-name-sans-extension buffer-file-name))))))" 627 (if buffer-file-name
628 (shell-quote-argument
629 (file-name-sans-extension buffer-file-name))))))))"
628 :type 'string 630 :type 'string
629 :group 'compilation) 631 :group 'compilation)
630;;;###autoload(put 'compile-command 'safe-local-variable (lambda (a) (and (stringp a) (or (not (boundp 'compilation-read-command)) compilation-read-command)))) 632;;;###autoload(put 'compile-command 'safe-local-variable (lambda (a) (and (stringp a) (or (not (boundp 'compilation-read-command)) compilation-read-command))))
@@ -2492,7 +2494,7 @@ displays at the top of the window; there is no arrow."
2492All arguments are markers. If END-MK is non-nil, mark is set there 2494All arguments are markers. If END-MK is non-nil, mark is set there
2493and overlay is highlighted between MK and END-MK." 2495and overlay is highlighted between MK and END-MK."
2494 ;; Show compilation buffer in other window, scrolled to this error. 2496 ;; Show compilation buffer in other window, scrolled to this error.
2495 (let* ((from-compilation-buffer (eq (window-buffer (selected-window)) 2497 (let* ((from-compilation-buffer (eq (window-buffer)
2496 (marker-buffer msg))) 2498 (marker-buffer msg)))
2497 ;; Use an existing window if it is in a visible frame. 2499 ;; Use an existing window if it is in a visible frame.
2498 (pre-existing (get-buffer-window (marker-buffer msg) 0)) 2500 (pre-existing (get-buffer-window (marker-buffer msg) 0))
diff --git a/lisp/progmodes/ebrowse.el b/lisp/progmodes/ebrowse.el
index 6a71ab330a8..865211d109c 100644
--- a/lisp/progmodes/ebrowse.el
+++ b/lisp/progmodes/ebrowse.el
@@ -1605,7 +1605,7 @@ specifies where to find/view the result."
1605 ;; Get the source file to view or find. 1605 ;; Get the source file to view or find.
1606 (setf file (ebrowse-find-source-file file tags-file)) 1606 (setf file (ebrowse-find-source-file file tags-file))
1607 ;; If current window is dedicated, use another frame. 1607 ;; If current window is dedicated, use another frame.
1608 (when (window-dedicated-p (selected-window)) 1608 (when (window-dedicated-p)
1609 (setf where 'other-window)) 1609 (setf where 'other-window))
1610 (cond (view 1610 (cond (view
1611 (setf ebrowse-temp-position-to-view struc 1611 (setf ebrowse-temp-position-to-view struc
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index ff6321d74c3..a7b7e630bb9 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -982,7 +982,7 @@ See documentation of variable `tags-file-name'."
982 ;; selected window's buffer; without the hair, point is moved in both 982 ;; selected window's buffer; without the hair, point is moved in both
983 ;; windows. To prevent this, we save the selected window's point before 983 ;; windows. To prevent this, we save the selected window's point before
984 ;; doing find-tag-noselect, and restore it after. 984 ;; doing find-tag-noselect, and restore it after.
985 (let* ((window-point (window-point (selected-window))) 985 (let* ((window-point (window-point))
986 (tagbuf (find-tag-noselect tagname next-p regexp-p)) 986 (tagbuf (find-tag-noselect tagname next-p regexp-p))
987 (tagpoint (progn (set-buffer tagbuf) (point)))) 987 (tagpoint (progn (set-buffer tagbuf) (point))))
988 (set-window-point (prog1 988 (set-window-point (prog1
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el
index 9bde2900a67..80f663360e4 100644
--- a/lisp/progmodes/f90.el
+++ b/lisp/progmodes/f90.el
@@ -1026,7 +1026,7 @@ Set subexpression 1 in the match-data to the name of the type."
1026 (if (lookup-key (current-local-map) [menu-bar index]) 1026 (if (lookup-key (current-local-map) [menu-bar index])
1027 (message "%s" "F90-imenu already exists.") 1027 (message "%s" "F90-imenu already exists.")
1028 (imenu-add-to-menubar "F90-imenu") 1028 (imenu-add-to-menubar "F90-imenu")
1029 (redraw-frame (selected-frame)))) 1029 (redraw-frame)))
1030 1030
1031 1031
1032;; Abbrevs have generally two letters, except standard types `c, `i, `r, `t. 1032;; Abbrevs have generally two letters, except standard types `c, `i, `r, `t.
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 2ead734d163..ab86b83f7bf 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -353,7 +353,7 @@ Return nil if we cannot, non-nil if we can."
353 'flymake-simple-cleanup)) 353 'flymake-simple-cleanup))
354 354
355(defun flymake-get-real-file-name-function (file-name) 355(defun flymake-get-real-file-name-function (file-name)
356 (or (nth 4 (flymake-get-file-name-mode-and-masks file-name)) 356 (or (nth 2 (flymake-get-file-name-mode-and-masks file-name))
357 'flymake-get-real-file-name)) 357 'flymake-get-real-file-name))
358 358
359(defvar flymake-find-buildfile-cache (flymake-makehash 'equal)) 359(defvar flymake-find-buildfile-cache (flymake-makehash 'equal))
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el
index ff667f80f9d..0fc805aae81 100644
--- a/lisp/progmodes/fortran.el
+++ b/lisp/progmodes/fortran.el
@@ -1080,8 +1080,7 @@ The next key typed is executed unless it is SPC."
1080 fortran-column-ruler-fixed) 1080 fortran-column-ruler-fixed)
1081 (save-excursion 1081 (save-excursion
1082 (beginning-of-line) 1082 (beginning-of-line)
1083 (if (eq (window-start (selected-window)) 1083 (if (eq (window-start) (window-point))
1084 (window-point (selected-window)))
1085 (line-beginning-position 2) 1084 (line-beginning-position 2)
1086 (point))) 1085 (point)))
1087 nil "Type SPC or any command to erase ruler.")) 1086 nil "Type SPC or any command to erase ruler."))
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 4b51a5e7835..2017636435c 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -2951,7 +2951,7 @@ If not in a source or disassembly buffer just set point."
2951 obj) 2951 obj)
2952 (when (numberp pos) 2952 (when (numberp pos)
2953 (with-selected-window (posn-window posn) 2953 (with-selected-window (posn-window posn)
2954 (with-current-buffer (window-buffer (selected-window)) 2954 (with-current-buffer (window-buffer)
2955 (goto-char pos) 2955 (goto-char pos)
2956 (dolist (overlay (overlays-in pos pos)) 2956 (dolist (overlay (overlays-in pos pos))
2957 (when (overlay-get overlay 'put-break) 2957 (when (overlay-get overlay 'put-break)
diff --git a/lisp/progmodes/idlw-toolbar.el b/lisp/progmodes/idlw-toolbar.el
index d255b8b1a3f..98f9ee3b530 100644
--- a/lisp/progmodes/idlw-toolbar.el
+++ b/lisp/progmodes/idlw-toolbar.el
@@ -962,7 +962,7 @@ static char * file[] = {
962 (if (featurep 'xemacs) 962 (if (featurep 'xemacs)
963 nil ; no action necessary, toolbar gets updated automatically 963 nil ; no action necessary, toolbar gets updated automatically
964 ;; On Emacs, redraw the frame to make sure the Toolbar is updated. 964 ;; On Emacs, redraw the frame to make sure the Toolbar is updated.
965 (redraw-frame (selected-frame)))) 965 (redraw-frame)))
966 966
967(provide 'idlw-toolbar) 967(provide 'idlw-toolbar)
968(provide 'idlwave-toolbar) 968(provide 'idlwave-toolbar)
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 28ee859f9db..49a21933133 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -2244,11 +2244,8 @@ current buffer. Pushes a mark onto the tag ring just like
2244 2244
2245;;; MozRepl integration 2245;;; MozRepl integration
2246 2246
2247(put 'js-moz-bad-rpc 'error-conditions '(error timeout)) 2247(define-error 'js-moz-bad-rpc "Mozilla RPC Error") ;; '(timeout error))
2248(put 'js-moz-bad-rpc 'error-message "Mozilla RPC Error") 2248(define-error 'js-js-error "Javascript Error") ;; '(js-error error))
2249
2250(put 'js-js-error 'error-conditions '(error js-error))
2251(put 'js-js-error 'error-message "Javascript Error")
2252 2249
2253(defun js--wait-for-matching-output 2250(defun js--wait-for-matching-output
2254 (process regexp timeout &optional start) 2251 (process regexp timeout &optional start)
diff --git a/lisp/progmodes/mixal-mode.el b/lisp/progmodes/mixal-mode.el
index 8814cdbba35..a14654cdd7c 100644
--- a/lisp/progmodes/mixal-mode.el
+++ b/lisp/progmodes/mixal-mode.el
@@ -1113,8 +1113,10 @@ Assumes that file has been compiled with debugging support."
1113 mixal-syntax-propertize-function) 1113 mixal-syntax-propertize-function)
1114 ;; might add an indent function in the future 1114 ;; might add an indent function in the future
1115 ;; (set (make-local-variable 'indent-line-function) 'mixal-indent-line) 1115 ;; (set (make-local-variable 'indent-line-function) 'mixal-indent-line)
1116 (set (make-local-variable 'compile-command) (concat "mixasm " 1116 (set (make-local-variable 'compile-command)
1117 buffer-file-name))) 1117 (concat "mixasm "
1118 (if buffer-file-name
1119 (shell-quote-argument buffer-file-name)))))
1118 1120
1119(provide 'mixal-mode) 1121(provide 'mixal-mode)
1120 1122
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 62870f9085b..fb2dc01c9be 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)))
@@ -501,29 +501,24 @@ The type returned can be `comment', `string' or `paren'."
501 (,(lambda (limit) 501 (,(lambda (limit)
502 (let ((re (python-rx (group (+ (any word ?. ?_))) 502 (let ((re (python-rx (group (+ (any word ?. ?_)))
503 (? ?\[ (+ (not (any ?\]))) ?\]) (* space) 503 (? ?\[ (+ (not (any ?\]))) ?\]) (* space)
504 assignment-operator))) 504 assignment-operator))
505 (when (re-search-forward re limit t) 505 (res nil))
506 (while (and (python-syntax-context 'paren) 506 (while (and (setq res (re-search-forward re limit t))
507 (re-search-forward re limit t))) 507 (or (python-syntax-context 'paren)
508 (if (not (or (python-syntax-context 'paren) 508 (equal (char-after (point-marker)) ?=))))
509 (equal (char-after (point-marker)) ?=))) 509 res))
510 t
511 (set-match-data nil)))))
512 (1 font-lock-variable-name-face nil nil)) 510 (1 font-lock-variable-name-face nil nil))
513 ;; support for a, b, c = (1, 2, 3) 511 ;; support for a, b, c = (1, 2, 3)
514 (,(lambda (limit) 512 (,(lambda (limit)
515 (let ((re (python-rx (group (+ (any word ?. ?_))) (* space) 513 (let ((re (python-rx (group (+ (any word ?. ?_))) (* space)
516 (* ?, (* space) (+ (any word ?. ?_)) (* space)) 514 (* ?, (* space) (+ (any word ?. ?_)) (* space))
517 ?, (* space) (+ (any word ?. ?_)) (* space) 515 ?, (* space) (+ (any word ?. ?_)) (* space)
518 assignment-operator))) 516 assignment-operator))
519 (when (and (re-search-forward re limit t) 517 (res nil))
520 (goto-char (nth 3 (match-data)))) 518 (while (and (setq res (re-search-forward re limit t))
521 (while (and (python-syntax-context 'paren) 519 (goto-char (match-end 1))
522 (re-search-forward re limit t)) 520 (python-syntax-context 'paren)))
523 (goto-char (nth 3 (match-data)))) 521 res))
524 (if (not (python-syntax-context 'paren))
525 t
526 (set-match-data nil)))))
527 (1 font-lock-variable-name-face nil nil)))) 522 (1 font-lock-variable-name-face nil nil))))
528 523
529(defconst python-syntax-propertize-function 524(defconst python-syntax-propertize-function
@@ -1588,6 +1583,29 @@ This command assumes point is not in a string or comment."
1588 (or arg (setq arg 1)) 1583 (or arg (setq arg 1))
1589 (python-nav-up-list (- arg))) 1584 (python-nav-up-list (- arg)))
1590 1585
1586(defun python-nav-if-name-main ()
1587 "Move point at the beginning the __main__ block.
1588When \"if __name__ == '__main__':\" is found returns its
1589position, else returns nil."
1590 (interactive)
1591 (let ((point (point))
1592 (found (catch 'found
1593 (goto-char (point-min))
1594 (while (re-search-forward
1595 (python-rx line-start
1596 "if" (+ space)
1597 "__name__" (+ space)
1598 "==" (+ space)
1599 (group-n 1 (or ?\" ?\'))
1600 "__main__" (backref 1) (* space) ":")
1601 nil t)
1602 (when (not (python-syntax-context-type))
1603 (beginning-of-line)
1604 (throw 'found t))))))
1605 (if found
1606 (point)
1607 (ignore (goto-char point)))))
1608
1591 1609
1592;;; Shell integration 1610;;; Shell integration
1593 1611
@@ -2119,17 +2137,58 @@ Returns the output. See `python-shell-send-string-no-output'."
2119(define-obsolete-function-alias 2137(define-obsolete-function-alias
2120 'python-send-string 'python-shell-internal-send-string "24.3") 2138 'python-send-string 'python-shell-internal-send-string "24.3")
2121 2139
2140(defun python-shell-buffer-substring (start end &optional nomain)
2141 "Send buffer substring from START to END formatted for shell.
2142This is a wrapper over `buffer-substring' that takes care of
2143different transformations for the code sent to be evaluated in
2144the python shell:
2145 1. When Optional Argument NOMAIN is non-nil everything under an
2146 \"if __name__ == '__main__'\" block will be removed.
2147 2. When a subregion of the buffer is sent, it takes care of
2148 appending extra whitelines so tracebacks are correct.
2149 3. Wraps indented regions under an \"if True:\" block so the
2150 interpreter evaluates them correctly."
2151 (let ((substring (buffer-substring-no-properties start end))
2152 (fillstr (make-string (1- (line-number-at-pos start)) ?\n))
2153 (toplevel-block-p (save-excursion
2154 (goto-char start)
2155 (or (zerop (line-number-at-pos start))
2156 (progn
2157 (python-util-forward-comment 1)
2158 (zerop (current-indentation)))))))
2159 (with-temp-buffer
2160 (python-mode)
2161 (insert fillstr)
2162 (insert substring)
2163 (goto-char (point-min))
2164 (when (not toplevel-block-p)
2165 (insert "if True:")
2166 (delete-region (point) (line-end-position)))
2167 (when nomain
2168 (let* ((if-name-main-start-end
2169 (and nomain
2170 (save-excursion
2171 (when (python-nav-if-name-main)
2172 (cons (point)
2173 (progn (python-nav-forward-sexp)
2174 (point)))))))
2175 ;; Oh destructuring bind, how I miss you.
2176 (if-name-main-start (car if-name-main-start-end))
2177 (if-name-main-end (cdr if-name-main-start-end)))
2178 (when if-name-main-start-end
2179 (goto-char if-name-main-start)
2180 (delete-region if-name-main-start if-name-main-end)
2181 (insert
2182 (make-string
2183 (- (line-number-at-pos if-name-main-end)
2184 (line-number-at-pos if-name-main-start)) ?\n)))))
2185 (buffer-substring-no-properties (point-min) (point-max)))))
2186
2122(defun python-shell-send-region (start end) 2187(defun python-shell-send-region (start end)
2123 "Send the region delimited by START and END to inferior Python process." 2188 "Send the region delimited by START and END to inferior Python process."
2124 (interactive "r") 2189 (interactive "r")
2125 (python-shell-send-string 2190 (python-shell-send-string
2126 (concat 2191 (python-shell-buffer-substring start end) nil t))
2127 (let ((line-num (line-number-at-pos start)))
2128 ;; When sending a region, add blank lines for non sent code so
2129 ;; backtraces remain correct.
2130 (make-string (1- line-num) ?\n))
2131 (buffer-substring start end))
2132 nil t))
2133 2192
2134(defun python-shell-send-buffer (&optional arg) 2193(defun python-shell-send-buffer (&optional arg)
2135 "Send the entire buffer to inferior Python process. 2194 "Send the entire buffer to inferior Python process.
@@ -2138,13 +2197,9 @@ by \"if __name__== '__main__':\""
2138 (interactive "P") 2197 (interactive "P")
2139 (save-restriction 2198 (save-restriction
2140 (widen) 2199 (widen)
2141 (let ((str (buffer-substring (point-min) (point-max)))) 2200 (python-shell-send-string
2142 (and 2201 (python-shell-buffer-substring
2143 (not arg) 2202 (point-min) (point-max) (not arg)))))
2144 (setq str (replace-regexp-in-string
2145 (python-rx if-name-main)
2146 "if __name__ == '__main__ ':" str)))
2147 (python-shell-send-string str))))
2148 2203
2149(defun python-shell-send-defun (arg) 2204(defun python-shell-send-defun (arg)
2150 "Send the current defun to inferior Python process. 2205 "Send the current defun to inferior Python process.
@@ -2271,13 +2326,17 @@ and use the following as the value of this variable:
2271LINE is used to detect the context on how to complete given 2326LINE is used to detect the context on how to complete given
2272INPUT." 2327INPUT."
2273 (let* ((prompt 2328 (let* ((prompt
2274 ;; Get the last prompt for the inferior process 2329 ;; Get last prompt of the inferior process buffer (this
2275 ;; buffer. This is used for the completion code selection 2330 ;; intentionally avoids using `comint-last-prompt' because
2276 ;; heuristic. 2331 ;; of incompatibilities with Emacs 24.x).
2277 (with-current-buffer (process-buffer process) 2332 (with-current-buffer (process-buffer process)
2278 (buffer-substring-no-properties 2333 (save-excursion
2279 (overlay-start comint-last-prompt-overlay) 2334 (buffer-substring-no-properties
2280 (overlay-end comint-last-prompt-overlay)))) 2335 (- (point) (length line))
2336 (progn
2337 (re-search-backward "^")
2338 (python-util-forward-comment)
2339 (point))))))
2281 (completion-context 2340 (completion-context
2282 ;; Check whether a prompt matches a pdb string, an import 2341 ;; Check whether a prompt matches a pdb string, an import
2283 ;; statement or just the standard prompt and use the 2342 ;; statement or just the standard prompt and use the
@@ -3042,32 +3101,22 @@ It must be a function with two arguments: TYPE and NAME.")
3042 "*class definition*" 3101 "*class definition*"
3043 "*function definition*")) 3102 "*function definition*"))
3044 3103
3045(defun python-imenu--put-parent (type name pos num-children tree &optional root) 3104(defun python-imenu--put-parent (type name pos tree)
3046 "Add the parent with TYPE, NAME, POS and NUM-CHILDREN to TREE. 3105 "Add the parent with TYPE, NAME and POS to TREE."
3047Optional Argument ROOT must be non-nil when the node being
3048processed is the root of the TREE."
3049 (let ((label 3106 (let ((label
3050 (funcall python-imenu-format-item-label-function type name)) 3107 (funcall python-imenu-format-item-label-function type name))
3051 (jump-label 3108 (jump-label
3052 (funcall python-imenu-format-parent-item-jump-label-function type name))) 3109 (funcall python-imenu-format-parent-item-jump-label-function type name)))
3053 (if root 3110 (if (not tree)
3054 ;; This is the root, everything is a children. 3111 (cons label pos)
3055 (cons label (cons (cons jump-label pos) tree)) 3112 (cons label (cons (cons jump-label pos) tree)))))
3056 ;; This is node a which may contain some children.
3057 (cons
3058 (cons label (cons (cons jump-label pos)
3059 ;; Append all the children
3060 (python-util-popn tree num-children)))
3061 ;; All previous non-children nodes.
3062 (nthcdr num-children tree)))))
3063 3113
3064(defun python-imenu--build-tree (&optional min-indent prev-indent num-children tree) 3114(defun python-imenu--build-tree (&optional min-indent prev-indent tree)
3065 "Recursively build the tree of nested definitions of a node. 3115 "Recursively build the tree of nested definitions of a node.
3066Arguments MIN-INDENT PREV-INDENT NUM-CHILDREN and TREE are 3116Arguments MIN-INDENT PREV-INDENT and TREE are internal and should
3067internal and should not be passed explicitly unless you know what 3117not be passed explicitly unless you know what you are doing."
3068you are doing." 3118 (setq min-indent (or min-indent 0)
3069 (setq num-children (or num-children 0) 3119 prev-indent (or prev-indent python-indent-offset))
3070 min-indent (or min-indent 0))
3071 (let* ((pos (python-nav-backward-defun)) 3120 (let* ((pos (python-nav-backward-defun))
3072 (type) 3121 (type)
3073 (name (when (and pos (looking-at python-nav-beginning-of-defun-regexp)) 3122 (name (when (and pos (looking-at python-nav-beginning-of-defun-regexp))
@@ -3076,73 +3125,33 @@ you are doing."
3076 (cadr split)))) 3125 (cadr split))))
3077 (label (when name 3126 (label (when name
3078 (funcall python-imenu-format-item-label-function type name))) 3127 (funcall python-imenu-format-item-label-function type name)))
3079 (indent (current-indentation))) 3128 (indent (current-indentation))
3129 (children-indent-limit (+ python-indent-offset min-indent)))
3080 (cond ((not pos) 3130 (cond ((not pos)
3081 ;; No defun found, nothing to add. 3131 ;; Nothing found, probably near to bobp.
3082 tree) 3132 nil)
3083 ((equal indent 0) 3133 ((<= indent min-indent)
3084 (if (> num-children 0) 3134 ;; The current indentation points that this is a parent
3085 ;; Append it as the parent of everything collected to 3135 ;; node, add it to the tree and stop recursing.
3086 ;; this point. 3136 (python-imenu--put-parent type name pos tree))
3087 (python-imenu--put-parent type name pos num-children tree t)
3088 ;; There are no children, this is a lonely defun.
3089 (cons label pos)))
3090 ((equal min-indent indent)
3091 ;; Stop collecting nodes after moving to a position with
3092 ;; indentation equaling min-indent. This is specially
3093 ;; useful for navigating nested definitions recursively.
3094 (if (> num-children 0)
3095 tree
3096 ;; When there are no children, the collected tree is a
3097 ;; single node intended to be added in the list of defuns
3098 ;; of its parent.
3099 (car tree)))
3100 (t 3137 (t
3101 (python-imenu--build-tree 3138 (python-imenu--build-tree
3102 min-indent 3139 min-indent
3103 indent 3140 indent
3104 ;; Add another children, either when this is the 3141 (if (<= indent children-indent-limit)
3105 ;; first call or when indentation is 3142 ;; This lies within the children indent offset range,
3106 ;; less-or-equal than previous. And do not 3143 ;; so it's a normal child of its parent (i.e., not
3107 ;; discard the number of children, because the 3144 ;; a child of a child).
3108 ;; way code is scanned, all children are 3145 (cons (cons label pos) tree)
3109 ;; collected until a root node yet to be found 3146 ;; Oh no, a child of a child?! Fear not, we
3110 ;; appears. 3147 ;; know how to roll. We recursively parse these by
3111 (if (or (not prev-indent) 3148 ;; swapping prev-indent and min-indent plus adding this
3112 (and 3149 ;; newly found item to a fresh subtree. This works, I
3113 (> indent min-indent) 3150 ;; promise.
3114 (<= indent prev-indent))) 3151 (cons
3115 (1+ num-children) 3152 (python-imenu--build-tree
3116 num-children) 3153 prev-indent indent (list (cons label pos)))
3117 (cond ((not prev-indent) 3154 tree)))))))
3118 ;; First call to the function: append this
3119 ;; defun to the index.
3120 (list (cons label pos)))
3121 ((= indent prev-indent)
3122 ;; Add another defun with the same depth
3123 ;; as the previous.
3124 (cons (cons label pos) tree))
3125 ((and (< indent prev-indent)
3126 (< 0 num-children))
3127 ;; There are children to be appended and
3128 ;; the previous defun had more
3129 ;; indentation, the current one must be a
3130 ;; parent.
3131 (python-imenu--put-parent type name pos num-children tree))
3132 ((> indent prev-indent)
3133 ;; There are children defuns deeper than
3134 ;; current depth. Fear not, we already
3135 ;; know how to treat them.
3136 (cons
3137 (prog1
3138 (python-imenu--build-tree
3139 prev-indent indent 0 (list (cons label pos)))
3140 ;; Adjustment: after scanning backwards
3141 ;; for all deeper children, we need to
3142 ;; continue our scan for a parent from
3143 ;; the current defun we are looking at.
3144 (python-nav-forward-defun))
3145 tree))))))))
3146 3155
3147(defun python-imenu-create-index () 3156(defun python-imenu-create-index ()
3148 "Return tree Imenu alist for the current python buffer. 3157 "Return tree Imenu alist for the current python buffer.
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index c8fae7ba1e6..acc7738ae5c 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
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 29020d95226..292bc2369a6 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
@@ -497,6 +496,9 @@ This is buffer-local in every such buffer.")
497 (define-key map "\C-c+" 'sh-add) 496 (define-key map "\C-c+" 'sh-add)
498 (define-key map "\C-\M-x" 'sh-execute-region) 497 (define-key map "\C-\M-x" 'sh-execute-region)
499 (define-key map "\C-c\C-x" 'executable-interpret) 498 (define-key map "\C-c\C-x" 'executable-interpret)
499 (define-key map "\C-c\C-n" 'sh-send-line-or-region-and-step)
500 (define-key map "\C-c\C-d" 'sh-cd-here)
501 (define-key map "\C-c\C-z" 'sh-show-shell)
500 502
501 (define-key map [remap delete-backward-char] 503 (define-key map [remap delete-backward-char]
502 'backward-delete-char-untabify) 504 'backward-delete-char-untabify)
@@ -670,7 +672,9 @@ removed when closing the here document."
670 "." "alias" "bg" "bind" "builtin" "caller" "compgen" "complete" 672 "." "alias" "bg" "bind" "builtin" "caller" "compgen" "complete"
671 "declare" "dirs" "disown" "enable" "fc" "fg" "help" "history" 673 "declare" "dirs" "disown" "enable" "fc" "fg" "help" "history"
672 "jobs" "kill" "let" "local" "popd" "printf" "pushd" "shopt" 674 "jobs" "kill" "let" "local" "popd" "printf" "pushd" "shopt"
673 "source" "suspend" "typeset" "unalias") 675 "source" "suspend" "typeset" "unalias"
676 ;; bash4
677 "mapfile" "readarray")
674 678
675 ;; The next entry is only used for defining the others 679 ;; The next entry is only used for defining the others
676 (bourne sh-append shell 680 (bourne sh-append shell
@@ -734,6 +738,7 @@ implemented as aliases. See `sh-feature'."
734 :type '(repeat (cons (symbol :tag "Shell") 738 :type '(repeat (cons (symbol :tag "Shell")
735 (choice (repeat string) 739 (choice (repeat string)
736 (sexp :format "Evaluate: %v")))) 740 (sexp :format "Evaluate: %v"))))
741 :version "24.4" ; bash4 additions
737 :group 'sh-script) 742 :group 'sh-script)
738 743
739 744
@@ -1462,6 +1467,61 @@ The default is t because I assume that in one Emacs session one is
1462frequently editing existing scripts with different styles.") 1467frequently editing existing scripts with different styles.")
1463 1468
1464 1469
1470;; inferior shell interaction
1471;; TODO: support multiple interactive shells
1472(defvar sh-shell-process nil
1473 "The inferior shell process for interaction.")
1474(make-variable-buffer-local 'sh-shell-process)
1475(defun sh-shell-process (force)
1476 "Get a shell process for interaction.
1477If FORCE is non-nil and no process found, create one."
1478 (if (and sh-shell-process (process-live-p sh-shell-process))
1479 sh-shell-process
1480 (setq sh-shell-process
1481 (let ((found nil) proc
1482 (procs (process-list)))
1483 (while (and (not found) procs
1484 (process-live-p (setq proc (pop procs)))
1485 (process-command proc))
1486 (when (string-equal sh-shell (file-name-nondirectory
1487 (car (process-command proc))))
1488 (setq found proc)))
1489 (or found
1490 (and force
1491 (get-buffer-process
1492 (let ((explicit-shell-file-name sh-shell-file))
1493 (shell)))))))))
1494
1495(defun sh-show-shell ()
1496 "Pop the shell interaction buffer."
1497 (interactive)
1498 (pop-to-buffer (process-buffer (sh-shell-process t))))
1499
1500(defun sh-send-text (text)
1501 "Send the text to the `sh-shell-process'."
1502 (comint-send-string (sh-shell-process t) (concat text "\n")))
1503
1504(defun sh-cd-here ()
1505 "Change directory in the current interaction shell to the current one."
1506 (interactive)
1507 (sh-send-text (concat "cd " default-directory)))
1508
1509(defun sh-send-line-or-region-and-step ()
1510 "Send the current line to the inferior shell and step to the next line.
1511When the region is active, send the region instead."
1512 (interactive)
1513 (let (from to end)
1514 (if (use-region-p)
1515 (setq from (region-beginning)
1516 to (region-end)
1517 end to)
1518 (setq from (line-beginning-position)
1519 to (line-end-position)
1520 end (1+ to)))
1521 (sh-send-text (buffer-substring-no-properties from to))
1522 (goto-char end)))
1523
1524
1465;; mode-command and utility functions 1525;; mode-command and utility functions
1466 1526
1467;;;###autoload 1527;;;###autoload
@@ -2169,6 +2229,7 @@ Calls the value of `sh-set-shell-hook' if set."
2169 (setq font-lock-set-defaults nil) 2229 (setq font-lock-set-defaults nil)
2170 (font-lock-set-defaults) 2230 (font-lock-set-defaults)
2171 (font-lock-fontify-buffer)) 2231 (font-lock-fontify-buffer))
2232 (setq sh-shell-process nil)
2172 (run-hooks 'sh-set-shell-hook)) 2233 (run-hooks 'sh-set-shell-hook))
2173 2234
2174 2235
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index ed911fcbba2..03364bddd9f 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -3256,7 +3256,7 @@ inserted using a single call to `verilog-insert'."
3256(defun verilog-point-text (&optional pointnum) 3256(defun verilog-point-text (&optional pointnum)
3257 "Return text describing where POINTNUM or current point is (for errors). 3257 "Return text describing where POINTNUM or current point is (for errors).
3258Use filename, if current buffer being edited shorten to just buffer name." 3258Use filename, if current buffer being edited shorten to just buffer name."
3259 (concat (or (and (equal (window-buffer (selected-window)) (current-buffer)) 3259 (concat (or (and (equal (window-buffer) (current-buffer))
3260 (buffer-name)) 3260 (buffer-name))
3261 buffer-file-name 3261 buffer-file-name
3262 (buffer-name)) 3262 (buffer-name))