aki2o / emacs-tss

Provide a interface for auto-complete.el/flymake.el on typescript-mode.
108 stars 17 forks source link

derive typscript-mode from prog-mode #10

Closed jschaf closed 9 years ago

jschaf commented 9 years ago

prog-mode is useful because you can add hooks to prog-mode-hook

aki2o commented 9 years ago

Hi, @jschaf Thanks for your pull request. I have some question.

I've found prog-mode is used in js2-mode. But I don't know how to use prog-mode. How case prog-mode-hook is used?

It seems that prog-mode requires Emacs 24 or higher. I think we should use the code like the following coffee-mode.el code.

;; For compatibility with Emacs < 24, derive conditionally
(defalias 'coffee-parent-mode
  (if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode))

;;;###autoload
(define-derived-mode coffee-mode coffee-parent-mode "Coffee"
  "Major mode for editing CoffeeScript."
jschaf commented 9 years ago

prog-mode is used solely for deriving new modes. It allows you to apply customizations to all programming buffers.

I use prog-mode like so:

;; All programming modes
(my:add-hooks 'prog-mode-hook
  '(my:add-watchwords ;; highlight TODO
    my:delete-trailing-whitespace-before-save
    my:local-comment-auto-fill))

(defun my:delete-trailing-whitespace-before-save ()
  "Add `delete-trailing-whitespace' to the local `after-save-hook'."
  (add-hook (make-local-variable 'before-save-hook)
            'my:delete-trailing-whitespace-except-current-line))

Emacs 24 was released over two years ago. I don't think it's worth the effort to support Emacs 23, but I'll add an alias like coffee-mode if you want.

aki2o commented 9 years ago

I think so about support lower versions than 24. But, if it's easy, I think it might be better to support. So, I would appreciate it.

jschaf commented 9 years ago

Too easy, gimme a second and I'll push it.

MichaelXavier commented 9 years ago

Friendly bump on this. Would love to have this.

jschaf commented 9 years ago

Just rebased, should be good to merge

aki2o commented 9 years ago

Thanks!!!