Here is my attempt at a solution (assuming you want to expose MySQL keywords)
(defun point-in-comment () (let ((syn (syntax-ppss))) (and (nth 8 syn) (not (nth 3 syn))))) (defun my-capitalize-all-mysql-keywords () (interactive) (require 'sql) (save-excursion (dolist (keywords sql-mode-mysql-font-lock-keywords) (goto-char (point-min)) (while (re-search-forward (car keywords) nil t) (unless (point-in-comment) (goto-char (match-beginning 0)) (upcase-word 1))))))
After evaluating this function, just Mx my-capitalize-all-mysql-keywords RET . The advantage of this solution is that it selects keywords from Emacs sql-mode , you do not need to specify them.
I also suggested that you mean that you want upcase words
user2053036
source share