emacs - How to query syntax class constituents as string of char? -
using elisp trying convert emacs syntax class \s_ string of characters constitute class using syntax table. have not been able find reference code or example identify.
does have reference or code snippet share?
thanks, matt
update 1 : after further reading, have found table can traversed map-char-table, accumulating required characters.
some utilities in use here
https://launchpad.net/s-x-emacs-werkstatt/
(defun ar-syntax-class-atpt (&optional pos) "return syntax class part of syntax @ point. " (interactive) (let* ((pos (or pos (point))) (erg (logand (car (syntax-after pos)) 65535))) (when (interactive-p) (message "%s" erg)) erg)) (defun syntax-class-bfpt () "return syntax class part of syntax @ point. " (interactive) (let ((erg (logand (car (syntax-after (1- (point)))) 65535))) (when (interactive-p) (message "%s" erg)) erg)) (defun ar-syntax-atpt (&optional docu pos) (interactive) (when pos (goto-char pos)) (let* ((elt (car (if (featurep 'xemacs) (char-syntax (char-after)) (syntax-after (point))))) (stax (cond ((eq elt 0) "0 whitespace") ((eq elt 5) "5 close parenthesis") ((eq elt 10) "10 character quote") ((eq elt 1) "1 punctuation") ((eq elt 6) "6 expression prefix") ((eq elt 11) "11 comment-start") ((eq elt 2) "2 word") ((eq elt 7) "7 string quote") ((eq elt 12) "12 comment-end") ((eq elt 3) "3 symbol") ((eq elt 8) "8 paired delimiter") ((eq elt 13) "13 inherit") ((eq elt 4) "4 open parenthesis") ((eq elt 9) "9 escape") ((eq elt 14) "14 generic comment") ((eq elt 15) "15 generic string")))) (when (interactive-p) (message (format "%s" stax))) (if docu (format "%s" stax) elt))) (defun ar-syntax-in-region-atpt (beg end) (interactive "r") (save-excursion (goto-char beg) (let (erg) (while (< (point) end) (setq erg (concat erg "\n" "\"" (char-to-string (char-after)) "\"" " " (ar-syntax-atpt t))) (forward-char 1)) (message "%s" erg) erg))) (defun syntax-bfpt () (interactive) (let ((stax (syntax-after (1- (point))))) (when (interactive-p) (message (format "%s" stax))) stax))
Comments
Post a Comment