;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/ide/elisp.el (require 'auto-version) (require 'close) (require 'draw) (require 'dwim) (require 'eldoc) (require 'elide-head) (require 'elisp-mode) (require 'fun-names) (require 'ide) (require 'lisp-mode) (require 'mode-line) (require 'package-style) (require 'revert-buffer) (require 'search-regexp-in-files) (require 'super) (defalias 'elisp-mode #'emacs-lisp-mode) (global-eldoc-mode -1) (setq eldoc-idle-delay 0) (setq emacs-lisp-docstring-fill-column t) ; same as fill-column (setq initial-major-mode 'emacs-lisp-mode) (defun count-funs () (let ((func 0) (cmdc 0) (funs)) (mapatoms (lambda (e) (when (functionp e) (cl-incf func) (when (commandp e) (cl-incf cmdc)) (when (zerop (mod func 2000)) (push e funs))))) (insert (format "\n\n;; funs: %s\n" func)) (insert (format ";; cmds: %s\n;;\n" cmdc)) (insert (format ";; %s" funs)) (goto-char (pos-bol)) (prog-fill-reindent-defun))) ;; (count-funs) ;; funs: 9420 ;; cmds: 3177 ;; ;; (fill-text-properties-at completion--cache-all-sorted-completions ;; window-adjust-process-window-size-smallest buffer-enable-undo) ;; funs: 27980 ;; cmds: 7597 ;; ;; (destroy-fringe-bitmap bool-vector-not ;; fill-individual-paragraphs-prefix w3m-url-to-file-name ;; help-fns--interactive-only fill-common-string-prefix ;; widget-boolean-prompt-value ispell-word ;; gnus-score-customize comint-get-next-from-history ;; gnus-group-list-flush custom-face-mark-to-reset-standard ;; keymap-global-set) (defun new-elisp-file () (interactive) (this-file-comment) (lex t) (provide-file) ) (defun provide-file (&optional file) (interactive "fFile: ") (or file (setq file (buffer-file-name))) (goto-char (point-min)) (let*((name (file-name-base file)) (prov (concat "\n(provide '" name ")\n") )) (unless (re-search-forward prov nil t) (goto-char (point-max)) (insert prov) (save-buffer) ))) (defun provide-all () (dolist (f (files-as-list "~/.emacs.d/emacs-init/**/*.el")) (with-current-buffer (find-file-noselect f) (provide-file f) ))) (defun lex (&optional more) (interactive "P") (save-excursion (goto-char (point-min)) (insert ";;; -*- lexical-binding: t -*-\n") (when more (insert ";;\n") ) (save-buffer) )) (defun point-in-comment-p (&optional print) (interactive "p") (let*((cmt (nth 8 (syntax-ppss))) (msg (format "%s comment" (if cmt "Yes:" "No"))) ) (prog1 cmt (when print (message msg) )))) (defun fill-all-comments (&optional beg end) (interactive (use-region)) (or beg (setq beg (point-min))) (or end (setq end (point-max))) (goto-char beg) (while (search-forward-regexp "^;;" end t) (fill-comment-paragraph) )) (defun emacs-lisp-mode-hook-f () (abbrev-mode) (elide-head-mode)) (add-hook 'emacs-lisp-mode-hook #'emacs-lisp-mode-hook-f) ;; (remove-hook 'emacs-lisp-mode-hook #'emacs-lisp-mode-hook-f) (let ((kmap emacs-lisp-mode-map)) (disable-super-global-keys kmap) (keymap-set kmap "C-" #'draw-center-string) (keymap-set kmap "M-_" #'fun-names-short) (keymap-set kmap "C-_" #'fun-names-short) (keymap-set kmap "C-c C-c" #'compile) (keymap-set kmap "C-x C-s" #'auto-version-save) (keymap-set kmap "M-n" #'eval-buffer) (keymap-set kmap "M-r" #'all-elint)) (let ((kmap emacs-lisp-compilation-mode-map)) (disable-super-global-keys kmap) (set-close-key kmap)) (provide 'elisp)