aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/compile.el197
-rw-r--r--lisp/progmodes/gdb-ui.el19
-rw-r--r--lisp/progmodes/python.el98
3 files changed, 184 insertions, 130 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index ff4256192c4..71946dd02f5 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -100,7 +100,7 @@ in the compilation output, and should return a transformed file name.")
100;;;###autoload 100;;;###autoload
101(defvar compilation-process-setup-function nil 101(defvar compilation-process-setup-function nil
102 "*Function to call to customize the compilation process. 102 "*Function to call to customize the compilation process.
103This functions is called immediately before the compilation process is 103This function is called immediately before the compilation process is
104started. It can be used to set any variables or functions that are used 104started. It can be used to set any variables or functions that are used
105while processing the output of the compilation process. The function 105while processing the output of the compilation process. The function
106is called with variables `compilation-buffer' and `compilation-window' 106is called with variables `compilation-buffer' and `compilation-window'
@@ -187,8 +187,9 @@ of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil (1))
187 "^\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) :\ 187 "^\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) :\
188 \\(?:warnin\\(g\\)\\|informationa\\(l\\)\\)?" 1 2 3 (4 . 5)) 188 \\(?:warnin\\(g\\)\\|informationa\\(l\\)\\)?" 1 2 3 (4 . 5))
189 189
190 ;; fixme: should be `mips'
190 (irix 191 (irix
191 "^[a-z0-9/]+: \\(?:[eE]rror\\|[wW]arnin\\(g\\)\\|[iI]nf\\(o\\)\\)[0-9 ]*:\ 192 "^[-[:alnum:]_/]+: \\(?:[eE]rror\\|[wW]arnin\\(g\\)\\|[iI]nf\\(o\\)\\)[0-9 ]*:\
192 \\([^,\" \n\t]+\\)\\(?:, line\\|:\\) \\([0-9]+\\):" 3 4 nil (1 . 2)) 193 \\([^,\" \n\t]+\\)\\(?:, line\\|:\\) \\([0-9]+\\):" 3 4 nil (1 . 2))
193 194
194 (java 195 (java
@@ -206,7 +207,7 @@ of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil (1))
206\\(.+\\):\\([0-9]+\\)\\(?:\\(:\\)\\|\\(,\\)\\)?" 1 2 nil (3 . 4)) 207\\(.+\\):\\([0-9]+\\)\\(?:\\(:\\)\\|\\(,\\)\\)?" 1 2 nil (3 . 4))
207 208
208 (gnu 209 (gnu
209 "^\\(?:[a-zA-Z][-a-zA-Z0-9.]+: ?\\)?\ 210 "^\\(?:[[:alpha:]][-[:alnum:].]+: ?\\)?\
210\\([/.]*[a-zA-Z]:?[^ \t\n:]*\\): ?\ 211\\([/.]*[a-zA-Z]:?[^ \t\n:]*\\): ?\
211\\([0-9]+\\)\\([.:]?\\)\\([0-9]+\\)?\ 212\\([0-9]+\\)\\([.:]?\\)\\([0-9]+\\)?\
212\\(?:-\\(?:\\([0-9]+\\)\\3\\)?\\.?\\([0-9]+\\)?\\)?:\ 213\\(?:-\\(?:\\([0-9]+\\)\\3\\)?\\.?\\([0-9]+\\)?\\)?:\
@@ -228,6 +229,7 @@ of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil (1))
228 (1 (compilation-error-properties 2 3 nil nil nil 0 nil) 229 (1 (compilation-error-properties 2 3 nil nil nil 0 nil)
229 append))) 230 append)))
230 231
232 ;; Should be lint-1, lint-2 (SysV lint)
231 (mips-1 233 (mips-1
232 " (\\([0-9]+\\)) in \\([^ \n]+\\)" 2 1) 234 " (\\([0-9]+\\)) in \\([^ \n]+\\)" 2 1)
233 (mips-2 235 (mips-2
@@ -261,15 +263,16 @@ of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil (1))
261 nil 1 nil (3) nil (2 (compilation-face '(3)))) 263 nil 1 nil (3) nil (2 (compilation-face '(3))))
262 264
263 (sun 265 (sun
264 ": \\(?:ERROR\\|WARNIN\\(G\\)\\|REMAR\\(K\\)\\) \\(?:[a-zA-Z0-9 ]+, \\)?\ 266 ": \\(?:ERROR\\|WARNIN\\(G\\)\\|REMAR\\(K\\)\\) \\(?:[[:alnum:] ]+, \\)?\
265File = \\(.+\\), Line = \\([0-9]+\\)\\(?:, Column = \\([0-9]+\\)\\)?" 267File = \\(.+\\), Line = \\([0-9]+\\)\\(?:, Column = \\([0-9]+\\)\\)?"
266 3 4 5 (1 . 2)) 268 3 4 5 (1 . 2))
267 269
268 (sun-ada 270 (sun-ada
269 "^\\([^, \n\t]+\\), line \\([0-9]+\\), char \\([0-9]+\\)[:., \(-]" 1 2 3) 271 "^\\([^, \n\t]+\\), line \\([0-9]+\\), char \\([0-9]+\\)[:., \(-]" 1 2 3)
270 272
271 (ultrix 273 ;; Redundant with `mips'
272 "^\\(?:cfe\\|fort\\): \\(Warning\\)?[^:\n]*: \\([^ \n]*\\), line \\([0-9]+\\):" 2 3 nil (1)) 274;; (ultrix
275;; "^\\(?:cfe\\|fort\\): \\(Warning\\)?[^:\n]*: \\([^ \n]*\\), line \\([0-9]+\\):" 2 3 nil (1))
273 276
274 (4bsd 277 (4bsd
275 "\\(?:^\\|:: \\|\\S ( \\)\\(/[^ \n\t()]+\\)(\\([0-9]+\\))\ 278 "\\(?:^\\|:: \\|\\S ( \\)\\(/[^ \n\t()]+\\)(\\([0-9]+\\))\
@@ -279,14 +282,14 @@ File = \\(.+\\), Line = \\([0-9]+\\)\\(?:, Column = \\([0-9]+\\)\\)?"
279(defcustom compilation-error-regexp-alist 282(defcustom compilation-error-regexp-alist
280 (mapcar 'car compilation-error-regexp-alist-alist) 283 (mapcar 'car compilation-error-regexp-alist-alist)
281 "Alist that specifies how to match errors in compiler output. 284 "Alist that specifies how to match errors in compiler output.
282Note that on Unix exerything is a valid filename, so these 285Note that on Unix everything is a valid filename, so these
283matchers must make some common sense assumptions, which catch 286matchers must make some common sense assumptions, which catch
284normal cases. A shorter list will be lighter on resource usage. 287normal cases. A shorter list will be lighter on resource usage.
285 288
286Instead of an alist element, you can use a symbol, which is 289Instead of an alist element, you can use a symbol, which is
287looked up in `compilation-error-regexp-alist-alist'. You can see 290looked up in `compilation-error-regexp-alist-alist'. You can see
288the predefined symbols and their effects in the file 291the predefined symbols and their effects in the file
289`etc/compilation.txt' (linked below if your are customizing this). 292`etc/compilation.txt' (linked below if you are customizing this).
290 293
291Each elt has the form (REGEXP FILE [LINE COLUMN TYPE HYPERLINK 294Each elt has the form (REGEXP FILE [LINE COLUMN TYPE HYPERLINK
292HIGHLIGHT...]). If REGEXP matches, the FILE'th subexpression 295HIGHLIGHT...]). If REGEXP matches, the FILE'th subexpression
@@ -357,7 +360,7 @@ you may also want to change `compilation-page-delimiter'.")
357 (1 font-lock-variable-name-face) 360 (1 font-lock-variable-name-face)
358 (2 (compilation-face '(4 . 3)))) 361 (2 (compilation-face '(4 . 3))))
359 ;; Command output lines. Recognize `make[n]:' lines too. 362 ;; Command output lines. Recognize `make[n]:' lines too.
360 ("^\\([A-Za-z_0-9/.+-]+\\)\\(\\[\\([0-9]+\\)\\]\\)?[ \t]*:" 363 ("^\\([[:alnum:]_/.+-]+\\)\\(\\[\\([0-9]+\\)\\]\\)?[ \t]*:"
361 (1 font-lock-function-name-face) (3 compilation-line-face nil t)) 364 (1 font-lock-function-name-face) (3 compilation-line-face nil t))
362 (" --?o\\(?:utfile\\|utput\\)?[= ]?\\(\\S +\\)" . 1) 365 (" --?o\\(?:utfile\\|utput\\)?[= ]?\\(\\S +\\)" . 1)
363 ("^Compilation finished" . compilation-info-face) 366 ("^Compilation finished" . compilation-info-face)
@@ -427,7 +430,7 @@ You might also use mode hooks to specify it in certain modes, like this:
427(defvar compilation-locs ()) 430(defvar compilation-locs ())
428 431
429(defvar compilation-debug nil 432(defvar compilation-debug nil
430 "*Set this to `t' before creating a *compilation* buffer. 433 "*Set this to t before creating a *compilation* buffer.
431Then every error line will have a debug text property with the matcher that 434Then every error line will have a debug text property with the matcher that
432fit this line and the match data. Use `describe-text-properties'.") 435fit this line and the match data. Use `describe-text-properties'.")
433 436
@@ -494,7 +497,7 @@ Faces `compilation-error-face', `compilation-warning-face',
494 497
495 498
496;; Used for compatibility with the old compile.el. 499;; Used for compatibility with the old compile.el.
497(defvar compilation-parsing-end nil) 500(defvar compilation-parsing-end (make-marker))
498(defvar compilation-parse-errors-function nil) 501(defvar compilation-parse-errors-function nil)
499(defvar compilation-error-list nil) 502(defvar compilation-error-list nil)
500(defvar compilation-old-error-list nil) 503(defvar compilation-old-error-list nil)
@@ -518,6 +521,7 @@ Faces `compilation-error-face', `compilation-warning-face',
518 '(nil)) ; nil only isn't a property-change 521 '(nil)) ; nil only isn't a property-change
519 (cons (match-string-no-properties idx) dir)) 522 (cons (match-string-no-properties idx) dir))
520 mouse-face highlight 523 mouse-face highlight
524 keymap compilation-button-map
521 help-echo "mouse-2: visit current directory"))) 525 help-echo "mouse-2: visit current directory")))
522 526
523;; Data type `reverse-ordered-alist' retriever. This function retrieves the 527;; Data type `reverse-ordered-alist' retriever. This function retrieves the
@@ -528,6 +532,7 @@ Faces `compilation-error-face', `compilation-warning-face',
528;; may be nil. The other KEYs are ordered backwards so that growing line 532;; may be nil. The other KEYs are ordered backwards so that growing line
529;; numbers can be inserted in front and searching can abort after half the 533;; numbers can be inserted in front and searching can abort after half the
530;; list on average. 534;; list on average.
535(eval-when-compile ;Don't keep it at runtime if not needed.
531(defmacro compilation-assq (key alist) 536(defmacro compilation-assq (key alist)
532 `(let* ((l1 ,alist) 537 `(let* ((l1 ,alist)
533 (l2 (cdr l1))) 538 (l2 (cdr l1)))
@@ -538,7 +543,7 @@ Faces `compilation-error-face', `compilation-warning-face',
538 l2 (cdr l1))) 543 l2 (cdr l1)))
539 (if l2 (eq ,key (caar l2)))) 544 (if l2 (eq ,key (caar l2))))
540 l2 545 l2
541 (setcdr l1 (cons (list ,key) l2)))))) 546 (setcdr l1 (cons (list ,key) l2)))))))
542 547
543 548
544;; This function is the central driver, called when font-locking to gather 549;; This function is the central driver, called when font-locking to gather
@@ -564,7 +569,7 @@ Faces `compilation-error-face', `compilation-warning-face',
564 file (or (if file 569 file (or (if file
565 (nth 2 (car (or (get-text-property (1- file) 'message) 570 (nth 2 (car (or (get-text-property (1- file) 'message)
566 (get-text-property file 'message))))) 571 (get-text-property file 'message)))))
567 ;; no previous either -- let font-lock continue 572 ;; no previous either -- but don't let font-lock fail
568 (gethash (setq file '("*unknown*")) compilation-locs) 573 (gethash (setq file '("*unknown*")) compilation-locs)
569 (puthash file (list file fmt) compilation-locs)))) 574 (puthash file (list file fmt) compilation-locs))))
570 ;; All of these fields are optional, get them only if we have an index, and 575 ;; All of these fields are optional, get them only if we have an index, and
@@ -581,15 +586,54 @@ Faces `compilation-error-face', `compilation-warning-face',
581 (if (and end-col (setq end-col (match-string-no-properties end-col))) 586 (if (and end-col (setq end-col (match-string-no-properties end-col)))
582 (setq end-col (- (string-to-number end-col) compilation-first-column)) 587 (setq end-col (- (string-to-number end-col) compilation-first-column))
583 (if end-line (setq end-col -1))) 588 (if end-line (setq end-col -1)))
584 (if (consp type) ; not a preset type, check what it is. 589 (if (consp type) ; not a static type, check what it is.
585 (setq type (or (and (car type) (match-end (car type)) 1) 590 (setq type (or (and (car type) (match-end (car type)) 1)
586 (and (cdr type) (match-end (cdr type)) 0) 591 (and (cdr type) (match-end (cdr type)) 0)
587 2))) 592 2)))
588 ;; Get any (first) already existing marker (if any has one, all have one). 593 ;; Get first already existing marker (if any has one, all have one).
589 ;; Do this first, as the next assq`s may create new nodes. 594 ;; Do this first, as the compilation-assq`s may create new nodes.
590 (let ((marker (nth 3 (car (cdar (cddr file))))) 595 (let* ((marker-line (car (cddr file))) ; a line structure
591 (loc (compilation-assq line (cdr file))) 596 (marker (nth 3 (cadr marker-line))) ; its marker
592 end-loc) 597 (compilation-error-screen-columns compilation-error-screen-columns)
598 end-marker loc end-loc)
599 (if (not (and marker (marker-buffer marker)))
600 (setq marker) ; no valid marker for this file
601 (setq loc (or line 1) ; normalize no linenumber to line 1
602 marker-line)
603 (catch 'marker ; find nearest loc, at least one exists
604 (dolist (x (cddr file)) ; loop over lines
605 (if (> (or (car x) 1) loc) ; still bigger
606 (setq marker-line x)
607 (if (or (not marker-line) ; first in list
608 (> (- (or (car marker-line) 1) loc)
609 (- loc (or (car x) 1)))) ; current line is nearer
610 (setq marker-line x))
611 (throw 'marker t))))
612 (setq marker (nth 3 (cadr marker-line))
613 marker-line (car marker-line))
614 (with-current-buffer (marker-buffer marker)
615 (save-restriction
616 (widen)
617 (goto-char (marker-position marker))
618 (when (or end-col end-line)
619 (beginning-of-line (- (or end-line line) marker-line -1))
620 (if (< end-col 0)
621 (end-of-line)
622 (if compilation-error-screen-columns
623 (move-to-column end-col)
624 (forward-char end-col)))
625 (setq end-marker (list (point-marker))))
626 (beginning-of-line (if end-line
627 (- end-line line -1)
628 (- loc marker-line -1)))
629 (if col
630 (if compilation-error-screen-columns
631 (move-to-column col)
632 (forward-char col))
633 (forward-to-indentation 0))
634 (setq marker (list (point-marker))))))
635
636 (setq loc (compilation-assq line (cdr file)))
593 (if end-line 637 (if end-line
594 (setq end-loc (compilation-assq end-line (cdr file)) 638 (setq end-loc (compilation-assq end-line (cdr file))
595 end-loc (compilation-assq end-col end-loc)) 639 end-loc (compilation-assq end-col end-loc))
@@ -597,44 +641,10 @@ Faces `compilation-error-face', `compilation-warning-face',
597 (setq end-loc (compilation-assq end-col loc)))) 641 (setq end-loc (compilation-assq end-col loc))))
598 (setq loc (compilation-assq col loc)) 642 (setq loc (compilation-assq col loc))
599 ;; If they are new, make the loc(s) reference the file they point to. 643 ;; If they are new, make the loc(s) reference the file they point to.
600 (or (cdr loc) (setcdr loc (list line file))) 644 (or (cdr loc) (setcdr loc `(,line ,file ,@marker)))
601 (if end-loc 645 (if end-loc
602 (or (cdr end-loc) (setcdr end-loc (list (or end-line line) file)))) 646 (or (cdr end-loc) (setcdr end-loc `(,(or end-line line) ,file ,@end-marker))))
603 ;; If we'd found a marker, ensure that the new locs also get markers 647
604 (when (and marker
605 (not (or (cddr loc) (cddr end-loc))) ; maybe new node w/o marker
606 (marker-buffer marker)) ; other marker still valid
607 (or line (setq line 1)) ; normalize no linenumber to line 1
608 (catch 'marker ; find nearest loc, at least one exists
609 (dolist (x (cddr file))
610 (if (> (or (car x) 1) line)
611 (setq marker x)
612 (if (eq (or (car x) 1) line)
613 (if (cdr (cddr x)) ; at least one other column
614 (throw 'marker (setq marker x))
615 (if marker (throw 'marker t)))
616 (throw 'marker (or marker (setq marker x)))))))
617 (setq marker (if (eq (car (cddr marker)) col)
618 (nthcdr 3 marker)
619 (cddr marker))
620 file compilation-error-screen-columns)
621 (with-current-buffer (marker-buffer (cddr marker))
622 (save-restriction
623 (widen)
624 (goto-char (marker-position (cddr marker)))
625 (beginning-of-line (- line (car (cadr marker)) -1))
626 (if file ; original c.-error-screen-columns
627 (move-to-column (car loc))
628 (forward-char (car loc)))
629 (setcdr (cdr loc) (point-marker))
630 (when end-loc
631 (beginning-of-line (- end-line line -1))
632 (if (< end-col 0)
633 (end-of-line)
634 (if file ; original c.-error-screen-columns
635 (move-to-column (car end-loc))
636 (forward-char (car end-loc))))
637 (setcdr (cdr end-loc) (point-marker))))))
638 ;; Must start with face 648 ;; Must start with face
639 `(face ,compilation-message-face 649 `(face ,compilation-message-face
640 message (,loc ,type ,end-loc) 650 message (,loc ,type ,end-loc)
@@ -686,9 +696,9 @@ Faces `compilation-error-face', `compilation-warning-face',
686 ;; error location. Let's do our best. 696 ;; error location. Let's do our best.
687 `(,(car item) 697 `(,(car item)
688 (0 (compilation-compat-error-properties 698 (0 (compilation-compat-error-properties
689 (funcall ',line (list* (match-string ,file) 699 (funcall ',line (cons (match-string ,file)
690 default-directory 700 (cons default-directory
691 ',(nthcdr 4 item)) 701 ',(nthcdr 4 item)))
692 ,(if col `(match-string ,col))))) 702 ,(if col `(match-string ,col)))))
693 (,file compilation-error-face t)) 703 (,file compilation-error-face t))
694 704
@@ -729,7 +739,7 @@ Faces `compilation-error-face', `compilation-warning-face',
729Runs COMMAND, a shell command, in a separate process asynchronously 739Runs COMMAND, a shell command, in a separate process asynchronously
730with output going to the buffer `*compilation*'. 740with output going to the buffer `*compilation*'.
731 741
732If optional second arg COMINT is t the buffer will be in comint mode with 742If optional second arg COMINT is t the buffer will be in Comint mode with
733`compilation-shell-minor-mode'. 743`compilation-shell-minor-mode'.
734 744
735You can then use the command \\[next-error] to find the next error message 745You can then use the command \\[next-error] to find the next error message
@@ -762,8 +772,8 @@ to a function that generates a unique name."
762;; run compile with the default command line 772;; run compile with the default command line
763(defun recompile () 773(defun recompile ()
764 "Re-compile the program including the current buffer. 774 "Re-compile the program including the current buffer.
765If this is run in a compilation-mode buffer, re-use the arguments from the 775If this is run in a Compilation mode buffer, re-use the arguments from the
766original use. Otherwise, it recompiles using `compile-command'." 776original use. Otherwise, recompile using `compile-command'."
767 (interactive) 777 (interactive)
768 (save-some-buffers (not compilation-ask-about-save) nil) 778 (save-some-buffers (not compilation-ask-about-save) nil)
769 (let ((default-directory (or compilation-directory default-directory))) 779 (let ((default-directory (or compilation-directory default-directory)))
@@ -773,9 +783,9 @@ original use. Otherwise, it recompiles using `compile-command'."
773(defcustom compilation-scroll-output nil 783(defcustom compilation-scroll-output nil
774 "*Non-nil to scroll the *compilation* buffer window as output appears. 784 "*Non-nil to scroll the *compilation* buffer window as output appears.
775 785
776Setting it causes the compilation-mode commands to put point at the 786Setting it causes the Compilation mode commands to put point at the
777end of their output window so that the end of the output is always 787end of their output window so that the end of the output is always
778visible rather than the begining." 788visible rather than the beginning."
779 :type 'boolean 789 :type 'boolean
780 :version "20.3" 790 :version "20.3"
781 :group 'compilation) 791 :group 'compilation)
@@ -822,11 +832,11 @@ Otherwise, construct a buffer name from MODE-NAME."
822The rest of the arguments are optional; for them, nil means use the default. 832The rest of the arguments are optional; for them, nil means use the default.
823 833
824MODE is the major mode to set in the compilation buffer. Mode 834MODE is the major mode to set in the compilation buffer. Mode
825may also be `t' meaning `compilation-shell-minor-mode' under `comint-mode'. 835may also be t meaning use `compilation-shell-minor-mode' under `comint-mode'.
826NAME-FUNCTION is a function called to name the buffer. 836NAME-FUNCTION is a function called to name the buffer.
827 837
828If HIGHLIGHT-REGEXP is non-nil, `next-error' will temporarily highlight 838If HIGHLIGHT-REGEXP is non-nil, `next-error' will temporarily highlight
829matching section of the visited source line; the default is to use the 839the matching section of the visited source line; the default is to use the
830global value of `compilation-highlight-regexp'. 840global value of `compilation-highlight-regexp'.
831 841
832Returns the compilation buffer created." 842Returns the compilation buffer created."
@@ -838,8 +848,8 @@ Returns the compilation buffer created."
838 (process-environment 848 (process-environment
839 (append 849 (append
840 compilation-environment 850 compilation-environment
841 (if (and (boundp 'system-uses-terminfo) 851 (if (if (boundp 'system-uses-terminfo) ; `if' for compiler warning
842 system-uses-terminfo) 852 system-uses-terminfo)
843 (list "TERM=dumb" "TERMCAP=" 853 (list "TERM=dumb" "TERMCAP="
844 (format "COLUMNS=%d" (window-width))) 854 (format "COLUMNS=%d" (window-width)))
845 (list "TERM=emacs" 855 (list "TERM=emacs"
@@ -1136,7 +1146,9 @@ The global commands next/previous/first-error/goto-error use this.")
1136(defconst compilation-turn-on-font-lock 'turn-on-font-lock) 1146(defconst compilation-turn-on-font-lock 'turn-on-font-lock)
1137 1147
1138(defun compilation-setup (&optional minor) 1148(defun compilation-setup (&optional minor)
1139 "Prepare the buffer for the compilation parsing commands to work." 1149 "Prepare the buffer for the compilation parsing commands to work.
1150Optional argument MINOR indicates this is called from
1151`compilation-minor-mode'."
1140 (make-local-variable 'compilation-current-error) 1152 (make-local-variable 'compilation-current-error)
1141 (make-local-variable 'compilation-error-screen-columns) 1153 (make-local-variable 'compilation-error-screen-columns)
1142 (make-local-variable 'overlay-arrow-position) 1154 (make-local-variable 'overlay-arrow-position)
@@ -1145,7 +1157,7 @@ The global commands next/previous/first-error/goto-error use this.")
1145 '(directory message help-echo mouse-face debug)) 1157 '(directory message help-echo mouse-face debug))
1146 (set (make-local-variable 'compilation-locs) 1158 (set (make-local-variable 'compilation-locs)
1147 (make-hash-table :test 'equal :weakness 'value)) 1159 (make-hash-table :test 'equal :weakness 'value))
1148 ;; lazy-lock would never find the message unless it's scrolled to 1160 ;; lazy-lock would never find the message unless it's scrolled to.
1149 ;; jit-lock might fontify some things too late. 1161 ;; jit-lock might fontify some things too late.
1150 (set (make-local-variable 'font-lock-support-mode) nil) 1162 (set (make-local-variable 'font-lock-support-mode) nil)
1151 (set (make-local-variable 'font-lock-maximum-size) nil) 1163 (set (make-local-variable 'font-lock-maximum-size) nil)
@@ -1193,7 +1205,7 @@ Turning the mode on runs the normal hook `compilation-minor-mode-hook'."
1193 (font-lock-fontify-buffer))) 1205 (font-lock-fontify-buffer)))
1194 1206
1195(defun compilation-handle-exit (process-status exit-status msg) 1207(defun compilation-handle-exit (process-status exit-status msg)
1196 "Write msg in the current buffer and hack its mode-line-process." 1208 "Write MSG in the current buffer and hack its mode-line-process."
1197 (let ((buffer-read-only nil) 1209 (let ((buffer-read-only nil)
1198 (status (if compilation-exit-message-function 1210 (status (if compilation-exit-message-function
1199 (funcall compilation-exit-message-function 1211 (funcall compilation-exit-message-function
@@ -1338,7 +1350,7 @@ select the source buffer."
1338 (pop-to-buffer compilation-last-buffer)) 1350 (pop-to-buffer compilation-last-buffer))
1339 1351
1340(defun previous-error-no-select (n) 1352(defun previous-error-no-select (n)
1341 "Move point to the previous error in the compilation buffer and highlight match. 1353 "Move point to previous error in compilation buffer and highlight match.
1342Prefix arg N says how many error messages to move backwards (or 1354Prefix arg N says how many error messages to move backwards (or
1343forwards, if negative). 1355forwards, if negative).
1344Finds and highlights the source line like \\[previous-error], but does not 1356Finds and highlights the source line like \\[previous-error], but does not
@@ -1449,7 +1461,7 @@ See variable `compilation-error-regexp-alist' for customization ideas."
1449 ;; If loc contains no marker, no error in that file has been visited. If 1461 ;; If loc contains no marker, no error in that file has been visited. If
1450 ;; the marker is invalid the buffer has been killed. So, recalculate all 1462 ;; the marker is invalid the buffer has been killed. So, recalculate all
1451 ;; markers for that file. 1463 ;; markers for that file.
1452 (unless (and (nthcdr 3 loc) (marker-buffer (nth 3 loc))) 1464 (unless (and (nth 3 loc) (marker-buffer (nth 3 loc)))
1453 (with-current-buffer (compilation-find-file marker (caar (nth 2 loc)) 1465 (with-current-buffer (compilation-find-file marker (caar (nth 2 loc))
1454 (or (cdar (nth 2 loc)) 1466 (or (cdar (nth 2 loc))
1455 default-directory)) 1467 default-directory))
@@ -1472,7 +1484,7 @@ See variable `compilation-error-regexp-alist' for customization ideas."
1472 (forward-char (car col)))) 1484 (forward-char (car col))))
1473 (beginning-of-line) 1485 (beginning-of-line)
1474 (skip-chars-forward " \t")) 1486 (skip-chars-forward " \t"))
1475 (if (nthcdr 3 col) 1487 (if (nth 3 col)
1476 (set-marker (nth 3 col) (point)) 1488 (set-marker (nth 3 col) (point))
1477 (setcdr (nthcdr 2 col) `(,(point-marker))))))))) 1489 (setcdr (nthcdr 2 col) `(,(point-marker)))))))))
1478 (compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc)) 1490 (compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc))
@@ -1499,6 +1511,32 @@ This operates on the output from the \\[compile] command."
1499 (setq compilation-current-error nil) 1511 (setq compilation-current-error nil)
1500 (next-error n)) 1512 (next-error n))
1501 1513
1514(defun compilation-fake-loc (marker file &optional line col)
1515 "Preassociate MARKER with FILE.
1516This is useful when you compile temporary files, but want
1517automatic translation of the messages to the real buffer from
1518which the temporary file came. This only works if done before a
1519message about FILE appears!
1520
1521Optional args LINE and COL default to 1 and beginning of
1522indentation respectively. The marker is expected to reflect
1523this. In the simplest case the marker points to the first line
1524of the region that was saved to the temp file.
1525
1526If you concatenate several regions into the temp file (e.g. a
1527header with variable assignments and a code region), you must
1528call this several times, once each for the last line of one
1529region and the first line of the next region."
1530 (or (consp file) (setq file (list file)))
1531 (setq file (or (gethash file compilation-locs)
1532 (puthash file (list file nil) compilation-locs)))
1533 (let ((loc (compilation-assq (or line 1) (cdr file))))
1534 (setq loc (compilation-assq col loc))
1535 (if (cdr loc)
1536 (setcdr (cddr loc) (list marker))
1537 (setcdr loc (list (or line 1) file marker)))
1538 loc))
1539
1502(defcustom compilation-context-lines next-screen-context-lines 1540(defcustom compilation-context-lines next-screen-context-lines
1503 "*Display this many lines of leading context before message." 1541 "*Display this many lines of leading context before message."
1504 :type 'integer 1542 :type 'integer
@@ -1506,7 +1544,7 @@ This operates on the output from the \\[compile] command."
1506 :version "21.4") 1544 :version "21.4")
1507 1545
1508(defsubst compilation-set-window (w mk) 1546(defsubst compilation-set-window (w mk)
1509 ;; Align the compilation output window W with marker MK near top. 1547 "Align the compilation output window W with marker MK near top."
1510 (set-window-start w (save-excursion 1548 (set-window-start w (save-excursion
1511 (goto-char mk) 1549 (goto-char mk)
1512 (beginning-of-line (- 1 compilation-context-lines)) 1550 (beginning-of-line (- 1 compilation-context-lines))
@@ -1514,8 +1552,8 @@ This operates on the output from the \\[compile] command."
1514 (set-window-point w mk)) 1552 (set-window-point w mk))
1515 1553
1516(defun compilation-goto-locus (msg mk end-mk) 1554(defun compilation-goto-locus (msg mk end-mk)
1517 "Jump to an error MESSAGE and SOURCE. 1555 "Jump to an error corresponding to MSG at MK.
1518All arguments are markers. If SOURCE-END is non nil, mark is set there." 1556All arguments are markers. If END-MK is non nil, mark is set there."
1519 (if (eq (window-buffer (selected-window)) 1557 (if (eq (window-buffer (selected-window))
1520 (marker-buffer msg)) 1558 (marker-buffer msg))
1521 ;; If the compilation buffer window is selected, 1559 ;; If the compilation buffer window is selected,
@@ -1623,7 +1661,7 @@ Pop up the buffer containing MARKER and scroll to MARKER if we ask the user."
1623 buffer))) 1661 buffer)))
1624 1662
1625(defun compilation-normalize-filename (filename) 1663(defun compilation-normalize-filename (filename)
1626 "Convert a filename string found in an error message to make it usable." 1664 "Convert FILENAME string found in an error message to make it usable."
1627 1665
1628 ;; Check for a comint-file-name-prefix and prepend it if 1666 ;; Check for a comint-file-name-prefix and prepend it if
1629 ;; appropriate. (This is very useful for 1667 ;; appropriate. (This is very useful for
@@ -1691,7 +1729,7 @@ Pop up the buffer containing MARKER and scroll to MARKER if we ask the user."
1691(defun compile-buffer-substring (n) (if n (match-string n))) 1729(defun compile-buffer-substring (n) (if n (match-string n)))
1692 1730
1693(defun compilation-compat-error-properties (err) 1731(defun compilation-compat-error-properties (err)
1694 ;; Map old-style ERROR to new-style MESSAGE. 1732 "Map old-style error ERR to new-style message."
1695 (let* ((dst (cdr err)) 1733 (let* ((dst (cdr err))
1696 (loc (cond ((markerp dst) (list nil nil nil dst)) 1734 (loc (cond ((markerp dst) (list nil nil nil dst))
1697 ((consp dst) 1735 ((consp dst)
@@ -1701,6 +1739,7 @@ Pop up the buffer containing MARKER and scroll to MARKER if we ask the user."
1701 `(face nil 1739 `(face nil
1702 message ,(list loc 2) 1740 message ,(list loc 2)
1703 help-echo "mouse-2: visit the source location" 1741 help-echo "mouse-2: visit the source location"
1742 keymap compilation-button-map
1704 mouse-face highlight))) 1743 mouse-face highlight)))
1705 1744
1706(defun compilation-compat-parse-errors (limit) 1745(defun compilation-compat-parse-errors (limit)
diff --git a/lisp/progmodes/gdb-ui.el b/lisp/progmodes/gdb-ui.el
index 8446266b2f3..b33f8f3f239 100644
--- a/lisp/progmodes/gdb-ui.el
+++ b/lisp/progmodes/gdb-ui.el
@@ -222,6 +222,7 @@ speedbar."
222(defun gdb-goto-info () 222(defun gdb-goto-info ()
223 (interactive) 223 (interactive)
224 (select-frame (make-frame)) 224 (select-frame (make-frame))
225 (require 'info)
225 (Info-goto-node "(emacs)GDB Graphical Interface")) 226 (Info-goto-node "(emacs)GDB Graphical Interface"))
226 227
227(defconst gdb-var-create-regexp 228(defconst gdb-var-create-regexp
@@ -688,9 +689,9 @@ This filter may simply queue output for a later time."
688 (string-to-int (match-string 2 args)))) 689 (string-to-int (match-string 2 args))))
689 (setq gdb-current-address (match-string 3 args)) 690 (setq gdb-current-address (match-string 3 args))
690 (setq gdb-view-source t) 691 (setq gdb-view-source t)
691;; cover for auto-display output which comes *before* 692 ;; cover for auto-display output which comes *before*
692;; stopped annotation 693 ;; stopped annotation
693 (if (eq (gdb-get-output-sink) 'inferior) (gdb-set-output-sink 'user))) 694 (if (eq (gdb-get-output-sink) 'inferior) (gdb-set-output-sink 'user)))
694 695
695(defun gdb-send-item (item) 696(defun gdb-send-item (item)
696 (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log)) 697 (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log))
@@ -1112,7 +1113,8 @@ static char *magick[] = {
1112 (save-excursion 1113 (save-excursion
1113 (goto-line (string-to-number line)) 1114 (goto-line (string-to-number line))
1114 (gdb-put-breakpoint-icon (eq flag ?y))))))))) 1115 (gdb-put-breakpoint-icon (eq flag ?y)))))))))
1115 (end-of-line)))))) 1116 (end-of-line)))))
1117 (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom)))
1116 1118
1117(defun gdb-mouse-toggle-breakpoint (event) 1119(defun gdb-mouse-toggle-breakpoint (event)
1118 "Toggle breakpoint with mouse click in left margin." 1120 "Toggle breakpoint with mouse click in left margin."
@@ -1532,11 +1534,9 @@ the source buffer."
1532 1534
1533(defun gdb-display-source-buffer (buffer) 1535(defun gdb-display-source-buffer (buffer)
1534 (if (eq gdb-selected-view 'source) 1536 (if (eq gdb-selected-view 'source)
1535 (progn
1536 (gdb-display-buffer buffer) 1537 (gdb-display-buffer buffer)
1537 (get-buffer-window buffer)) 1538 (gdb-display-buffer (gdb-get-buffer 'gdb-assembler-buffer)))
1538 (gdb-display-buffer (gdb-get-buffer 'gdb-assembler-buffer)) 1539 (get-buffer-window buffer))
1539 nil))
1540 1540
1541 1541
1542;;; Shared keymap initialization: 1542;;; Shared keymap initialization:
@@ -1612,6 +1612,7 @@ the source buffer."
1612(defun gdb-view-assembler() 1612(defun gdb-view-assembler()
1613 (interactive) 1613 (interactive)
1614 (gdb-display-buffer (gdb-get-create-buffer 'gdb-assembler-buffer)) 1614 (gdb-display-buffer (gdb-get-create-buffer 'gdb-assembler-buffer))
1615 (gdb-invalidate-assembler)
1615 (setq gdb-selected-view 'assembler)) 1616 (setq gdb-selected-view 'assembler))
1616 1617
1617;(defun gdb-view-both() 1618;(defun gdb-view-both()
@@ -1964,7 +1965,7 @@ BUFFER nil or omitted means use the current buffer."
1964 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) 1965 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
1965 (goto-char (point-min)) 1966 (goto-char (point-min))
1966 (forward-line) 1967 (forward-line)
1967 (if (looking-at ".*=\\s-+0x\\(\\S-*\\)\\s-+in\\s-+\\(\\S-*\\)") 1968 (if (looking-at ".*=\\s-+0x\\(\\S-*\\)\\s-+in\\s-+\\(\\S-*?\\);? ")
1968 (progn 1969 (progn
1969 (setq gdb-current-frame (match-string 2)) 1970 (setq gdb-current-frame (match-string 2))
1970 (let ((address (match-string 1))) 1971 (let ((address (match-string 1)))
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index bfa507b851a..7a7e62d06ee 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3,6 +3,7 @@
3;; Copyright (C) 2003, 04 Free Software Foundation, Inc. 3;; Copyright (C) 2003, 04 Free Software Foundation, Inc.
4 4
5;; Author: Dave Love <fx@gnu.org> 5;; Author: Dave Love <fx@gnu.org>
6;; Maintainer: FSF
6;; Created: Nov 2003 7;; Created: Nov 2003
7;; Keywords: languages 8;; Keywords: languages
8 9
@@ -66,10 +67,8 @@
66(require 'comint) 67(require 'comint)
67(eval-when-compile 68(eval-when-compile
68 (require 'compile) 69 (require 'compile)
69 (autoload 'Info-last "info")
70 (autoload 'Info-exit "info")
71 (autoload 'info-lookup-maybe-add-help "info-look")) 70 (autoload 'info-lookup-maybe-add-help "info-look"))
72(autoload 'compilation-start "compile") ; spurious compiler warning anyway 71(autoload 'compilation-start "compile")
73 72
74(defgroup python nil 73(defgroup python nil
75 "Silly walks in the Python language" 74 "Silly walks in the Python language"
@@ -829,7 +828,8 @@ move and return nil. Otherwise return t."
829Makes nested Imenu menus from nested `class' and `def' statements. 828Makes nested Imenu menus from nested `class' and `def' statements.
830The nested menus are headed by an item referencing the outer 829The nested menus are headed by an item referencing the outer
831definition; it has a space prepended to the name so that it sorts 830definition; it has a space prepended to the name so that it sorts
832first with `imenu--sort-by-name'." 831first with `imenu--sort-by-name' (though, unfortunately, sub-menus
832precede it)."
833 (unless (boundp 'python-recursing) ; dynamically bound below 833 (unless (boundp 'python-recursing) ; dynamically bound below
834 (goto-char (point-min))) ; normal call from Imenu 834 (goto-char (point-min))) ; normal call from Imenu
835 (let (index-alist ; accumulated value to return 835 (let (index-alist ; accumulated value to return
@@ -937,32 +937,37 @@ Additional arguments are added when the command is used by `run-python'
937et al.") 937et al.")
938 938
939(defvar python-buffer nil 939(defvar python-buffer nil
940 "*The current python process buffer. 940 "The current python process buffer."
941To run multiple Python processes, start the first with \\[run-python]. 941 ;; Fixme: a single process is currently assumed, so that this doc
942It will be in a buffer named *Python*. Rename that with 942 ;; is misleading.
943\\[rename-buffer]. Now start a new process with \\[run-python]. It 943
944will be in a new buffer, named *Python*. Switch between the different 944;; "*The current python process buffer.
945process buffers with \\[switch-to-buffer]. 945;; To run multiple Python processes, start the first with \\[run-python].
946 946;; It will be in a buffer named *Python*. Rename that with
947Commands that send text from source buffers to Python processes have 947;; \\[rename-buffer]. Now start a new process with \\[run-python]. It
948to choose a process to send to. This is determined by global variable 948;; will be in a new buffer, named *Python*. Switch between the different
949`python-buffer'. Suppose you have three inferior Pythons running: 949;; process buffers with \\[switch-to-buffer].
950 Buffer Process 950
951 foo python 951;; Commands that send text from source buffers to Python processes have
952 bar python<2> 952;; to choose a process to send to. This is determined by global variable
953 *Python* python<3> 953;; `python-buffer'. Suppose you have three inferior Pythons running:
954If you do a \\[python-send-region-and-go] command on some Python source 954;; Buffer Process
955code, what process does it go to? 955;; foo python
956 956;; bar python<2>
957- In a process buffer (foo, bar, or *Python*), send it to that process. 957;; *Python* python<3>
958- In some other buffer (e.g. a source file), send it to the process 958;; If you do a \\[python-send-region-and-go] command on some Python source
959 attached to `python-buffer'. 959;; code, what process does it go to?
960Process selection is done by function `python-proc'. 960
961 961;; - In a process buffer (foo, bar, or *Python*), send it to that process.
962Whenever \\[run-python] starts a new process, it resets `python-buffer' 962;; - In some other buffer (e.g. a source file), send it to the process
963to be the new process's buffer. If you only run one process, this will 963;; attached to `python-buffer'.
964do the right thing. If you run multiple processes, you can change 964;; Process selection is done by function `python-proc'.
965`python-buffer' to another process buffer with \\[set-variable].") 965
966;; Whenever \\[run-python] starts a new process, it resets `python-buffer'
967;; to be the new process's buffer. If you only run one process, this will
968;; do the right thing. If you run multiple processes, you can change
969;; `python-buffer' to another process buffer with \\[set-variable]."
970 )
966 971
967(defconst python-compilation-regexp-alist 972(defconst python-compilation-regexp-alist
968 `((,(rx (and line-start (1+ (any " \t")) "File \"" 973 `((,(rx (and line-start (1+ (any " \t")) "File \""
@@ -971,6 +976,9 @@ do the right thing. If you run multiple processes, you can change
971 1 python-compilation-line-number)) 976 1 python-compilation-line-number))
972 "`compilation-error-regexp-alist' for inferior Python.") 977 "`compilation-error-regexp-alist' for inferior Python.")
973 978
979;; Fixme: This should inherit some stuff from python-mode, but I'm not
980;; sure how much: at least some keybindings, like C-c C-f; syntax?;
981;; font-locking, e.g. for triple-quoted strings?
974(define-derived-mode inferior-python-mode comint-mode "Inferior Python" 982(define-derived-mode inferior-python-mode comint-mode "Inferior Python"
975 "Major mode for interacting with an inferior Python process. 983 "Major mode for interacting with an inferior Python process.
976A Python process can be started with \\[run-python]. 984A Python process can be started with \\[run-python].
@@ -997,7 +1005,8 @@ For running multiple processes in multiple buffers, see `python-buffer'.
997 (add-hook 'comint-input-filter-functions 'python-input-filter nil t) 1005 (add-hook 'comint-input-filter-functions 'python-input-filter nil t)
998 (add-hook 'comint-preoutput-filter-functions #'python-preoutput-filter 1006 (add-hook 'comint-preoutput-filter-functions #'python-preoutput-filter
999 nil t) 1007 nil t)
1000 ;; Still required by `comint-redirect-send-command', for instance: 1008 ;; Still required by `comint-redirect-send-command', for instance
1009 ;; (and we need to match things like `>>> ... >>> '):
1001 (set (make-local-variable 'comint-prompt-regexp) "^\\([>.]\\{3\\} \\)+") 1010 (set (make-local-variable 'comint-prompt-regexp) "^\\([>.]\\{3\\} \\)+")
1002 (set (make-local-variable 'compilation-error-regexp-alist) 1011 (set (make-local-variable 'compilation-error-regexp-alist)
1003 python-compilation-regexp-alist) 1012 python-compilation-regexp-alist)
@@ -1037,11 +1046,15 @@ Used as line-number hook function in `python-compilation-regexp-alist'."
1037 (cons (point-marker) 1046 (cons (point-marker)
1038 (if (and (markerp python-orig-start) 1047 (if (and (markerp python-orig-start)
1039 (marker-buffer python-orig-start)) 1048 (marker-buffer python-orig-start))
1040 (with-current-buffer (marker-buffer python-orig-start) 1049 (let ((start python-orig-start))
1041 (goto-char python-orig-start) 1050 (with-current-buffer (marker-buffer python-orig-start)
1042 (forward-line (1- line))) 1051 (goto-char start)
1043 (list (if (stringp python-orig-start) python-orig-start file) 1052 (forward-line (1- line))
1044 line nil))))) 1053 (point-marker)))
1054 (list (if (stringp python-orig-start)
1055 (list python-orig-start default-directory)
1056 file)
1057 line col)))))
1045 1058
1046(defvar python-preoutput-result nil 1059(defvar python-preoutput-result nil
1047 "Data from output line last `_emacs_out' line seen by the preoutput filter.") 1060 "Data from output line last `_emacs_out' line seen by the preoutput filter.")
@@ -1234,17 +1247,17 @@ module-qualified names."
1234 ;; (set (make-local-variable 'compilation-old-error-list) nil) 1247 ;; (set (make-local-variable 'compilation-old-error-list) nil)
1235 (let ((comint-input-filter-functions 1248 (let ((comint-input-filter-functions
1236 (delete 'python-input-filter comint-input-filter-functions))) 1249 (delete 'python-input-filter comint-input-filter-functions)))
1250 (set (make-local-variable 'python-orig-start) nil)
1251 ;; Fixme: I'm not convinced by this logic from python-mode.el.
1237 (python-send-string 1252 (python-send-string
1238 (if (string-match "\\.py\\'" file-name) 1253 (if (string-match "\\.py\\'" file-name)
1239 ;; Fixme: make sure the directory is in the path list 1254 ;; Fixme: make sure the directory is in the path list
1240 (let ((module (file-name-sans-extension 1255 (let ((module (file-name-sans-extension
1241 (file-name-nondirectory file-name)))) 1256 (file-name-nondirectory file-name))))
1242 (set (make-local-variable 'python-orig-start) nil)
1243 (format "\ 1257 (format "\
1244if globals().has_key(%S): reload(%s) 1258if globals().has_key(%S): reload(%s)
1245else: import %s 1259else: import %s
1246" module module module)) 1260" module module module))
1247 (set (make-local-variable 'python-orig-start) file-name)
1248 (format "execfile('%s')" file-name)))) 1261 (format "execfile('%s')" file-name))))
1249 (set-marker compilation-parsing-end end) 1262 (set-marker compilation-parsing-end end)
1250 (setq compilation-last-buffer (current-buffer)))))) 1263 (setq compilation-last-buffer (current-buffer))))))
@@ -1329,13 +1342,14 @@ Used with `eval-after-load'."
1329 (string-match "^Python \\([0-9]+\\.[0-9]+\\>\\)" s) 1342 (string-match "^Python \\([0-9]+\\.[0-9]+\\>\\)" s)
1330 (match-string 1 s))) 1343 (match-string 1 s)))
1331 ;; Whether info files have a Python version suffix, e.g. in Debian. 1344 ;; Whether info files have a Python version suffix, e.g. in Debian.
1332 (versioned 1345 (versioned
1333 (with-temp-buffer 1346 (with-temp-buffer
1334 (Info-mode) 1347 (with-no-warnings (Info-mode))
1335 (condition-case () 1348 (condition-case ()
1336 ;; Don't use `info' because it would pop-up a *info* buffer. 1349 ;; Don't use `info' because it would pop-up a *info* buffer.
1337 (Info-goto-node (format "(python%s-lib)Miscellaneous Index" 1350 (with-no-warnings
1338 version)) 1351 (Info-goto-node (format "(python%s-lib)Miscellaneous Index"
1352 version)))
1339 (error nil))))) 1353 (error nil)))))
1340 (info-lookup-maybe-add-help 1354 (info-lookup-maybe-add-help
1341 :mode 'python-mode 1355 :mode 'python-mode