0

To enable smart-dash ("an Emacs minor mode which redefines the dash key to insert an underscore within C-style identifiers and a dash otherwise") after falling in love with Kebab/Lisp case,

I want to check whether current programming language supports Kebab case and activate smart-dash when it doesn't.

Approaches tried:

  • Exhaustively call (add-hook <mode-hook> #'smart-dash-mode) for every known non-Kebab case language.
  • Find current major-mode's syntax, so far I have not found a uniform way, for Common Lisp it's a variable: lisp-mode-symbol-regexp, for Python it's (python-rx (syntax symbol))
  • Utilize smartparens:
(defun smart-dash-maybe (&rest _)
  (when (require 'smartparens)
    (unless (member major-mode (append '(
                                         sh-mode ;commands with "-" are common
                                         cobol-mode forth-mode css-mode ;According to Wikipedia
                                         )
                                       sp-lisp-modes))
      (smart-dash-mode))))

But it requires an external package.

Daanturo
  • 180
  • 8

0 Answers0