al-elisp.el 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ;;; al-elisp.el --- Additional functionality for elisp, eldoc
  2. ;; Copyright © 2013-2016 Alex Kost
  3. ;; This program is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation, either version 3 of the License, or
  6. ;; (at your option) any later version.
  7. ;; This program is distributed in the hope that it will be useful,
  8. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ;; GNU General Public License for more details.
  11. ;; You should have received a copy of the GNU General Public License
  12. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ;;; Code:
  14. (require 'pp)
  15. ;;;###autoload
  16. (defun al/pp-eval-expression (expression)
  17. "Same as `pp-eval-expression' but without \"Evaluating...\" message."
  18. (interactive
  19. (list (read--expression "Eval: ")))
  20. (setq values (cons (eval expression) values))
  21. (pp-display-expression (car values) "*Pp Eval Output*"))
  22. ;;;###autoload
  23. (defun al/eval-dwim (arg)
  24. "Eval last sexp or region if it is active.
  25. ARG is passed to `eval-last-sexp'."
  26. (interactive "P")
  27. (if (use-region-p)
  28. (eval-region (region-beginning) (region-end))
  29. (eval-last-sexp arg)))
  30. ;;;###autoload
  31. (defun al/pp-eval-dwim (arg)
  32. "Eval last sexp or region if it is active.
  33. ARG is passed to `pp-eval-last-sexp'."
  34. (interactive "P")
  35. (if (use-region-p)
  36. (eval-region (region-beginning) (region-end))
  37. (pp-eval-last-sexp arg)))
  38. ;;;###autoload
  39. (defun al/indent-sexp (&optional no-offset pp)
  40. "Indent each line of the list starting just after point.
  41. If NO-OFFSET is non-nil (with \\[universal-argument]), indent
  42. without offset for the following lines.
  43. If PP is non-nil (with \\[universal-argument] \\[universal-argument]), pretty-print the following list."
  44. (interactive
  45. (list (equal current-prefix-arg '(4))
  46. (equal current-prefix-arg '(16))))
  47. (let ((lisp-indent-offset (and no-offset 1)))
  48. (indent-pp-sexp pp)))
  49. (provide 'al-elisp)
  50. ;;; al-elisp.el ends here