emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master f7f4132 21/56: WIP: stab at positioning with column offset


From: Rocky Bernstein
Subject: [elpa] master f7f4132 21/56: WIP: stab at positioning with column offsets
Date: Sat, 27 May 2017 05:02:31 -0400 (EDT)

branch: master
commit f7f4132cebb331eb935a04bc9cd50f4521664324
Author: rocky <address@hidden>
Commit: rocky <address@hidden>

    WIP: stab at positioning with column offsets
---
 realgud/common/buffer/backtrace.el |  2 +-
 realgud/common/buffer/command.el   |  2 ++
 realgud/common/file.el             | 14 ++++++++------
 realgud/common/regexp.el           |  3 ++-
 realgud/common/track.el            | 12 ++++++++++--
 realgud/debugger/jdb/core.el       |  2 +-
 realgud/debugger/trepan/core.el    |  2 +-
 realgud/debugger/trepan2/core.el   |  2 +-
 realgud/lang/python.el             |  2 +-
 test/test-file.el                  |  4 ++--
 test/test-track.el                 | 20 ++++++++++----------
 11 files changed, 39 insertions(+), 26 deletions(-)

diff --git a/realgud/common/buffer/backtrace.el 
b/realgud/common/buffer/backtrace.el
index 816ffdb..b2ffc91 100644
--- a/realgud/common/buffer/backtrace.el
+++ b/realgud/common/buffer/backtrace.el
@@ -461,7 +461,7 @@ filename, line number, whether the frame is selected as 
text properties."
          ))
 
        (when (and (stringp filename) (numberp line-num))
-         (let ((loc (realgud:file-loc-from-line filename line-num cmdbuf)))
+         (let ((loc (realgud:file-loc-from-line filename line-num nil cmdbuf)))
            (put-text-property (match-beginning 0) (match-end 0)
                               'loc loc string)
            ))
diff --git a/realgud/common/buffer/command.el b/realgud/common/buffer/command.el
index bd8aaca..18b874f 100644
--- a/realgud/common/buffer/command.el
+++ b/realgud/common/buffer/command.el
@@ -97,6 +97,7 @@
   line-group
   alt-file-group
   alt-line-group
+  char-offset-group
   text-group
   ignore-file-re
 
@@ -331,6 +332,7 @@ values set in the debugger's init.el."
             :line-group (realgud-sget 'loc-pat 'line-group)
             :alt-file-group (realgud-sget 'loc-pat 'alt-file-group)
             :alt-line-group (realgud-sget 'loc-pat 'alt-line-group)
+            :char-offset-group (realgud-sget 'loc-pat 'char-offset-group)
             :text-group (realgud-sget 'loc-pat 'text-group)
             :ignore-file-re (realgud-sget 'loc-pat 'ignore-file-re)
             :loc-hist (make-realgud-loc-hist)
diff --git a/realgud/common/file.el b/realgud/common/file.el
index cd27057..ae396c2 100644
--- a/realgud/common/file.el
+++ b/realgud/common/file.el
@@ -55,9 +55,8 @@ at LINE-NUMBER or nil if it is not there"
                 (current-column))))))
     (error nil)))
 
-;; FIXME: should allow column number to be passed in.
 (defun realgud:file-loc-from-line(filename line-number
-                                          &optional cmd-marker source-text 
bp-num
+                                          &optional column cmd-marker 
source-text bp-num
                                           ;; FIXME: remove ignore-file-re and 
cover with
                                           ;; find-file-fn.
                                           ignore-file-re find-file-fn 
directory)
@@ -110,9 +109,11 @@ problem as best as we can determine."
                    (if (setq line-count (realgud:file-line-count filename))
                        (if (> line-count line-number)
                            (let* ((column-number
-                                   (realgud:file-column-from-string filename
-                                                                   line-number
-                                                                   
source-text))
+                                   (or column
+                                       (realgud:file-column-from-string 
filename
+                                                                        
line-number
+                                                                        
source-text)
+                                       1))
                                   (source-buffer (find-file-noselect filename))
                                   (source-mark))
 
@@ -120,8 +121,9 @@ problem as best as we can determine."
                              ;; doing something other than validation?
                              (with-current-buffer source-buffer
                                (goto-char (point-min))
-                               ;; FIXME also allow column number and byte 
offset
+                               ;; FIXME allow for byte offset
                                (forward-line (1- line-number))
+                               (forward-char (1- column-number))
                                (make-realgud-loc
                                      :num           bp-num
                                      :cmd-marker    cmd-marker
diff --git a/realgud/common/regexp.el b/realgud/common/regexp.el
index e21de25..55895dc 100644
--- a/realgud/common/regexp.el
+++ b/realgud/common/regexp.el
@@ -45,9 +45,10 @@ output by a debugger inside a process shell"
   (alt-file-group)     ;; Used when regexp is too complicated and use \|
                        ;; e.g. perldb file loc regexps
   (alt-line-group)     ;; ditto
+                       ;; FIXME: separate character offset from beginning
+                       ;; from column number
   (char-offset-group)  ;; Character offset position in struct
   (instruction-address-group)
-  (column-group)
   (ignore-file-re)     ;; Some debuggers create pseudo files in eval strings
                        ;; for example "(eval)" in Ruby and Perl
   (text-group)         ;; Some source text that should found at position
diff --git a/realgud/common/track.el b/realgud/common/track.el
index f26a0ed..c2c8f7b 100644
--- a/realgud/common/track.el
+++ b/realgud/common/track.el
@@ -375,7 +375,7 @@ encountering a new loc."
   )
 
 (defun realgud-track-loc(text cmd-mark &optional opt-regexp opt-file-group
-                          opt-line-group no-warn-on-no-match?
+                          opt-line-group opt-col-group no-warn-on-no-match?
                           opt-ignore-file-re)
   "Do regular-expression matching to find a file name and line number inside
 string TEXT. If we match, we will turn the result into a realgud-loc struct.
@@ -397,6 +397,8 @@ Otherwise return nil."
                           (realgud-sget 'cmdbuf-info 'file-group)))
           (line-group (or opt-line-group
                           (realgud-sget 'cmdbuf-info 'line-group)))
+          (column-group (or opt-col-group
+                            (realgud-sget 'cmdbuf-info 'char-offset-group)))
           (alt-file-group (realgud-sget 'cmdbuf-info 'alt-file-group))
           (alt-line-group (realgud-sget 'cmdbuf-info 'alt-line-group))
           (text-group (realgud-sget 'cmdbuf-info 'text-group))
@@ -410,9 +412,13 @@ Otherwise return nil."
                                     (match-string alt-file-group text)))
                       (line-str (or (match-string line-group text)
                                     (match-string alt-line-group text)))
+                      (column-str
+                       (cond (column-group (match-string column-group text))
+                             ('t "1")))
                       (source-str (and text-group
                                        (match-string text-group text)))
                       (lineno (string-to-number (or line-str "1")))
+                      (column (string-to-number (or column-str "1")))
                       (directory
                        (cond ((boundp 'starting-directory) starting-directory)
                                     (t nil)))
@@ -428,7 +434,7 @@ Otherwise return nil."
                         (unless line-str
                           (message "line number not found -- using 1"))
                         (if (and filename lineno)
-                            (realgud:file-loc-from-line filename lineno
+                            (realgud:file-loc-from-line filename lineno column
                                                         cmd-mark
                                                         source-str nil
                                                         ignore-file-re
@@ -466,6 +472,7 @@ Otherwise return nil. CMD-MARK is set in the realgud-loc 
object created.
                    (loc-regexp     (realgud-loc-pat-regexp loc-pat))
                    (file-group     (realgud-loc-pat-file-group loc-pat))
                    (line-group     (realgud-loc-pat-line-group loc-pat))
+                   (col-group      (realgud-loc-pat-char-offset-group loc-pat))
                    (text-group     (realgud-loc-pat-text-group loc-pat))
                    (ignore-file-re (realgud-loc-pat-ignore-file-re loc-pat))
                    (callback-loc-fn (realgud-sget 'cmdbuf-info 
'callback-loc-fn))
@@ -716,6 +723,7 @@ find a location. non-nil if we can find a location.
                                (realgud-loc-pat-regexp loc-pat)
                                (realgud-loc-pat-file-group loc-pat)
                                (realgud-loc-pat-line-group loc-pat)
+                               (realgud-loc-pat-char-offset-group loc-pat)
                                nil
                                (realgud-loc-pat-ignore-file-re loc-pat)
                                ))
diff --git a/realgud/debugger/jdb/core.el b/realgud/debugger/jdb/core.el
index 34064e1..4392fc1 100644
--- a/realgud/debugger/jdb/core.el
+++ b/realgud/debugger/jdb/core.el
@@ -99,7 +99,7 @@ that works."
 
 (defun realgud:jdb-loc-fn-callback(text filename lineno source-str
                                        ignore-file-re cmd-mark)
-  (realgud:file-loc-from-line filename lineno
+  (realgud:file-loc-from-line filename lineno nil
                              cmd-mark source-str nil
                              ignore-file-re 'realgud:jdb-find-file))
 
diff --git a/realgud/debugger/trepan/core.el b/realgud/debugger/trepan/core.el
index a844208..de3cb35 100644
--- a/realgud/debugger/trepan/core.el
+++ b/realgud/debugger/trepan/core.el
@@ -78,7 +78,7 @@ future, we may also consult RUBYPATH."
 
 (defun realgud:trepan-loc-fn-callback(text filename lineno source-str
                                           ignore-file-re cmd-mark)
-  (realgud:file-loc-from-line filename lineno
+  (realgud:file-loc-from-line filename lineno nil
                              cmd-mark source-str nil nil
                              'realgud:trepan-find-file))
 
diff --git a/realgud/debugger/trepan2/core.el b/realgud/debugger/trepan2/core.el
index ddf9011..93a4ad4 100644
--- a/realgud/debugger/trepan2/core.el
+++ b/realgud/debugger/trepan2/core.el
@@ -87,7 +87,7 @@ we may also consult PYTHONPATH."
 
 (defun realgud:trepan2-loc-fn-callback(text filename lineno source-str
                                            ignore-file-re cmd-mark)
-  (realgud:file-loc-from-line filename lineno
+  (realgud:file-loc-from-line filename lineno nil
                              cmd-mark source-str nil nil
                              'realgud:trepan2-find-file))
 
diff --git a/realgud/lang/python.el b/realgud/lang/python.el
index 2f41136..6e7b731 100644
--- a/realgud/lang/python.el
+++ b/realgud/lang/python.el
@@ -176,7 +176,7 @@ traceback) line."  )
 
 (defconst realgud-flake8-msg-loc-pat
   (make-realgud-loc-pat
-   :regexp "^\\(.*\\):\\([0-9]+\\):\\([0-9]+\\): [EW]\\([0-9]+\\) "
+   :regexp "^\\(.*\\):\\([0-9]+\\):\\([0-9]+\\): [EFW]\\([0-9]+\\) "
    :file-group 1
    :line-group 2
    :char-offset-group 3
diff --git a/test/test-file.el b/test/test-file.el
index e9129d4..3164624 100644
--- a/test/test-file.el
+++ b/test/test-file.el
@@ -68,12 +68,12 @@
   (assert-t (stringp (realgud:file-loc-from-line test-filename 10001))
            "Line number too large for file")
 
-  (setq test-file-loc (realgud:file-loc-from-line (__FILE__) 5 nil ";; Note"))
+  (setq test-file-loc (realgud:file-loc-from-line (__FILE__) 5 nil nil ";; 
Note"))
   (assert-t (realgud-loc? test-file-loc)
            "Ok loc creation - no cmd marker")
 
   (assert-t (realgud-loc?
-            (realgud:file-loc-from-line test-filename 30 (make-marker)))
+            (realgud:file-loc-from-line test-filename 30 nil (make-marker)))
            "Ok loc creation - cmd marker")
 
   (assert-equal 5 (realgud-loc-line-number test-file-loc))
diff --git a/test/test-track.el b/test/test-track.el
index 5e98fec..d50e283 100644
--- a/test/test-track.el
+++ b/test/test-track.el
@@ -28,6 +28,7 @@
   (defvar line-number)
   (defvar realgud-pat-hash)
   (defvar test-filename)
+  (defvar test-loc)
 )
 
 ;; Some setup usually done in setting up the buffer.
@@ -43,16 +44,15 @@
 (setq line-number 7)
 (setq debugger-output (format "-> (%s:%d)\nrequire 'foo'\n(trepan):\n"
                              test-filename line-number))
-(let ((loc (realgud-track-loc debugger-output nil)))
-  (assert-t (realgud-loc-p loc)   "loc extracted")
-  (assert-equal "(trepan):\n"
-               (realgud-track-loc-remaining debugger-output)
-               "loc-remaining")
-  (assert-equal test-filename (realgud-loc-filename loc)
-               "loc filename extracted")
-  (assert-equal line-number (realgud-loc-line-number loc)
-               "loc line-number extracted")
-  )
+(setq test-loc (realgud-track-loc debugger-output nil))
+(assert-t (realgud-loc-p test-loc)   "loc extracted")
+(assert-equal "(trepan):\n"
+             (realgud-track-loc-remaining debugger-output)
+             "loc-remaining")
+(assert-equal test-filename (realgud-loc-filename test-loc)
+             "loc filename extracted")
+(assert-equal line-number (realgud-loc-line-number test-loc)
+             "loc line-number extracted")
 
 (note "realgud-track-selected-frame")
 (setq debugger-output "up



reply via email to

[Prev in Thread] Current Thread [Next in Thread]