rolandwalker / button-lock

clickable text in Emacs
42 stars 6 forks source link

Error message #6

Open llcc opened 9 years ago

llcc commented 9 years ago

Hi @rolandwalker

Thanks for your good package. I have a problem by setting a button to make LaTeX package in \usepackage{...} clickable with the following code:

(make-variable-buffer-local
 (defvar *texdoc-buttons* '() "list of texdoc buttons"))

(require 'rx)

(defun* texdocs ()
  (interactive)
  (save-excursion
    (let ((case-fold-search t))
      (goto-char (point-min))
      (while (re-search-forward "\\\\usepackage.*{\\(.+\\)}" nil t)
    (let* ((package1 (match-string 1)))
    (add-to-list '*texdoc-buttons*
             (button-lock-set-button
              (rx word-start (eval package1) word-end)
              (lambda ()
            (interactive)
            (call-process "texdoc" nil 0 nil "--view" (match-string 1))))))))))

But it give me a Wrong type argument: stringp, nil error, do you know what the wrong with this code?

rolandwalker commented 9 years ago

Hi!

I'm not sure where you are getting the error Wrong type argument: stringp, nil. The best way to resolve that is to use Edebug, by placing the point at the end of the definition of texdocs and pressing C-u C-M-x, as described at http://www.gnu.org/software/emacs/manual/html_node/elisp/Using-Edebug.html . After that, invoking texdocs will allow you to step through the function.

However, I can give a few comments on the above code:

llcc commented 9 years ago

@rolandwalker Thanks for your elaborated explanation, I really learned about something from your reply. Your code works like a charm.

Hope you enjoy your every days.