0

I have written a helm-extension that at the end shows a list of entries where each entry is like this:

module_name function_name file-path line-number

I am now writing a persistent-action that will open the the file at a particular line number on each entry.

(defun decode-bt--open-file (line &optional persistent)
    (let ((file (match-string 3 line))
          (line-number (string-to-number (match-string 4 line)))
          (text (match-string 2 line)))
      (find-file (if (file-name-absolute-p file) file (concat dir file)))
      (goto-line (line-number))
      (if persistent (helm-highlight-current-line))))

(defun decode-backtrace-command ()
  (interactive)
  (setq backtrace-alist nil)
  (helm :sources '(some-helm-source)
        :truncate-lines t
        :action (lambda (line) (decode-bt--open-file line))
        :persistent-action (lambda (line) (decode-bt--open-file line t))
        :buffer "*helm backtrace*"))

This fails with the following error, Wrong type argument: stringp, nil

What am I doing wrong?

  • 1
    Not sure about the error. But the arguments :action and :persistent-action are part of the helm source itself, they doesn't work with the function helm. – xuchunyang Aug 11 at 10:57
  • nevertheless my function decode-bt--open-file is getting called. So I'm good. But the calling conventions seem to have a problem. and edebug doesn't show me local variables even if I press "v". Says it is not a function call. – maindoor Aug 11 at 17:25
0
(defconst bt-decode--parse-regexp
    "^\\(?:.+ \\)\\{2\\}\\(.+\\) \\([0-9]+\\)")

(defun decode-bt--open-file (line &optional persistent)
  (when (string-match bt-decode--parse-regexp line)
    (let  ((filepath (match-string 1 line))
           (lineno (string-to-number (match-string 2 line))))
        (find-file-other-window filepath)
        (goto-char (point-min))
        (forward-line (1- lineno))
        (helm-highlight-current-line))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.