Skip to content

Instantly share code, notes, and snippets.

@JuanCaicedo
Last active January 22, 2018 07:40
Add a spacemacs/emacs keybinding for console.log insertion
;; if using spacemacs, place this code inside dotspacemacs/user-config
;; otherwise, just put it in .emacs
(defun insert-console-log ()
"Insert console.log of the variable at point."
(interactive)
(let ((beg nil)
(end nil))
(back-to-indentation)
(setq beg (point))
(end-of-line)
(setq end (point))
(message "beg %s" beg)
(message "end %s" end)
(message "type of %s" (type-of kill-ring))
(kill-region beg end)
(insert (format "console.log(\"%s\", %s)"
(car kill-ring)
(car kill-ring)))))
;; add keybinding for spacemacs
(spacemacs/set-leader-keys-for-major-mode 'rjsx-mode "l" 'insert-console-log)
;; add keybinding for emacs
(define-key rjsx-mode-map (kbd "C-c C-l") 'insert-console-log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment