PageRenderTime 26ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/ergoemacs/init_functions.el

http://ergoemacs.googlecode.com/
Emacs Lisp | 169 lines | 150 code | 16 blank | 3 comment | 9 complexity | 2246f2055e5f1a00d29bf9554da8ebad MD5 | raw file
Possible License(s): CC-BY-SA-4.0, GPL-3.0, GPL-2.0
  1. ;-*- coding: utf-8 -*-
  2. (defun text-scale-normal-size ()
  3. "Set the height of the default face in the current buffer to its default value."
  4. (interactive)
  5. (text-scale-increase 0))
  6. (defun toggle-line-move-visual ()
  7. "Toggle behavior of up/down arrow key, by visual line vs logical line."
  8. (interactive)
  9. (if line-move-visual
  10. (setq line-move-visual nil)
  11. (setq line-move-visual t))
  12. )
  13. (defun cmd-shell (&optional arg)
  14. "Run cmd.exe (WinNT) or command.com shell. A numeric prefix
  15. arg switches to the specified session, creating it if necessary."
  16. (interactive "P")
  17. (let ((buf-name (cond ((numberp arg)
  18. (format "*cmd<%s>*" arg))
  19. (arg
  20. (generate-new-buffer-name "*cmd*"))
  21. (t
  22. "*cmd*")))
  23. (explicit-shell-file-name (or (and (w32-using-nt) "cmd.exe")
  24. "command.com")))
  25. (shell buf-name)))
  26. (defun msys-shell (&optional arg)
  27. "Run MSYS shell (sh.exe). It's like a Unix Shell in Windows.
  28. A numeric prefix arg switches to the specified session, creating
  29. it if necessary."
  30. (interactive "P")
  31. (let ((buf-name (cond ((numberp arg)
  32. (format "*msys<%d>*" arg))
  33. (arg
  34. (generate-new-buffer-name "*msys*"))
  35. (t
  36. "*msys*")))
  37. (explicit-shell-file-name "sh.exe"))
  38. (shell buf-name)))
  39. (defun soft-wrap-lines ()
  40. "Make lines wrap at window edge and on word boundary,
  41. in current buffer."
  42. (interactive)
  43. (setq truncate-lines nil)
  44. (setq word-wrap t)
  45. )
  46. (defun close-frame ()
  47. "Closes the current frame or kill emacs if there are just one
  48. frame. It simulates the same functionality of the Close button in
  49. the frame title bar."
  50. (interactive)
  51. (if multiple-frames
  52. (delete-frame)
  53. (save-buffers-kill-terminal)))
  54. (defadvice elisp-index-search (before interactive-default activate)
  55. "Provide the symbol at point as the default when reading TOPIC interactively."
  56. (interactive
  57. (let ((mysymbol (thing-at-point 'symbol)))
  58. (list (read-string (if mysymbol
  59. (format "Topic (%s): " mysymbol)
  60. (format "Topic: "))
  61. nil nil mysymbol)))))
  62. (defun list-text-editing-modes ()
  63. "Display a list of all text editing related major modes.
  64. The list includes all major modes for editing programing language
  65. files or such things as BBCode, but does not include major modes
  66. for dired, irc, mail, shell, etc."
  67. (interactive)
  68. (with-output-to-temp-buffer "*Major Modes for Text Editing*"
  69. (princ
  70. "###############################################
  71. # This is a list of text-editing related major modes that comes with ErgoEmacs.
  72. # The lines are formatted this way:
  73. # ‹purpose/language name› • ‹command name›
  74. # The list is not complete.
  75. # please help by adding modes you use at
  76. # http://code.google.com/p/ergoemacs/issues/detail?id=64
  77. AutoHotKey • xahk-mode
  78. BBCode • xbbcode-mode
  79. Bash • sh-mode
  80. C • c-mode
  81. C++ • c++-mode
  82. CSS • css-mode
  83. Clojure • clojure-mode
  84. Emacs Lisp • emacs-lisp-mode
  85. Erlang • erlang-mode
  86. HTML • html-mode
  87. Haskell • haskell-mode
  88. Java • java-mode
  89. Javascript • js-mode
  90. Javascript • js2-mode
  91. LaTeX • latex-mode
  92. Linden Scripting Language • xlsl-mode
  93. Lua • lua-mode
  94. OCaml • tuareg-mode
  95. PHP • php-mode
  96. Perl • cperl-mode
  97. PowerShell • powershell-mode
  98. Python • python-mode
  99. Ruby • ruby-mode
  100. Scala • scala-mode
  101. TCL • tcl-mode
  102. Visual Basic • visual-basic-mode
  103. XML • nxml-mode
  104. XML • xml-mode
  105. cmd.exe • dos-mode"
  106. )
  107. )
  108. )
  109. (defun toggle-whitespace-setting ()
  110. "Toggle some display settings for `whitespace-mode'."
  111. (interactive)
  112. (let (stateBefore stateAfter (statesList '(0 1)))
  113. (setq stateBefore (if (get 'toggle-whitespace-setting 'state) (get 'toggle-whitespace-setting 'state) (elt statesList 0)))
  114. (setq stateAfter (% (+ stateBefore (length statesList) 1) (length statesList)))
  115. (put 'toggle-whitespace-setting 'state stateAfter)
  116. (cond
  117. ((equal stateAfter 0)
  118. (progn
  119. (setq whitespace-style '(tabs spaces trailing lines space-before-tab newline indentation empty space-after-tab space-mark tab-mark newline-mark))
  120. (setq whitespace-display-mappings
  121. '((space-mark 32 [183] [46])
  122. (space-mark 160 [164] [95])
  123. (space-mark 2208 [2212] [95])
  124. (space-mark 2336 [2340] [95])
  125. (space-mark 3616 [3620] [95])
  126. (space-mark 3872 [3876] [95])
  127. (newline-mark 10 [36 10])
  128. (tab-mark 9 [187 9] [92 9]))
  129. )
  130. (message "whitespace-setting set to default.")
  131. ))
  132. ((equal stateAfter 1)
  133. (progn
  134. ;; Make whitespace-mode with very basic background coloring for whitespaces
  135. (setq whitespace-style '( spaces tabs newline space-mark tab-mark newline-mark ))
  136. ;; Make whitespace-mode and whitespace-newline-mode use “ś” for end of line char and ? for tab.
  137. (setq whitespace-display-mappings
  138. '(
  139. (space-mark 32 [183] [46]) ; normal space, MIDDLE DOT, FULL STOP.
  140. (space-mark 160 [164] [95])
  141. (space-mark 2208 [2212] [95])
  142. (space-mark 2336 [2340] [95])
  143. (space-mark 3616 [3620] [95])
  144. (space-mark 3872 [3876] [95])
  145. (newline-mark 10 [182 10]) ; newlne
  146. (tab-mark 9 [9655 9] [92 9]) ; tab
  147. ))
  148. (message "whitespace-setting set to using ? for tab and ś for newline.")
  149. ))
  150. )
  151. (when global-whitespace-mode (global-whitespace-mode 0) (global-whitespace-mode 1))
  152. (when whitespace-mode (whitespace-mode 0) (whitespace-mode 1))
  153. ))