galdor / rfc-mode

An Emacs major mode to read and browse RFC documents.
ISC License
105 stars 10 forks source link

Error on completing-read default argument #15

Closed basil-conto closed 3 years ago

basil-conto commented 3 years ago
  1. emacs -Q -l rfc-mode.el
  2. (setq debug-on-error t
         rfc-mode-browse-input-function #'completing-read
         rfc-mode-directory (make-temp-file "my-rfc-" t))
  3. C-j
  4. 2324 C-a
  5. M-x rfc-mode-browse RET
Debugger entered--Lisp error: (error "Format specifier doesn’t match argument type")
  format("RFC%d" nil)
  (rfc-mode--pad-string (format "RFC%d" (plist-get entry :number)) 7)
  (let* ((ref (rfc-mode--pad-string (format "RFC%d" (plist-get entry :number)) 7)) (title (rfc-mode--pad-string (plist-get entry :title) rfc-mode-browser-entry-title-width)) (status (or (plist-get entry :status) "")) (obsoleted-by (plist-get entry :obsoleted-by)) (obsoletep (> (length obsoleted-by) 0)) (string (format "%s  %s  %s" (rfc-mode--highlight-string ref 'rfc-mode-browser-ref-face) (rfc-mode--highlight-string title (if obsoletep 'rfc-mode-browser-title-obsolete-face 'rfc-mode-browser-title-face)) (rfc-mode--highlight-string status 'rfc-mode-browser-status-face)))) (cons string entry))
  rfc-mode-browser-format-candidate(2324)
  (and default (rfc-mode-browser-format-candidate default))
  (completing-read "View RFC document: " (mapcar #'rfc-mode-browser-format-candidate rfc-mode-index-entries) nil nil nil nil (and default (rfc-mode-browser-format-candidate default)))
  (let* ((default (rfc-mode--integer-at-point)) (choice (completing-read "View RFC document: " (mapcar #'rfc-mode-browser-format-candidate rfc-mode-index-entries) nil nil nil nil (and default (rfc-mode-browser-format-candidate default)))) (number (or (and (string-match "\\`RFC\\([0-9]+\\)" choice) (string-to-number (match-string 1 choice))) (condition-case nil (progn (string-to-number choice)) (error nil))))) (if number nil (user-error "%s doesn't match a complication candidate and is n..." choice)) (display-buffer (rfc-mode--document-buffer number)))
  (let nil (let* ((default (rfc-mode--integer-at-point)) (choice (completing-read "View RFC document: " (mapcar #'rfc-mode-browser-format-candidate rfc-mode-index-entries) nil nil nil nil (and default (rfc-mode-browser-format-candidate default)))) (number (or (and (string-match "\\`RFC\\([0-9]+\\)" choice) (string-to-number (match-string 1 choice))) (condition-case nil (progn (string-to-number choice)) (error nil))))) (if number nil (user-error "%s doesn't match a complication candidate and is n..." choice)) (display-buffer (rfc-mode--document-buffer number))))
  (cond ((eq rfc-mode-browse-input-function 'read-number) (let nil (display-buffer (rfc-mode--document-buffer (read-number "View RFC document: " (rfc-mode--integer-at-point)))))) ((eq rfc-mode-browse-input-function 'helm) (let nil (if (and (require 'helm nil t) (fboundp 'helm)) (helm :buffer "*helm rfc browser*" :sources (rfc-mode-browser-helm-sources rfc-mode-index-entries)) (user-error "Helm has to be installed explicitly")))) ((eq rfc-mode-browse-input-function 'completing-read) (let nil (let* ((default (rfc-mode--integer-at-point)) (choice (completing-read "View RFC document: " (mapcar ... rfc-mode-index-entries) nil nil nil nil (and default ...))) (number (or (and ... ...) (condition-case nil ... ...)))) (if number nil (user-error "%s doesn't match a complication candidate and is n..." choice)) (display-buffer (rfc-mode--document-buffer number))))) (t (let nil (display-buffer (rfc-mode--document-buffer (funcall rfc-mode-browse-input-function))))))
  rfc-mode-browse()
  funcall-interactively(rfc-mode-browse)
  call-interactively(rfc-mode-browse record nil)
  command-execute(rfc-mode-browse record)
  execute-extended-command(nil "rfc-mode-browse" "rfc-mode-br")
  funcall-interactively(execute-extended-command nil "rfc-mode-browse" "rfc-mode-br")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

This happens because rfc-mode-browser-format-candidate expects a plist entry, but is given a number:

https://github.com/galdor/rfc-mode/blob/21c966a02cdd4783dc6ea50b807589abc405d929/rfc-mode.el#L255-L262

basil-conto commented 3 years ago

Should be addressed in PR #16.

galdor commented 3 years ago

I imagine you tested it, so let us merge it :)

Thank you for taking the time to fix them problem.

basil-conto commented 3 years ago

I imagine you tested it

WFM™ :).

Thank you for taking the time to fix them problem.

Thank you for merging PRs at 75% the speed of light, and for the cool mode :).