[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[BUG] "Not enough arguments for format string" from failed fuzzy search
From: |
Corwin Kerr |
Subject: |
[BUG] "Not enough arguments for format string" from failed fuzzy search containing % [9.6.19] |
Date: |
Sat, 24 Feb 2024 15:45:22 -0500 |
User-agent: |
Cyrus-JMAP/3.11.0-alpha0-153-g7e3bb84806-fm-20240215.007-g7e3bb848 |
Hello,
When a search link with a fuzzy expression contains the % character
and is not found in the file, the error message is burried by format
error. This affects ~org-link-search~, ~org-open-file~, etc.
Expected message:
: No match for fuzzy expression: % search bad
Actual message:
: Not enough arguments for format string
I ended up with this search term by storing a link to a comment in a tex file.
Here is the backtrace from how I originally discovered it:
#+begin_src elisp
Debugger entered--Lisp error: (error "Not enough arguments for format string")
format-message("No match for fuzzy expression: % search bad")
apply(format-message "No match for fuzzy expression: % search bad")
error("No match for fuzzy expression: % search bad")
org-open-file(".../bad-file.tex" nil nil "% search bad")
apply(org-open-file ".../bad-file.tex" nil (nil "% search bad"))
org-link-open-as-file(".../bad-file.tex::% how thi..." nil)
org-link-open((link (:type "file" :path ".../bad-file.tex" :format bracket
:raw-link "file:.../bad-file.tex::% ho..." :application nil :search-option "%
search bad" :begin 8347 :end 8450 :contents-begin 8432 :contents-end 8447
:post-blank 1 :parent (paragraph (:begin 8347 :end 8461 :contents-begin 8347
:contents-end 8460 :post-blank 1 :post-affiliated 8347 :mode nil :granularity
element :cached t :parent (section (:begin 8312 :end 8461 :contents-begin 8312
:contents-end 8460 :robust-begin 8312 :robust-end 8458 :post-blank 1
:post-affiliated 8312 :mode section :granularity element :cached t :parent
(headline ...) :org-element--cache-sync-key nil)) :org-element--cache-sync-key
nil)))) nil)
org-open-at-point()
org-open-at-mouse((mouse-2 (#<window 3 on projects.org> 8438 (138 . 355)
272166805 nil 8438 (14 . 16) nil (5 . 5) (11 . 22))))
funcall-interactively(org-open-at-mouse (mouse-2 (#<window 3 on projects.org>
8438 (138 . 355) 272166805 nil 8438 (14 . 16) nil (5 . 5) (11 . 22))))
call-interactively(org-open-at-mouse nil nil)
command-execute(org-open-at-mouse)
#+end_src
* Versions
GNU Emacs 28.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version
10.14.6 (Build 18G95)) of 2023-02-22
Org mode version 9.6.19 (release_9.6.19 @
/Users/Corwin/.emacs.d/straight/repos/org/lisp/)
* Minimal reproduction
#+begin_src tex :tangle bad-file.tex
\begin{document}
% search attempt
\end{document}
#+end_src
#+begin_src elisp :tangle minimal.el
(setq debug-on-error t
debug-on-signal nil
debug-on-quit nil)
;; Add latest Org mode to load path.
(add-to-list 'load-path (expand-file-name
"~/.emacs.d/straight/repos/org/lisp"))
(org-open-file "bad-file.tex" nil nil "% search attempt") ;; works
(org-open-file "bad-file.tex" nil nil "% search bad") ;; error
#+end_src
Running emacs with
: /Applications/Emacs.app/Contents/MacOS/Emacs -Q -l /path/to/minimal.el
Generates this backtrace:
#+begin_src elisp
Debugger entered--Lisp error: (error "Not enough arguments for format string")
format-message("No match for fuzzy expression: % search bad")
apply(format-message "No match for fuzzy expression: % search bad")
error("No match for fuzzy expression: % search bad")
(condition-case err (org-link-search search) (error (funcall
save-position-maybe) (error (nth 1 err))))
(cond (line (org-goto-line line) (if (derived-mode-p 'org-mode) (progn
(org-fold-reveal)))) (search (condition-case err (org-link-search search)
(error (funcall save-position-maybe) (error (nth 1 err))))))
(cond ((org-string-nw-p cmd) (setq cmd (org--open-file-format-command cmd
file link link-match-data)) (let ((wconfig (current-window-configuration)))
(unwind-protect (progn (message "Running %s...done" cmd) (let
((process-connection-type nil)) (start-process-shell-command cmd nil cmd)) (and
(boundp 'org-wait) (numberp org-wait) (sit-for org-wait)))
(set-window-configuration wconfig)))) ((or (stringp cmd) (eq cmd 'emacs))
(funcall (cdr (assq 'file org-link-frame-setup)) file) (widen) (cond (line
(org-goto-line line) (if (derived-mode-p 'org-mode) (progn (org-fold-reveal))))
(search (condition-case err (org-link-search search) (error (funcall
save-position-maybe) (error (nth 1 err))))))) ((functionp cmd) (let
((save-match-data-internal (match-data))) (unwind-protect (progn
(set-match-data link-match-data) (condition-case nil (funcall cmd file link)
((debug wrong-number-of-arguments wrong-type-argument invalid-function)
(user-error "Please see Org News for version 9.0 about `org-fil..." cmd))))
(set-match-data save-match-data-internal 'evaporate)))) ((consp cmd)
(user-error "Please see Org News for version 9.0 about `org-fil..." cmd)) (t
(funcall (cdr (assq 'file org-link-frame-setup)) file)))
(let* ((file (if (equal path "") buffer-file-name (substitute-in-file-name
(expand-file-name path)))) (file-apps (append org-file-apps
(org--file-default-apps))) (apps (cl-remove-if #'org--file-apps-entry-locator-p
file-apps)) (apps-locator (cl-remove-if-not #'org--file-apps-entry-locator-p
file-apps)) (remp (and (assq 'remote apps) (file-remote-p file))) (dirp (if
remp nil (file-directory-p file))) (file (if (and dirp
org-open-directory-means-index-dot-org) (concat (file-name-as-directory file)
"index.org") file)) (a-m-a-p (assq 'auto-mode apps)) (dfile (downcase file))
(link (cond (line (concat file "::" (number-to-string line))) (search (concat
file "::" search)) (t file))) (ext (and (string-match
"\\`.*?\\.\\([a-zA-Z0-9]+\\(\\.gz\\)?\\)\\'" dfile) (match-string 1 dfile)))
(save-position-maybe (let ((old-buffer (current-buffer)) (old-pos (point))
(old-mode major-mode)) #'(lambda nil (and (derived-mode-p ...) (eq old-mode
...) (or ... ...) (org-mark-ring-push old-pos old-buffer))))) cmd
link-match-data) (cond ((member in-emacs '((16) system)) (setq cmd (cdr (assq
'system apps)))) (in-emacs (setq cmd 'emacs)) (t (setq cmd (or (and remp (cdr
(assq ... apps))) (and dirp (cdr (assq ... apps))) (let* ((case-fold-search t)
(match ...)) (if match (progn ... match) (progn ... nil))) (assoc-default dfile
(org--file-apps-regexp-alist apps a-m-a-p) 'string-match) (cdr (assoc ext
apps)) (cdr (assq t apps)))))) (if (eq cmd 'system) (progn (setq cmd (cdr (assq
'system apps))))) (if (eq cmd 'default) (progn (setq cmd (cdr (assoc t
apps))))) (if (eq cmd 'mailcap) (progn (require 'mailcap)
(mailcap-parse-mailcaps) (let* ((mime-type (mailcap-extension-to-mime (or ext
""))) (command (mailcap-mime-info mime-type))) (if (stringp command) (setq cmd
command) (setq cmd 'emacs))))) (if (and (not (eq cmd 'emacs)) (not
(file-exists-p file)) (not org-open-non-existing-files)) (progn (user-error "No
such file: %s" file))) (cond ((org-string-nw-p cmd) (setq cmd
(org--open-file-format-command cmd file link link-match-data)) (let ((wconfig
(current-window-configuration))) (unwind-protect (progn (message "Running
%s...done" cmd) (let (...) (start-process-shell-command cmd nil cmd)) (and
(boundp ...) (numberp org-wait) (sit-for org-wait))) (set-window-configuration
wconfig)))) ((or (stringp cmd) (eq cmd 'emacs)) (funcall (cdr (assq 'file
org-link-frame-setup)) file) (widen) (cond (line (org-goto-line line) (if
(derived-mode-p 'org-mode) (progn (org-fold-reveal)))) (search (condition-case
err (org-link-search search) (error (funcall save-position-maybe) (error
...)))))) ((functionp cmd) (let ((save-match-data-internal (match-data)))
(unwind-protect (progn (set-match-data link-match-data) (condition-case nil
(funcall cmd file link) (... ...))) (set-match-data save-match-data-internal
'evaporate)))) ((consp cmd) (user-error "Please see Org News for version 9.0
about `org-fil..." cmd)) (t (funcall (cdr (assq 'file org-link-frame-setup))
file))) (funcall save-position-maybe))
org-open-file("bad-file.tex" nil nil "% search bad")
eval-buffer(#<buffer *load*> nil
"/Users/Corwin/projects/comp-lang/emacs/minimal.el" nil t) ; Reading at buffer
position 315
load-with-code-conversion("/Users/Corwin/projects/comp-lang/emacs/minimal.el"
"/Users/Corwin/projects/comp-lang/emacs/minimal.el" nil t)
load("/Users/Corwin/projects/comp-lang/emacs/minimal.el" nil t)
command-line-1(("-l" "/Users/Corwin/projects/comp-lang/emacs/minimal.el"))
command-line()
normal-top-level()
#+end_src
- [BUG] "Not enough arguments for format string" from failed fuzzy search containing % [9.6.19],
Corwin Kerr <=