]> git.eshelyaron.com Git - emacs.git/commitdiff
Properly align offset in backtrace
authorZach Shaftel <zshaftel@gmail.com>
Fri, 5 Jun 2020 19:06:29 +0000 (15:06 -0400)
committerrocky <rocky@gnu.org>
Sat, 27 Jun 2020 00:05:11 +0000 (20:05 -0400)
* lisp/emacs-lisp/backtrace.el (backtrace--print-flags): Use format
width specifier to line up the flags and offset nicely.

lisp/emacs-lisp/backtrace.el

index ac6b6492790397140eb2676162482635c0ae131d..c3f2ff0cfec67a98c70df28dfc46e1e4af4458f4 100644 (file)
@@ -257,7 +257,7 @@ frames where the source code location is known.")
     map)
   "Local keymap for `backtrace-mode' buffers.")
 
-(defconst backtrace--flags-width 6
+(defconst backtrace--flags-width 7
   "Width in characters of the flags for a backtrace frame.")
 
 ;;; Navigation and Text Properties
@@ -747,12 +747,13 @@ property for use by navigation."
   (let ((beg (point))
         (flag (plist-get (backtrace-frame-flags frame) :debug-on-exit))
         (source (plist-get (backtrace-frame-flags frame) :source-available))
-        (off (plist-get (backtrace-frame-flags frame) :bytecode-offset)))
+        (offset (plist-get (backtrace-frame-flags frame) :bytecode-offset))
+        ;; right justify and pad the offset (or the empty string)
+        (offset-format (format "%%%ds " (- backtrace--flags-width 3))))
     (when (plist-get view :show-flags)
-      (when source (insert ">"))
-      (when flag (insert "*"))
-      (when off (insert (number-to-string off))))
-    (insert (make-string (- backtrace--flags-width (- (point) beg)) ?\s))
+      (insert (if source ">" " "))
+      (insert (if flag "*" " "))
+      (insert (format offset-format (or offset ""))))
     (put-text-property beg (point) 'backtrace-section 'func)))
 
 (defun backtrace--print-func-and-args (frame _view)