masasam / emacs-easy-hugo

Emacs major mode for managing hugo
https://gohugo.io/tools/editors/#emacs
GNU General Public License v3.0
355 stars 26 forks source link

easy-hugo--version() crashed. #57

Closed liuyinz closed 3 years ago

liuyinz commented 3 years ago

hugo version :
("hugo" "v0.81.0+extended" "darwin/amd64" "BuildDate=unknown")

Debug: Debugger entered--Lisp error: (wrong-type-argument arrayp nil) substring(nil 1) (string-to-number (substring (nth 4 source) 1)) (let ((source (split-string (let ((temp-buffer (generate-new-buffer " temp" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ...) (and ... ...)))) " "))) (string-to-number (substring (nth 4 source) 1))) easy-hugo--version() (progn (easy-hugo--version))

liuyinz commented 3 years ago
  ;; HACK fix easy-hugo--view
  (defun easy-hugo--version-patch ()
    "Return the version of hugo."
    (let ((source (split-string
                   (with-temp-buffer
                     (shell-command-to-string (concat easy-hugo-bin " version")))
                   " ")))
      (string-to-number (substring (nth 1 source) 1))))
  (advice-add 'easy-hugo--version :override #'easy-hugo--version-patch)

For now ,I just add the advide to use, change to (substring (nth 1 source)

liuyinz commented 3 years ago

Solved by d5c4e0fef47716ec8eef1bb22db91054a3b51af7

masasam commented 3 years ago

@liuyinz Thanks a lot.