Created
January 9, 2019 10:07
-
-
Save ustun/58ea028dba5481ef5c7b1afcf69df4b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'ht) | |
(setq log-this-js-log-format "console.log('%s: ', %s)") | |
(setq log-this-python-log-format "print(\"%s: \", %s)") | |
(setq log-this-clojure-log-format "(print \"%s: \" %s)") | |
(setq log-this-log-formats | |
(ht ("typescript-mode" log-this-js-log-format) | |
("js2-mode" log-this-js-log-format) | |
("js-mode" log-this-js-log-format) | |
("python-mode" log-this-python-log-format) | |
("clojure-mode" log-this-clojure-log-format))) | |
(defun log-this-log-format-for-mode () | |
"Gets the format for mode." | |
(ht-get log-this-log-formats (format "%s" major-mode) log-this-js-log-format)) | |
(defun log-this () | |
"Logs the thing at point." | |
(interactive "") | |
(save-excursion | |
(save-restriction | |
(let ((x (thing-at-point 'symbol))) | |
(end-of-line) | |
(newline) | |
(insert (format (log-this-log-format-for-mode) x x)))))) | |
(bind-key "C-M-l" 'log-this) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment