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 do I successfully add a new filter to emmet-filters? #120

Open
stephenwithav opened this issue Apr 10, 2020 · 2 comments
Open

How do I successfully add a new filter to emmet-filters? #120

stephenwithav opened this issue Apr 10, 2020 · 2 comments

Comments

@stephenwithav
Copy link

stephenwithav commented Apr 10, 2020

Goal: Use emmet-mode to successfully generate TensorFlow code in Python. (e.g., Dense*3 returns layer.Dense() three times.)

Approach: add "py" mapping to emmet-filters and emmet-default-filter, along with the accompanying json in preferences.json.

Result: emmet-filters fails to include "py" entry when debugging email-process-filter, so no work is done.

Question: Do you have any idea why emmet-filters lacks the "py" entry?

(defvar emmet-filters
  '("html" (emmet-primary-filter emmet-make-html-tag)
    "c"    (emmet-primary-filter emmet-make-commented-html-tag)
    "haml" (emmet-primary-filter emmet-make-haml-tag)
    "hic"  (emmet-primary-filter emmet-make-hiccup-tag)
    "py"   (emmet-primary-filter emmet-make-python-tag)
    "e"    (emmet-escape-xml)))

...

(defun emmet-default-filter ()
  "Default filter(s) to be used if none is specified."
  (let* ((file-ext (car (emmet-regex ".*\\(\\..*\\)" (or (buffer-file-name) "") 1)))
         (defaults '(".html" ("html")
                     ".htm"  ("html")
                     ".haml" ("haml")
                     ".py"   ("py")
                     ".clj"  ("hic")))
         (default-else      '("html"))
         (selected-default (member file-ext defaults)))
    (if selected-default
        (cadr selected-default)
      default-else)))
  "py": {
    "tags": {
      "dense":      {"block": false, "selfClosing": false, "defaultAttr": {"units": ""}}
    }
  }
(defun emmet-process-filter (filters input)
  "Process filters, chain one filter output as the input of the next filter."
  (debug)
  (let ((filter-data (member (car filters) emmet-filters))
        (more-filters (cdr filters)))
    (if filter-data
        (let* ((proc   (cadr filter-data))
               (fun    (car proc))
               (filter-output (funcall fun input proc)))
          (if more-filters
              (emmet-process-filter more-filters filter-output)
            filter-output))
      nil)))
@stephenwithav
Copy link
Author

@pobocks
Copy link
Collaborator

pobocks commented Apr 10, 2020

I haven't checked it out and tested it, but one thing I'm immediately seeing is that this is showing up in the src/ directory files, but not the compiled el - emmet-mode has a build step using make that I think you didn't run.

Details (well, instructions, anyway, they're not very detailed) are here: https://github.com/smihica/emmet-mode/#development-notes

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

No branches or pull requests

2 participants