Xah Talk Show 2024-08-15 Ep575, Emacs Lisp, Command to Add HTML Attribute
- 2024-05-08 emacs lisp, write a command xah-html-add-attribute
- Emacs: Xah HTML Mode 📦
- HTML Tutorial
- JavaScript in Depth
- JS: DOM Scripting Tutorial
- JS: Get Element Parent, Child, Sibling
- Emacs: Move Image File 🚀
- Elisp: Get User Input
- Emacs: Search Text in Directory
- Emacs: Xah Find Replace (xah-find.el) 📦
(defun xah-html-add-attribute () "Add an attribute to the current html tag. Created: 2024-08-15 Version: 2024-08-15" (interactive) (let (xbeg xend xtag) ;; first, determine if cursor is inside a opening tag or closing tag. ;; if opening, then use that ;; if closing, then jump to the opening tag ;; but if, cursor is not in any opening or closing tag. thus, it is in an innerText of some tag. ;; you need to find what is that tag. (seq-setq (xbeg xend) (xah-html-select-element)) (deactivate-mark) (goto-char xbeg) ;; (re-search-backward "<[a-z]") (search-forward ">") (backward-char) (insert " ") ;; (insert "id=\"xx\" style=\"xx\"") ;; need to get all current tag's attributes ;; also, we haven't decided, what is the interface ;; e.g. do you want to prompt user for what tag to add. (setq xtag (read-string "what tag to add:")) (insert xtag "=\"something\"")))