.emacs.d / files / emacs-lisp-mode.el

(require 'thingatpt)

(setq my-emacs-lisp-open-line-list '(

(defun my-emacs-lisp-open-line ()
  "Opens a new line if the point is at the closing parens of
function on `my-emacs-lisp-open-line-list'."
    (when (and (save-excursion
                 (when (listp (sexp-at-point))
                   (memq (car (sexp-at-point)) my-emacs-lisp-open-line-list)))
               (thing-at-point 'sexp)
               (eq (following-char) ?\)))

(defun my-describe-thing-in-buffer ()
  "Display the full documentation of FUNCTION (a symbol) in the help buffer."
  (let ((function (function-called-at-point))
        (variable (variable-at-point)))
     ((/= variable 0) (describe-variable variable))
     (function (describe-function function)))))

;; global elisp settings
(eldoc-in-minibuffer-mode 1)

(defun my-emacs-lisp-init ()
  (with-map-bind-keys emacs-lisp-mode-map
    ("RET" 'my-emacs-lisp-open-line)
    ("C-M-;" 'clippy-describe-function)
    ("C-. ." 'my-describe-thing-in-buffer))

  (set-input-method "english-prog")
  (eldoc-mode 1)
  (letcheck-mode t))

(defun my-wrap-region (beg end)
  (goto-char end)
  (insert ")")
  (goto-char beg)
  (insert "("))

(defun my-goto-dominating-let ()
  "Find dominating let form"
  (while (and (> (car (syntax-ppss)) 0)
              (not (ignore-errors
                       (memq (symbol-at-point) '(let let*))))))))

(defun my-extract-to-let (name &optional arg)
  "Extract the form at point into a variable called NAME placed
in a let form ARG levels up.

If ARG is \\[universal-argument] place the variable into the most
inner let form point is inside of."
  (interactive "sName of variable: \nP")
  (let ((new-vform (sp-get (sp--next-thing-selection) (delete-and-extract-region :beg-prf :end)))
        (raw (sp--raw-argument-p arg))
        (arg (prefix-numeric-value arg)))
          (forward-sexp 2)
          (insert "\n(" name " " new-vform ")")
        (backward-up-list arg)
        (if (> arg 0)
            (sp-get (sp--next-thing-selection) (my-wrap-region :beg-prf :end))
          (insert "()")
        (insert "let ((" name " " new-vform "))\n")
    (if (> arg 0)
        (insert name)
        (insert "\n")

(defun my-merge-let-forms ()
  "Merge the most inner let form into the next outer one."
    (forward-sexp 2)
    (let ((var-list (sp-get (sp--next-thing-selection) (delete-and-extract-region :beg-prf :end))))
      (sp-splice-sexp-killing-backward 1)
      (forward-sexp 2)
      (insert "\n" var-list)
      (backward-up-list 2)

(add-hook 'emacs-lisp-mode-hook 'my-emacs-lisp-init)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.