Skip to content

Instantly share code, notes, and snippets.

@ustun
Created January 9, 2019 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ustun/58ea028dba5481ef5c7b1afcf69df4b0 to your computer and use it in GitHub Desktop.
Save ustun/58ea028dba5481ef5c7b1afcf69df4b0 to your computer and use it in GitHub Desktop.
(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