init-utils.el 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ;;; init-utils.el --- .Emacs Configuration -*- lexical-binding: t -*-
  2. ;;; Commentary:
  3. ;;
  4. ;;; Code:
  5. ;; Loads functions from libs
  6. (defun load-directory (dir)
  7. "Load functions from the libs DIR.
  8. read the .el files"
  9. (let ((load-it (lambda (f)
  10. (load-file (concat (file-name-as-directory dir) f)))
  11. ))
  12. (mapc load-it (directory-files dir nil "\\.el$"))))
  13. ;;------------------------------------------------------------------------------
  14. ;; Sachachua
  15. ;;------------------------------------------------------------------------------
  16. ;; Increase-decrease functions from Sacha Chua
  17. (defun sacha/increase-font-size ()
  18. (interactive)
  19. (set-face-attribute 'default
  20. nil
  21. :height
  22. (ceiling (* 1.10
  23. (face-attribute 'default :height)))))
  24. (defun sacha/decrease-font-size ()
  25. (interactive)
  26. (set-face-attribute 'default
  27. nil
  28. :height
  29. (floor (* 0.9
  30. (face-attribute 'default :height)))))
  31. ;; Not original from Sacha.
  32. ;; Taken from: http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-line/
  33. (defun sacha/smarter-move-beginning-of-line (arg)
  34. "Move point back to indentation of beginning of line.
  35. Move point to the first non-whitespace character on this line.
  36. If point is already there, move to the beginning of the line.
  37. Effectively toggle between the first non-whitespace character and
  38. the beginning of the line.
  39. If ARG is not nil or 1, move forward ARG - 1 lines first. If
  40. point reaches the beginning or end of the buffer, stop there."
  41. (interactive "^p")
  42. (setq arg (or arg 1))
  43. ;; Move lines first
  44. (when (/= arg 1)
  45. (let ((line-move-visual nil))
  46. (forward-line (1- arg))))
  47. (let ((orig-point (point)))
  48. (back-to-indentation)
  49. (when (= orig-point (point))
  50. (move-beginning-of-line 1))))
  51. ;;------------------------------------------------------------------------------
  52. (provide 'init-utils)
  53. ;;; init-utils.el ends here