squeeze-view.el 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ;;; squeeze-view.el - set and unset wide margins on the current buffer view.
  2. (defconst squeeze-view-version "0.1.0")
  3. ;; Copyright (c)2010,2012 Jason Milkins. (by)(nc)(sa) Some rights reserved.
  4. ;; Author: Jasonm23 (concat "jason" "m23" "@" "gmail" ".com")
  5. ;; This file is not part of GNU Emacs.
  6. ;; This program is free software; you can redistribute it and/or
  7. ;; modify it under the terms of the GNU General Public License as
  8. ;; published by the Free Software Foundation version 2.
  9. ;; This program is distributed in the hope that it will be useful, but
  10. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. ;; General Public License for more details.
  13. ;; For a copy of the GNU General Public License, search the Internet,
  14. ;; or write to the Free Software Foundation, Inc., 59 Temple Place,
  15. ;; Suite 330, Boston, MA 02111-1307 USA
  16. ;;
  17. ;; squeeze-view.el
  18. ;;
  19. ;; Intended to improve readability/focus reduce eye strain, by
  20. ;; horizontally narrowing the window viewable area, and removing other
  21. ;; windows. Similar to WriteRoom, and other reduced distraction modes
  22. ;; in various editors.
  23. ;;
  24. ;; `squeeze-view' - uses the default margin size. (can be set with
  25. ;; customizing `squeeze-view-margin')
  26. ;; `squeeze-view-size' - asks for a margin size.
  27. ;;
  28. (defcustom squeeze-view-linum t
  29. "Specifies if line numbers are shown in a squeeze view")
  30. (defcustom squeeze-view-fringe 550
  31. "Specifies the fringe width for squeeze-view")
  32. (defcustom squeeze-view-margin 0
  33. "Specifies the standard margin size for a squeezed
  34. view. Defaults to 70.")
  35. (defun squeeze-view ()
  36. "Squeeze the view, designed to improve readability/focus by
  37. reducing the window viewable area, similar to WriteRoom"
  38. (interactive)
  39. (if (equal t squeeze-view-linum)
  40. (linum-mode 1)
  41. (linum-mode 0))
  42. (delete-other-windows)
  43. (set-window-fringes nil squeeze-view-fringe squeeze-view-fringe t)
  44. ;;(set-window-margins nil squeeze-view-margin squeeze-view-margin)
  45. )
  46. (defun unsqueeze-view ()
  47. "Reset the fringe margins to 0 and turn linum-mode back on"
  48. (interactive)
  49. (linum-mode 1)
  50. (set-window-fringes nil 8 8 nil)
  51. (set-window-margins nil 0 0)
  52. )
  53. (defun squeeze-view-size (margin)
  54. "Interactively squeeze the view using a supplied margin"
  55. (interactive "nSqueeze margins: ")
  56. (linum-mode 0)
  57. (delete-other-windows)
  58. (set-window-fringes nil squeeze-view-fringe squeeze-view-fringe squeeze-view-linum)
  59. (set-window-margins nil margin margin)
  60. )
  61. (provide 'squeeze-view)