Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to patch vector literal given with backticks #51

Closed
legendre6891 opened this issue Feb 18, 2021 · 2 comments
Closed

How to patch vector literal given with backticks #51

legendre6891 opened this issue Feb 18, 2021 · 2 comments

Comments

@legendre6891
Copy link

Thanks for the great package, Radon!

I'm having a bit of trouble figuring out how to patch the following defconst found in flycheck.

(defconst flycheck-error-list-format
  `[("File" 6)
    ("Line" 5 flycheck-error-list-entry-< :right-align t)
    ("Col" 3 nil :right-align t)
    ("Level" 8 flycheck-error-list-entry-level-<)
    ("ID" 6 t)
    (,(flycheck-error-list-make-last-column "Message" 'Checker) 0 t)]
  "Table format for the error list.")

Here is a reproducible example

(use-package el-patch
  :demand t
  :straight t)

(use-package flycheck
  :straight t)

(el-patch-feature flycheck)
(with-eval-after-load 'flycheck
  (el-patch-defconst flycheck-error-list-format
    `[("File" 6)
      ("Line" 5 flycheck-error-list-entry-< :right-align t)
      ("Col" 3 nil :right-align t)
      ("Level" 8 flycheck-error-list-entry-level-<)
      ("ID" (el-patch-swap 6 20) t)
      (,(flycheck-error-list-make-last-column "Message" 'Checker) 0 t)]
    "Table format for the error list."))

Unfortunately, I just can't figure out the right combination of backticks to use to make the patch validate. I believe there is an incompatibility with nested backticks? For example,

(with-eval-after-load 'flycheck
  (el-patch-defconst flycheck-error-list-format
    `[("File" 6)
      ("Line" 5 flycheck-error-list-entry-< :right-align t)
      ("Col" 3 nil :right-align t)
      ("Level" 8 flycheck-error-list-entry-level-<)
      ("ID" ,(el-patch-swap 6 20) t)
      (,(flycheck-error-list-make-last-column "Message" 'Checker) 0 t)]
    "Table format for the error list."))

throws an error Debugger entered--Lisp error: (error "Can’t use ‘el-patch-swap’ outside of an ‘el-patch’"). Is there an actual bug or am I misunderstanding?

raxod502 added a commit that referenced this issue Feb 19, 2021
@raxod502
Copy link
Member

Thanks for the report. This should be fixed now. (The problem was the vector literal, not the backticks.)

@legendre6891
Copy link
Author

Thanks for the fix — works beautifully! (Thanks for the pointer also; I’m learning a lot about Elisp and general software development guidance from reading your code.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants