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

el-patch-concat macro does not work in templates #72

Open
caadar opened this issue Jul 6, 2024 · 1 comment · May be fixed by #73
Open

el-patch-concat macro does not work in templates #72

caadar opened this issue Jul 6, 2024 · 1 comment · May be fixed by #73

Comments

@caadar
Copy link
Contributor

caadar commented Jul 6, 2024

Emacs version: 29.3
Emacs started as: emacs -Q
OS: Linux (NixOS)

How to reproduce:

(require 'el-patch)
(require 'el-patch-template)
(require 'nameless)

(el-patch-define-and-eval-template
 (define-minor-mode nameless-mode)
 (setq nameless-current-name
       (replace-regexp-in-string (el-patch-concat (el-patch-add "\\\\)?")
                                                  "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'")
                                 "" (lm-get-package-name))))

Eval output:

Debugger entered--Lisp error: (wrong-type-argument listp "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'")
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_16>("\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'")
  el-patch--resolve((el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'") nil #<hash-table equal 0/65 0xba0979>)
  #f(compiled-function (form) #<bytecode 0x1240c20141cf0950>)((el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'"))
  el-patch--resolve(((el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'") "" (lm-get-package-name)) nil #<hash-table equal 0/65 0xba0979>)
  #f(compiled-function (form) #<bytecode 0x1240c20141cf0950>)(((el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'") "" (lm-get-package-name)))
  el-patch--resolve((replace-regexp-in-string (el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'") "" (lm-get-package-name)) nil #<hash-table equal 0/65 0xba0979>)
  #f(compiled-function (form) #<bytecode 0x1240c20141cf0950>)((replace-regexp-in-string (el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'") "" (lm-get-package-name)))
  el-patch--resolve(((replace-regexp-in-string (el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'") "" (lm-get-package-name))) nil #<hash-table equal 0/65 0xba0979>)
  #f(compiled-function (form) #<bytecode 0x1240c20141cf0950>)(((replace-regexp-in-string (el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'") "" (lm-get-package-name))))
  el-patch--resolve((nameless-current-name (replace-regexp-in-string (el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'") "" (lm-get-package-name))) nil #<hash-table equal 0/65 0xba0979>)
  #f(compiled-function (form) #<bytecode 0x1240c20141cf0950>)((nameless-current-name (replace-regexp-in-string (el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'") "" (lm-get-package-name))))
  el-patch--resolve((setq nameless-current-name (replace-regexp-in-string (el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'") "" (lm-get-package-name))) nil)
  el-patch--partial-old-resolve((setq nameless-current-name (replace-regexp-in-string (el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'") "" (lm-get-package-name))))
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_17>((setq nameless-current-name (replace-regexp-in-string (el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'") "" (lm-get-package-name))))
  mapcar(#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_17> ((setq nameless-current-name (replace-regexp-in-string (el-patch-concat (el-patch-add "\\\\)?") "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'") "" (lm-get-package-name)))))
  el-patch--resolve-template(nameless-mode define-minor-mode)
  el-patch-eval-template(nameless-mode define-minor-mode)
  (condition-case err (el-patch-eval-template resolved-name (car qtype-name)) ((debug error) (display-warning 'el-patch (error-message-string err))))
  (let* ((qtype-name '(define-minor-mode nameless-mode)) (resolved-name (el-patch--define-template qtype-name '((setq nameless-current-name (replace-regexp-in-string ... "" ...)))))) (if el-patch-warn-on-eval-template (progn (display-warning 'el-patch "Runtime evaluation of el-patch templates can be sl..."))) (condition-case err (el-patch-eval-template resolved-name (car qtype-name)) ((debug error) (display-warning 'el-patch (error-message-string err)))))
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  command-execute(eval-last-sexp)

(The el-patch-swap macro works as expected here.)

The el-patch-concat macro works just fine with el-patch-define-minor-mode in this case.

@raxod502
Copy link
Member

raxod502 commented Oct 6, 2024

Let's start with adding a unit testing framework, that will help make it faster to fix these sorts of issues and ensure they stay fixed, so issue reports like this don't have to wait as long. I've started in #73 and will continue adding more until the problem is resolved.

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

Successfully merging a pull request may close this issue.

2 participants