bindings.el 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214
  1. ;;; bindings.el --- define standard key bindings and some variables
  2. ;; Copyright (C) 1985-1987, 1992-1996, 1999-2012
  3. ;; Free Software Foundation, Inc.
  4. ;; Maintainer: FSF
  5. ;; Keywords: internal
  6. ;; Package: emacs
  7. ;; This file is part of GNU Emacs.
  8. ;; GNU Emacs is free software: you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation, either version 3 of the License, or
  11. ;; (at your option) any later version.
  12. ;; GNU Emacs is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;; GNU General Public License for more details.
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  18. ;;; Commentary:
  19. ;;; Code:
  20. (defun make-mode-line-mouse-map (mouse function) "\
  21. Return a keymap with single entry for mouse key MOUSE on the mode line.
  22. MOUSE is defined to run function FUNCTION with no args in the buffer
  23. corresponding to the mode line clicked."
  24. (let ((map (make-sparse-keymap)))
  25. (define-key map (vector 'mode-line mouse) function)
  26. map))
  27. (defun mode-line-toggle-read-only (event)
  28. "Like `toggle-read-only', for the mode-line."
  29. (interactive "e")
  30. (save-selected-window
  31. (select-window (posn-window (event-start event)))
  32. (with-no-warnings (toggle-read-only))
  33. (force-mode-line-update)))
  34. (defun mode-line-toggle-modified (event)
  35. "Toggle the buffer-modified flag from the mode-line."
  36. (interactive "e")
  37. (save-selected-window
  38. (select-window (posn-window (event-start event)))
  39. (set-buffer-modified-p (not (buffer-modified-p)))
  40. (force-mode-line-update)))
  41. (defun mode-line-widen (event)
  42. "Widen a buffer from the mode-line."
  43. (interactive "e")
  44. (save-selected-window
  45. (select-window (posn-window (event-start event)))
  46. (widen)
  47. (force-mode-line-update)))
  48. (defvar mode-line-input-method-map
  49. (let ((map (make-sparse-keymap)))
  50. (define-key map [mode-line mouse-2]
  51. (lambda (e)
  52. (interactive "e")
  53. (save-selected-window
  54. (select-window
  55. (posn-window (event-start e)))
  56. (toggle-input-method)
  57. (force-mode-line-update))))
  58. (define-key map [mode-line mouse-3]
  59. (lambda (e)
  60. (interactive "e")
  61. (save-selected-window
  62. (select-window
  63. (posn-window (event-start e)))
  64. (describe-current-input-method))))
  65. (purecopy map)))
  66. (defvar mode-line-coding-system-map
  67. (let ((map (make-sparse-keymap)))
  68. (define-key map [mode-line mouse-1]
  69. (lambda (e)
  70. (interactive "e")
  71. (save-selected-window
  72. (select-window (posn-window (event-start e)))
  73. (when (and enable-multibyte-characters
  74. buffer-file-coding-system)
  75. (describe-coding-system buffer-file-coding-system)))))
  76. (define-key map [mode-line mouse-3]
  77. (lambda (e)
  78. (interactive "e")
  79. (save-selected-window
  80. (select-window (posn-window (event-start e)))
  81. (call-interactively 'set-buffer-file-coding-system))))
  82. (purecopy map))
  83. "Local keymap for the coding-system part of the mode line.")
  84. (defun mode-line-change-eol (event)
  85. "Cycle through the various possible kinds of end-of-line styles."
  86. (interactive "e")
  87. (with-selected-window (posn-window (event-start event))
  88. (let ((eol (coding-system-eol-type buffer-file-coding-system)))
  89. (set-buffer-file-coding-system
  90. (cond ((eq eol 0) 'dos) ((eq eol 1) 'mac) (t 'unix))))))
  91. (defvar mode-line-eol-desc-cache nil)
  92. (defun mode-line-eol-desc ()
  93. (let* ((eol (coding-system-eol-type buffer-file-coding-system))
  94. (mnemonic (coding-system-eol-type-mnemonic buffer-file-coding-system))
  95. (desc (assoc eol mode-line-eol-desc-cache)))
  96. (if (and desc (eq (cadr desc) mnemonic))
  97. (cddr desc)
  98. (if desc (setq mode-line-eol-desc-cache nil)) ;Flush the cache if stale.
  99. (setq desc
  100. (propertize
  101. mnemonic
  102. 'help-echo (format "End-of-line style: %s\nmouse-1: Cycle"
  103. (if (eq eol 0) "Unix-style LF"
  104. (if (eq eol 1) "DOS-style CRLF"
  105. (if (eq eol 2) "Mac-style CR"
  106. "Undecided"))))
  107. 'keymap
  108. (eval-when-compile
  109. (let ((map (make-sparse-keymap)))
  110. (define-key map [mode-line mouse-1] 'mode-line-change-eol)
  111. map))
  112. 'mouse-face 'mode-line-highlight))
  113. (push (cons eol (cons mnemonic desc)) mode-line-eol-desc-cache)
  114. desc)))
  115. ;;; Mode line contents
  116. (defcustom mode-line-default-help-echo
  117. "mouse-1: Select (drag to resize)\n\
  118. mouse-2: Make current window occupy the whole frame\n\
  119. mouse-3: Remove current window from display"
  120. "Default help text for the mode line.
  121. If the value is a string, it specifies the tooltip or echo area
  122. message to display when the mouse is moved over the mode line.
  123. If the text at the mouse position has a `help-echo' text
  124. property, that overrides this variable."
  125. :type '(choice (const :tag "No help" :value nil) string)
  126. :version "24.2"
  127. :group 'mode-line)
  128. (defvar mode-line-front-space '(:eval (if (display-graphic-p) " " "-"))
  129. "Mode line construct to put at the front of the mode line.
  130. By default, this construct is displayed right at the beginning of
  131. the mode line, except that if there is a memory-full message, it
  132. is displayed first.")
  133. (put 'mode-line-front-space 'risky-local-variable t)
  134. (defun mode-line-mule-info-help-echo (window _object _point)
  135. "Return help text specifying WINDOW's buffer coding system."
  136. (with-current-buffer (window-buffer window)
  137. (if buffer-file-coding-system
  138. (format "Buffer coding system (%s): %s
  139. mouse-1: Describe coding system
  140. mouse-3: Set coding system"
  141. (if enable-multibyte-characters "multi-byte" "unibyte")
  142. (symbol-name buffer-file-coding-system))
  143. "Buffer coding system: none specified")))
  144. (defvar mode-line-mule-info
  145. `(""
  146. (current-input-method
  147. (:propertize ("" current-input-method-title)
  148. help-echo (concat
  149. ,(purecopy "Current input method: ")
  150. current-input-method
  151. ,(purecopy "\n\
  152. mouse-2: Disable input method\n\
  153. mouse-3: Describe current input method"))
  154. local-map ,mode-line-input-method-map
  155. mouse-face mode-line-highlight))
  156. ,(propertize
  157. "%z"
  158. 'help-echo 'mode-line-mule-info-help-echo
  159. 'mouse-face 'mode-line-highlight
  160. 'local-map mode-line-coding-system-map)
  161. (:eval (mode-line-eol-desc)))
  162. "Mode line construct to report the multilingual environment.
  163. Normally it displays current input method (if any activated) and
  164. mnemonics of the following coding systems:
  165. coding system for saving or writing the current buffer
  166. coding system for keyboard input (on a text terminal)
  167. coding system for terminal output (on a text terminal)")
  168. ;;;###autoload
  169. (put 'mode-line-mule-info 'risky-local-variable t)
  170. (make-variable-buffer-local 'mode-line-mule-info)
  171. (defvar mode-line-client
  172. `(""
  173. (:propertize ("" (:eval (if (frame-parameter nil 'client) "@" "")))
  174. help-echo ,(purecopy "emacsclient frame")))
  175. "Mode line construct for identifying emacsclient frames.")
  176. ;;;###autoload
  177. (put 'mode-line-client 'risky-local-variable t)
  178. (defun mode-line-read-only-help-echo (window _object _point)
  179. "Return help text specifying WINDOW's buffer read-only status."
  180. (format "Buffer is %s\nmouse-1: Toggle"
  181. (if (buffer-local-value 'buffer-read-only (window-buffer window))
  182. "read-only"
  183. "writable")))
  184. (defun mode-line-modified-help-echo (window _object _point)
  185. "Return help text specifying WINDOW's buffer modification status."
  186. (format "Buffer is %smodified\nmouse-1: Toggle modification state"
  187. (if (buffer-modified-p (window-buffer window)) "" "not ")))
  188. (defvar mode-line-modified
  189. (list (propertize
  190. "%1*"
  191. 'help-echo 'mode-line-read-only-help-echo
  192. 'local-map (purecopy (make-mode-line-mouse-map
  193. 'mouse-1
  194. #'mode-line-toggle-read-only))
  195. 'mouse-face 'mode-line-highlight)
  196. (propertize
  197. "%1+"
  198. 'help-echo 'mode-line-modified-help-echo
  199. 'local-map (purecopy (make-mode-line-mouse-map
  200. 'mouse-1 #'mode-line-toggle-modified))
  201. 'mouse-face 'mode-line-highlight))
  202. "Mode line construct for displaying whether current buffer is modified.")
  203. ;;;###autoload
  204. (put 'mode-line-modified 'risky-local-variable t)
  205. (make-variable-buffer-local 'mode-line-modified)
  206. (defvar mode-line-remote
  207. (list (propertize
  208. "%1@"
  209. 'mouse-face 'mode-line-highlight
  210. 'help-echo (purecopy (lambda (window _object _point)
  211. (format "%s"
  212. (save-selected-window
  213. (select-window window)
  214. (concat
  215. (if (file-remote-p default-directory)
  216. "Current directory is remote: "
  217. "Current directory is local: ")
  218. default-directory)))))))
  219. "Mode line construct to indicate a remote buffer.")
  220. ;;;###autoload
  221. (put 'mode-line-remote 'risky-local-variable t)
  222. (make-variable-buffer-local 'mode-line-remote)
  223. ;; MSDOS frames have window-system, but want the Fn identification.
  224. (defun mode-line-frame-control ()
  225. "Compute mode line construct for frame identification.
  226. Value is used for `mode-line-frame-identification', which see."
  227. (if (or (null window-system)
  228. (eq window-system 'pc))
  229. "-%F "
  230. " "))
  231. ;; We need to defer the call to mode-line-frame-control to the time
  232. ;; the mode line is actually displayed.
  233. (defvar mode-line-frame-identification '(:eval (mode-line-frame-control))
  234. "Mode line construct to describe the current frame.")
  235. ;;;###autoload
  236. (put 'mode-line-frame-identification 'risky-local-variable t)
  237. (defvar mode-line-process nil
  238. "Mode line construct for displaying info on process status.
  239. Normally nil in most modes, since there is no process to display.")
  240. ;;;###autoload
  241. (put 'mode-line-process 'risky-local-variable t)
  242. (make-variable-buffer-local 'mode-line-process)
  243. (defvar mode-line-mode-menu (make-sparse-keymap "Minor Modes") "\
  244. Menu of mode operations in the mode line.")
  245. (defvar mode-line-major-mode-keymap
  246. (let ((map (make-sparse-keymap)))
  247. (define-key map [mode-line down-mouse-1]
  248. `(menu-item ,(purecopy "Menu Bar") ignore
  249. :filter (lambda (_) (mouse-menu-major-mode-map))))
  250. (define-key map [mode-line mouse-2] 'describe-mode)
  251. (define-key map [mode-line down-mouse-3] mode-line-mode-menu)
  252. map) "\
  253. Keymap to display on major mode.")
  254. (defvar mode-line-minor-mode-keymap
  255. (let ((map (make-sparse-keymap)))
  256. (define-key map [mode-line down-mouse-1] 'mouse-minor-mode-menu)
  257. (define-key map [mode-line mouse-2] 'mode-line-minor-mode-help)
  258. (define-key map [mode-line down-mouse-3] mode-line-mode-menu)
  259. (define-key map [header-line down-mouse-3] mode-line-mode-menu)
  260. map) "\
  261. Keymap to display on minor modes.")
  262. (defvar mode-line-modes
  263. (let ((recursive-edit-help-echo "Recursive edit, type C-M-c to get out"))
  264. (list (propertize "%[" 'help-echo recursive-edit-help-echo)
  265. "("
  266. `(:propertize ("" mode-name)
  267. help-echo "Major mode\n\
  268. mouse-1: Display major mode menu\n\
  269. mouse-2: Show help for major mode\n\
  270. mouse-3: Toggle minor modes"
  271. mouse-face mode-line-highlight
  272. local-map ,mode-line-major-mode-keymap)
  273. '("" mode-line-process)
  274. `(:propertize ("" minor-mode-alist)
  275. mouse-face mode-line-highlight
  276. help-echo "Minor mode\n\
  277. mouse-1: Display minor mode menu\n\
  278. mouse-2: Show help for minor mode\n\
  279. mouse-3: Toggle minor modes"
  280. local-map ,mode-line-minor-mode-keymap)
  281. (propertize "%n" 'help-echo "mouse-2: Remove narrowing from buffer"
  282. 'mouse-face 'mode-line-highlight
  283. 'local-map (make-mode-line-mouse-map
  284. 'mouse-2 #'mode-line-widen))
  285. ")"
  286. (propertize "%]" 'help-echo recursive-edit-help-echo)
  287. " "))
  288. "Mode line construct for displaying major and minor modes.")
  289. (put 'mode-line-modes 'risky-local-variable t)
  290. (defvar mode-line-column-line-number-mode-map
  291. (let ((map (make-sparse-keymap))
  292. (menu-map (make-sparse-keymap "Toggle Line and Column Number Display")))
  293. (define-key menu-map [line-number-mode]
  294. `(menu-item ,(purecopy "Display Line Numbers") line-number-mode
  295. :help ,(purecopy "Toggle displaying line numbers in the mode-line")
  296. :button (:toggle . line-number-mode)))
  297. (define-key menu-map [column-number-mode]
  298. `(menu-item ,(purecopy "Display Column Numbers") column-number-mode
  299. :help ,(purecopy "Toggle displaying column numbers in the mode-line")
  300. :button (:toggle . column-number-mode)))
  301. (define-key map [mode-line down-mouse-1] menu-map)
  302. map) "\
  303. Keymap to display on column and line numbers.")
  304. (defvar mode-line-position
  305. `((-3 ,(propertize
  306. "%p"
  307. 'local-map mode-line-column-line-number-mode-map
  308. 'mouse-face 'mode-line-highlight
  309. ;; XXX needs better description
  310. 'help-echo "Size indication mode\n\
  311. mouse-1: Display Line and Column Mode Menu"))
  312. (size-indication-mode
  313. (8 ,(propertize
  314. " of %I"
  315. 'local-map mode-line-column-line-number-mode-map
  316. 'mouse-face 'mode-line-highlight
  317. ;; XXX needs better description
  318. 'help-echo "Size indication mode\n\
  319. mouse-1: Display Line and Column Mode Menu")))
  320. (line-number-mode
  321. ((column-number-mode
  322. (10 ,(propertize
  323. " (%l,%c)"
  324. 'local-map mode-line-column-line-number-mode-map
  325. 'mouse-face 'mode-line-highlight
  326. 'help-echo "Line number and Column number\n\
  327. mouse-1: Display Line and Column Mode Menu"))
  328. (6 ,(propertize
  329. " L%l"
  330. 'local-map mode-line-column-line-number-mode-map
  331. 'mouse-face 'mode-line-highlight
  332. 'help-echo "Line Number\n\
  333. mouse-1: Display Line and Column Mode Menu"))))
  334. ((column-number-mode
  335. (5 ,(propertize
  336. " C%c"
  337. 'local-map mode-line-column-line-number-mode-map
  338. 'mouse-face 'mode-line-highlight
  339. 'help-echo "Column number\n\
  340. mouse-1: Display Line and Column Mode Menu"))))))
  341. "Mode line construct for displaying the position in the buffer.
  342. Normally displays the buffer percentage and, optionally, the
  343. buffer size, the line number and the column number.")
  344. (put 'mode-line-position 'risky-local-variable t)
  345. (defvar mode-line-buffer-identification-keymap
  346. ;; Add menu of buffer operations to the buffer identification part
  347. ;; of the mode line.or header line.
  348. (let ((map (make-sparse-keymap)))
  349. ;; Bind down- events so that the global keymap won't ``shine
  350. ;; through''.
  351. (define-key map [mode-line mouse-1] 'mode-line-previous-buffer)
  352. (define-key map [header-line down-mouse-1] 'ignore)
  353. (define-key map [header-line mouse-1] 'mode-line-previous-buffer)
  354. (define-key map [mode-line mouse-3] 'mode-line-next-buffer)
  355. (define-key map [header-line down-mouse-3] 'ignore)
  356. (define-key map [header-line mouse-3] 'mode-line-next-buffer)
  357. map) "\
  358. Keymap for what is displayed by `mode-line-buffer-identification'.")
  359. (defun propertized-buffer-identification (fmt)
  360. "Return a list suitable for `mode-line-buffer-identification'.
  361. FMT is a format specifier such as \"%12b\". This function adds
  362. text properties for face, help-echo, and local-map to it."
  363. (list (propertize fmt
  364. 'face 'mode-line-buffer-id
  365. 'help-echo
  366. (purecopy "Buffer name
  367. mouse-1: Previous buffer\nmouse-3: Next buffer")
  368. 'mouse-face 'mode-line-highlight
  369. 'local-map mode-line-buffer-identification-keymap)))
  370. (defvar mode-line-buffer-identification
  371. (propertized-buffer-identification "%12b")
  372. "Mode line construct for identifying the buffer being displayed.
  373. Its default value is (\"%12b\") with some text properties added.
  374. Major modes that edit things other than ordinary files may change this
  375. \(e.g. Info, Dired,...)")
  376. ;;;###autoload
  377. (put 'mode-line-buffer-identification 'risky-local-variable t)
  378. (make-variable-buffer-local 'mode-line-buffer-identification)
  379. (defvar mode-line-misc-info
  380. '((which-func-mode ("" which-func-format " "))
  381. (global-mode-string ("" global-mode-string " ")))
  382. "Mode line construct for miscellaneous information.
  383. By default, this shows the information specified by
  384. `which-func-mode' and `global-mode-string'.")
  385. (put 'mode-line-misc-info 'risky-local-variable t)
  386. (defvar mode-line-end-spaces '(:eval (unless (display-graphic-p) "-%-"))
  387. "Mode line construct to put at the end of the mode line.")
  388. (put 'mode-line-end-spaces 'risky-local-variable t)
  389. ;; Default value of the top-level `mode-line-format' variable:
  390. (let ((standard-mode-line-format
  391. (list "%e"
  392. 'mode-line-front-space
  393. 'mode-line-mule-info
  394. 'mode-line-client
  395. 'mode-line-modified
  396. 'mode-line-remote
  397. 'mode-line-frame-identification
  398. 'mode-line-buffer-identification
  399. " "
  400. 'mode-line-position
  401. '(vc-mode vc-mode)
  402. " "
  403. 'mode-line-modes
  404. 'mode-line-misc-info
  405. 'mode-line-end-spaces)))
  406. (setq-default mode-line-format standard-mode-line-format)
  407. (put 'mode-line-format 'standard-value
  408. (list `(quote ,standard-mode-line-format))))
  409. (defun mode-line-unbury-buffer (event) "\
  410. Call `unbury-buffer' in this window."
  411. (interactive "e")
  412. (save-selected-window
  413. (select-window (posn-window (event-start event)))
  414. (unbury-buffer)))
  415. (defun mode-line-bury-buffer (event) "\
  416. Like `bury-buffer', but temporarily select EVENT's window."
  417. (interactive "e")
  418. (save-selected-window
  419. (select-window (posn-window (event-start event)))
  420. (bury-buffer)))
  421. (defun mode-line-other-buffer () "\
  422. Switch to the most recently selected buffer other than the current one."
  423. (interactive)
  424. (switch-to-buffer (other-buffer) nil t))
  425. (defun mode-line-next-buffer (event)
  426. "Like `next-buffer', but temporarily select EVENT's window."
  427. (interactive "e")
  428. (save-selected-window
  429. (select-window (posn-window (event-start event)))
  430. (next-buffer)))
  431. (defun mode-line-previous-buffer (event)
  432. "Like `previous-buffer', but temporarily select EVENT's window."
  433. (interactive "e")
  434. (save-selected-window
  435. (select-window (posn-window (event-start event)))
  436. (previous-buffer)))
  437. (defmacro bound-and-true-p (var)
  438. "Return the value of symbol VAR if it is bound, else nil."
  439. `(and (boundp (quote ,var)) ,var))
  440. ;; Use mode-line-mode-menu for local minor-modes only.
  441. ;; Global ones can go on the menubar (Options --> Show/Hide).
  442. (define-key mode-line-mode-menu [overwrite-mode]
  443. `(menu-item ,(purecopy "Overwrite (Ovwrt)") overwrite-mode
  444. :help ,(purecopy "Overwrite mode: typed characters replace existing text")
  445. :button (:toggle . overwrite-mode)))
  446. (define-key mode-line-mode-menu [outline-minor-mode]
  447. `(menu-item ,(purecopy "Outline (Outl)") outline-minor-mode
  448. ;; XXX: This needs a good, brief description.
  449. :help ,(purecopy "")
  450. :button (:toggle . (bound-and-true-p outline-minor-mode))))
  451. (define-key mode-line-mode-menu [highlight-changes-mode]
  452. `(menu-item ,(purecopy "Highlight changes (Chg)") highlight-changes-mode
  453. :help ,(purecopy "Show changes in the buffer in a distinctive color")
  454. :button (:toggle . (bound-and-true-p highlight-changes-mode))))
  455. (define-key mode-line-mode-menu [hide-ifdef-mode]
  456. `(menu-item ,(purecopy "Hide ifdef (Ifdef)") hide-ifdef-mode
  457. :help ,(purecopy "Show/Hide code within #ifdef constructs")
  458. :button (:toggle . (bound-and-true-p hide-ifdef-mode))))
  459. (define-key mode-line-mode-menu [glasses-mode]
  460. `(menu-item ,(purecopy "Glasses (o^o)") glasses-mode
  461. :help ,(purecopy "Insert virtual separators to make long identifiers easy to read")
  462. :button (:toggle . (bound-and-true-p glasses-mode))))
  463. (define-key mode-line-mode-menu [font-lock-mode]
  464. `(menu-item ,(purecopy "Font Lock") font-lock-mode
  465. :help ,(purecopy "Syntax coloring")
  466. :button (:toggle . font-lock-mode)))
  467. (define-key mode-line-mode-menu [flyspell-mode]
  468. `(menu-item ,(purecopy "Flyspell (Fly)") flyspell-mode
  469. :help ,(purecopy "Spell checking on the fly")
  470. :button (:toggle . (bound-and-true-p flyspell-mode))))
  471. (define-key mode-line-mode-menu [auto-revert-tail-mode]
  472. `(menu-item ,(purecopy "Auto revert tail (Tail)") auto-revert-tail-mode
  473. :help ,(purecopy "Revert the tail of the buffer when buffer grows")
  474. :enable (buffer-file-name)
  475. :button (:toggle . (bound-and-true-p auto-revert-tail-mode))))
  476. (define-key mode-line-mode-menu [auto-revert-mode]
  477. `(menu-item ,(purecopy "Auto revert (ARev)") auto-revert-mode
  478. :help ,(purecopy "Revert the buffer when the file on disk changes")
  479. :button (:toggle . (bound-and-true-p auto-revert-mode))))
  480. (define-key mode-line-mode-menu [auto-fill-mode]
  481. `(menu-item ,(purecopy "Auto fill (Fill)") auto-fill-mode
  482. :help ,(purecopy "Automatically insert new lines")
  483. :button (:toggle . auto-fill-function)))
  484. (define-key mode-line-mode-menu [abbrev-mode]
  485. `(menu-item ,(purecopy "Abbrev (Abbrev)") abbrev-mode
  486. :help ,(purecopy "Automatically expand abbreviations")
  487. :button (:toggle . abbrev-mode)))
  488. (defun mode-line-minor-mode-help (event)
  489. "Describe minor mode for EVENT on minor modes area of the mode line."
  490. (interactive "@e")
  491. (let ((indicator (car (nth 4 (car (cdr event))))))
  492. (describe-minor-mode-from-indicator indicator)))
  493. (defvar minor-mode-alist nil "\
  494. Alist saying how to show minor modes in the mode line.
  495. Each element looks like (VARIABLE STRING);
  496. STRING is included in the mode line if VARIABLE's value is non-nil.
  497. Actually, STRING need not be a string; any mode-line construct is
  498. okay. See `mode-line-format'.")
  499. ;;;###autoload
  500. (put 'minor-mode-alist 'risky-local-variable t)
  501. ;; Don't use purecopy here--some people want to change these strings.
  502. (setq minor-mode-alist
  503. '((abbrev-mode " Abbrev")
  504. (overwrite-mode overwrite-mode)
  505. (auto-fill-function " Fill")
  506. ;; not really a minor mode...
  507. (defining-kbd-macro " Def")))
  508. ;; These variables are used by autoloadable packages.
  509. ;; They are defined here so that they do not get overridden
  510. ;; by the loading of those packages.
  511. ;; Names in directory that end in one of these
  512. ;; are ignored in completion,
  513. ;; making it more likely you will get a unique match.
  514. (setq completion-ignored-extensions
  515. (append
  516. (cond ((memq system-type '(ms-dos windows-nt))
  517. (mapcar 'purecopy
  518. '(".o" "~" ".bin" ".bak" ".obj" ".map" ".ico" ".pif" ".lnk"
  519. ".a" ".ln" ".blg" ".bbl" ".dll" ".drv" ".vxd" ".386")))
  520. (t
  521. (mapcar 'purecopy
  522. '(".o" "~" ".bin" ".lbin" ".so"
  523. ".a" ".ln" ".blg" ".bbl"))))
  524. (mapcar 'purecopy
  525. '(".elc" ".lof"
  526. ".glo" ".idx" ".lot"
  527. ;; VCS metadata directories
  528. ".svn/" ".hg/" ".git/" ".bzr/" "CVS/" "_darcs/" "_MTN/"
  529. ;; TeX-related
  530. ".fmt" ".tfm"
  531. ;; Java compiled
  532. ".class"
  533. ;; CLISP
  534. ".fas" ".lib" ".mem"
  535. ;; CMUCL
  536. ".x86f" ".sparcf"
  537. ;; OpenMCL / Clozure CL
  538. ".dfsl" ".pfsl" ".d64fsl" ".p64fsl" ".lx64fsl" ".lx32fsl"
  539. ".dx64fsl" ".dx32fsl" ".fx64fsl" ".fx32fsl" ".sx64fsl"
  540. ".sx32fsl" ".wx64fsl" ".wx32fsl"
  541. ;; Other CL implementations (Allegro, LispWorks)
  542. ".fasl" ".ufsl" ".fsl" ".dxl"
  543. ;; Libtool
  544. ".lo" ".la"
  545. ;; Gettext
  546. ".gmo" ".mo"
  547. ;; Texinfo-related
  548. ;; This used to contain .log, but that's commonly used for log
  549. ;; files you do want to see, not just TeX stuff. -- fx
  550. ".toc" ".aux"
  551. ".cp" ".fn" ".ky" ".pg" ".tp" ".vr"
  552. ".cps" ".fns" ".kys" ".pgs" ".tps" ".vrs"
  553. ;; Python byte-compiled
  554. ".pyc" ".pyo"))))
  555. ;; Suffixes used for executables.
  556. (setq exec-suffixes
  557. (cond
  558. ((memq system-type '(ms-dos windows-nt))
  559. '(".exe" ".com" ".bat" ".cmd" ".btm" ""))
  560. (t
  561. '(""))))
  562. ;; Packages should add to this list appropriately when they are
  563. ;; loaded, rather than listing everything here.
  564. (setq debug-ignored-errors
  565. ;; FIXME: Maybe beginning-of-line, beginning-of-buffer, end-of-line,
  566. ;; end-of-buffer, end-of-file, buffer-read-only, and
  567. ;; file-supersession should all be user-errors!
  568. `(beginning-of-line beginning-of-buffer end-of-line
  569. end-of-buffer end-of-file buffer-read-only
  570. file-supersession
  571. user-error ;; That's the main one!
  572. ))
  573. (make-variable-buffer-local 'indent-tabs-mode)
  574. ;; We have base64, md5 and sha1 functions built in now.
  575. (provide 'base64)
  576. (provide 'md5)
  577. (provide 'sha1)
  578. (provide 'overlay '(display syntax-table field))
  579. (provide 'text-properties '(display syntax-table field point-entered))
  580. (define-key esc-map "\t" 'complete-symbol)
  581. (defun complete-symbol (arg)
  582. "Perform completion on the text around point.
  583. The completion method is determined by `completion-at-point-functions'.
  584. With a prefix argument, this command does completion within
  585. the collection of symbols listed in the index of the manual for the
  586. language you are using."
  587. (interactive "P")
  588. (if arg (info-complete-symbol) (completion-at-point)))
  589. ;; Reduce total amount of space we must allocate during this function
  590. ;; that we will not need to keep permanently.
  591. (garbage-collect)
  592. (setq help-event-list '(help f1))
  593. (make-variable-buffer-local 'minor-mode-overriding-map-alist)
  594. ;; From frame.c
  595. (global-set-key [switch-frame] 'handle-switch-frame)
  596. (global-set-key [select-window] 'handle-select-window)
  597. ;; FIXME: Do those 3 events really ever reach the global-map ?
  598. ;; It seems that they can't because they're handled via
  599. ;; special-event-map which is used at very low-level. -stef
  600. (global-set-key [delete-frame] 'handle-delete-frame)
  601. (global-set-key [iconify-frame] 'ignore-event)
  602. (global-set-key [make-frame-visible] 'ignore-event)
  603. ;These commands are defined in editfns.c
  604. ;but they are not assigned to keys there.
  605. (put 'narrow-to-region 'disabled t)
  606. ;; Moving with arrows in bidi-sensitive direction.
  607. (defun right-char (&optional n)
  608. "Move point N characters to the right (to the left if N is negative).
  609. On reaching beginning or end of buffer, stop and signal error.
  610. Depending on the bidirectional context, this may move either forward
  611. or backward in the buffer. This is in contrast with \\[forward-char]
  612. and \\[backward-char], which see."
  613. (interactive "^p")
  614. (if (eq (current-bidi-paragraph-direction) 'left-to-right)
  615. (forward-char n)
  616. (backward-char n)))
  617. (defun left-char ( &optional n)
  618. "Move point N characters to the left (to the right if N is negative).
  619. On reaching beginning or end of buffer, stop and signal error.
  620. Depending on the bidirectional context, this may move either backward
  621. or forward in the buffer. This is in contrast with \\[backward-char]
  622. and \\[forward-char], which see."
  623. (interactive "^p")
  624. (if (eq (current-bidi-paragraph-direction) 'left-to-right)
  625. (backward-char n)
  626. (forward-char n)))
  627. (defun right-word (&optional n)
  628. "Move point N words to the right (to the left if N is negative).
  629. Depending on the bidirectional context, this may move either forward
  630. or backward in the buffer. This is in contrast with \\[forward-word]
  631. and \\[backward-word], which see.
  632. Value is normally t.
  633. If an edge of the buffer or a field boundary is reached, point is left there
  634. there and the function returns nil. Field boundaries are not noticed
  635. if `inhibit-field-text-motion' is non-nil."
  636. (interactive "^p")
  637. (if (eq (current-bidi-paragraph-direction) 'left-to-right)
  638. (forward-word n)
  639. (backward-word n)))
  640. (defun left-word (&optional n)
  641. "Move point N words to the left (to the right if N is negative).
  642. Depending on the bidirectional context, this may move either backward
  643. or forward in the buffer. This is in contrast with \\[backward-word]
  644. and \\[forward-word], which see.
  645. Value is normally t.
  646. If an edge of the buffer or a field boundary is reached, point is left there
  647. there and the function returns nil. Field boundaries are not noticed
  648. if `inhibit-field-text-motion' is non-nil."
  649. (interactive "^p")
  650. (if (eq (current-bidi-paragraph-direction) 'left-to-right)
  651. (backward-word n)
  652. (forward-word n)))
  653. (defvar narrow-map (make-sparse-keymap)
  654. "Keymap for narrowing commands.")
  655. (define-key ctl-x-map "n" narrow-map)
  656. (define-key narrow-map "n" 'narrow-to-region)
  657. (define-key narrow-map "w" 'widen)
  658. ;; Quitting
  659. (define-key global-map "\e\e\e" 'keyboard-escape-quit)
  660. (define-key global-map "\C-g" 'keyboard-quit)
  661. ;; Used to be in termdev.el: when using several terminals, make C-z
  662. ;; suspend only the relevant terminal.
  663. (substitute-key-definition 'suspend-emacs 'suspend-frame global-map)
  664. (define-key global-map "\C-j" 'newline-and-indent)
  665. (define-key global-map "\C-m" 'newline)
  666. (define-key global-map "\C-o" 'open-line)
  667. (define-key esc-map "\C-o" 'split-line)
  668. (define-key global-map "\C-q" 'quoted-insert)
  669. (define-key esc-map "^" 'delete-indentation)
  670. (define-key esc-map "\\" 'delete-horizontal-space)
  671. (define-key esc-map "m" 'back-to-indentation)
  672. (define-key ctl-x-map "\C-o" 'delete-blank-lines)
  673. (define-key esc-map " " 'just-one-space)
  674. (define-key esc-map "z" 'zap-to-char)
  675. (define-key esc-map "=" 'count-words-region)
  676. (define-key ctl-x-map "=" 'what-cursor-position)
  677. (define-key esc-map ":" 'eval-expression)
  678. ;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit.
  679. (define-key esc-map "\M-:" 'eval-expression)
  680. ;; Changed from C-x ESC so that function keys work following C-x.
  681. (define-key ctl-x-map "\e\e" 'repeat-complex-command)
  682. ;; New binding analogous to M-:.
  683. (define-key ctl-x-map "\M-:" 'repeat-complex-command)
  684. (define-key ctl-x-map "u" 'undo)
  685. (put 'undo :advertised-binding [?\C-x ?u])
  686. ;; Many people are used to typing C-/ on X terminals and getting C-_.
  687. (define-key global-map [?\C-/] 'undo)
  688. (define-key global-map "\C-_" 'undo)
  689. ;; Richard said that we should not use C-x <uppercase letter> and I have
  690. ;; no idea whereas to bind it. Any suggestion welcome. -stef
  691. ;; (define-key ctl-x-map "U" 'undo-only)
  692. (define-key esc-map "!" 'shell-command)
  693. (define-key esc-map "|" 'shell-command-on-region)
  694. (define-key esc-map "&" 'async-shell-command)
  695. (define-key ctl-x-map [right] 'next-buffer)
  696. (define-key ctl-x-map [C-right] 'next-buffer)
  697. (define-key global-map [XF86Forward] 'next-buffer)
  698. (define-key ctl-x-map [left] 'previous-buffer)
  699. (define-key ctl-x-map [C-left] 'previous-buffer)
  700. (define-key global-map [XF86Back] 'previous-buffer)
  701. (let ((map minibuffer-local-map))
  702. (define-key map "\en" 'next-history-element)
  703. (define-key map [next] 'next-history-element)
  704. (define-key map [down] 'next-history-element)
  705. (define-key map [XF86Forward] 'next-history-element)
  706. (define-key map "\ep" 'previous-history-element)
  707. (define-key map [prior] 'previous-history-element)
  708. (define-key map [up] 'previous-history-element)
  709. (define-key map [XF86Back] 'previous-history-element)
  710. (define-key map "\es" 'next-matching-history-element)
  711. (define-key map "\er" 'previous-matching-history-element)
  712. ;; Override the global binding (which calls indent-relative via
  713. ;; indent-for-tab-command). The alignment that indent-relative tries to
  714. ;; do doesn't make much sense here since the prompt messes it up.
  715. (define-key map "\t" 'self-insert-command)
  716. (define-key map [C-tab] 'file-cache-minibuffer-complete))
  717. (define-key global-map "\C-u" 'universal-argument)
  718. (let ((i ?0))
  719. (while (<= i ?9)
  720. (define-key esc-map (char-to-string i) 'digit-argument)
  721. (setq i (1+ i))))
  722. (define-key esc-map "-" 'negative-argument)
  723. ;; Define control-digits.
  724. (let ((i ?0))
  725. (while (<= i ?9)
  726. (define-key global-map (read (format "[?\\C-%c]" i)) 'digit-argument)
  727. (setq i (1+ i))))
  728. (define-key global-map [?\C--] 'negative-argument)
  729. ;; Define control-meta-digits.
  730. (let ((i ?0))
  731. (while (<= i ?9)
  732. (define-key esc-map (read (format "[?\\C-%c]" i)) 'digit-argument)
  733. (setq i (1+ i))))
  734. (define-key global-map [?\C-\M--] 'negative-argument)
  735. ;; Update tutorial--default-keys if you change these.
  736. (define-key global-map "\177" 'delete-backward-char)
  737. (define-key global-map "\C-d" 'delete-char)
  738. (define-key global-map "\C-k" 'kill-line)
  739. (define-key global-map "\C-w" 'kill-region)
  740. (define-key esc-map "w" 'kill-ring-save)
  741. (define-key esc-map "\C-w" 'append-next-kill)
  742. (define-key global-map "\C-y" 'yank)
  743. (define-key esc-map "y" 'yank-pop)
  744. ;; (define-key ctl-x-map "a" 'append-to-buffer)
  745. (define-key global-map "\C-@" 'set-mark-command)
  746. ;; Many people are used to typing C-SPC and getting C-@.
  747. (define-key global-map [?\C- ] 'set-mark-command)
  748. (put 'set-mark-command :advertised-binding [?\C- ])
  749. (define-key ctl-x-map "\C-x" 'exchange-point-and-mark)
  750. (define-key ctl-x-map "\C-@" 'pop-global-mark)
  751. (define-key ctl-x-map [?\C- ] 'pop-global-mark)
  752. (define-key global-map "\C-n" 'next-line)
  753. (define-key global-map "\C-p" 'previous-line)
  754. (define-key ctl-x-map "\C-n" 'set-goal-column)
  755. (define-key global-map "\C-a" 'move-beginning-of-line)
  756. (define-key global-map "\C-e" 'move-end-of-line)
  757. (define-key ctl-x-map "`" 'next-error)
  758. (defvar goto-map (make-sparse-keymap)
  759. "Keymap for navigation commands.")
  760. (define-key esc-map "g" goto-map)
  761. (define-key goto-map "c" 'goto-char)
  762. (define-key goto-map "g" 'goto-line)
  763. (define-key goto-map "\M-g" 'goto-line)
  764. (define-key goto-map "n" 'next-error)
  765. (define-key goto-map "\M-n" 'next-error)
  766. (define-key goto-map "p" 'previous-error)
  767. (define-key goto-map "\M-p" 'previous-error)
  768. (defvar search-map (make-sparse-keymap)
  769. "Keymap for search related commands.")
  770. (define-key esc-map "s" search-map)
  771. (define-key search-map "o" 'occur)
  772. (define-key search-map "hr" 'highlight-regexp)
  773. (define-key search-map "hp" 'highlight-phrase)
  774. (define-key search-map "hl" 'highlight-lines-matching-regexp)
  775. (define-key search-map "hu" 'unhighlight-regexp)
  776. (define-key search-map "hf" 'hi-lock-find-patterns)
  777. (define-key search-map "hw" 'hi-lock-write-interactive-patterns)
  778. ;;(defun function-key-error ()
  779. ;; (interactive)
  780. ;; (error "That function key is not bound to anything"))
  781. (define-key global-map [menu] 'execute-extended-command)
  782. (define-key global-map [find] 'search-forward)
  783. ;; Don't do this. We define <delete> in function-key-map instead.
  784. ;(define-key global-map [delete] 'backward-delete-char)
  785. ;; natural bindings for terminal keycaps --- defined in X keysym order
  786. (define-key global-map [C-S-backspace] 'kill-whole-line)
  787. (define-key global-map [home] 'move-beginning-of-line)
  788. (define-key global-map [C-home] 'beginning-of-buffer)
  789. (define-key global-map [M-home] 'beginning-of-buffer-other-window)
  790. (define-key esc-map [home] 'beginning-of-buffer-other-window)
  791. (define-key global-map [left] 'left-char)
  792. (define-key global-map [up] 'previous-line)
  793. (define-key global-map [right] 'right-char)
  794. (define-key global-map [down] 'next-line)
  795. (define-key global-map [prior] 'scroll-down-command)
  796. (define-key global-map [next] 'scroll-up-command)
  797. (define-key global-map [C-up] 'backward-paragraph)
  798. (define-key global-map [C-down] 'forward-paragraph)
  799. (define-key global-map [C-prior] 'scroll-right)
  800. (put 'scroll-left 'disabled t)
  801. (define-key global-map [C-next] 'scroll-left)
  802. (define-key global-map [M-next] 'scroll-other-window)
  803. (define-key esc-map [next] 'scroll-other-window)
  804. (define-key global-map [M-prior] 'scroll-other-window-down)
  805. (define-key esc-map [prior] 'scroll-other-window-down)
  806. (define-key esc-map [?\C-\S-v] 'scroll-other-window-down)
  807. (define-key global-map [end] 'move-end-of-line)
  808. (define-key global-map [C-end] 'end-of-buffer)
  809. (define-key global-map [M-end] 'end-of-buffer-other-window)
  810. (define-key esc-map [end] 'end-of-buffer-other-window)
  811. (define-key global-map [begin] 'beginning-of-buffer)
  812. (define-key global-map [M-begin] 'beginning-of-buffer-other-window)
  813. (define-key esc-map [begin] 'beginning-of-buffer-other-window)
  814. ;; (define-key global-map [select] 'function-key-error)
  815. ;; (define-key global-map [print] 'function-key-error)
  816. (define-key global-map [execute] 'execute-extended-command)
  817. (define-key global-map [insert] 'overwrite-mode)
  818. (define-key global-map [C-insert] 'kill-ring-save)
  819. (define-key global-map [S-insert] 'yank)
  820. ;; `insertchar' is what term.c produces. Should we change term.c
  821. ;; to produce `insert' instead?
  822. (define-key global-map [insertchar] 'overwrite-mode)
  823. (define-key global-map [C-insertchar] 'kill-ring-save)
  824. (define-key global-map [S-insertchar] 'yank)
  825. (define-key global-map [undo] 'undo)
  826. (define-key global-map [redo] 'repeat-complex-command)
  827. (define-key global-map [again] 'repeat-complex-command) ; Sun keyboard
  828. (define-key global-map [open] 'find-file) ; Sun
  829. ;; The following wouldn't work to interrupt running code since C-g is
  830. ;; treated specially in the event loop.
  831. ;; (define-key global-map [stop] 'keyboard-quit) ; Sun
  832. ;; (define-key global-map [clearline] 'function-key-error)
  833. (define-key global-map [insertline] 'open-line)
  834. (define-key global-map [deleteline] 'kill-line)
  835. (define-key global-map [deletechar] 'delete-forward-char)
  836. ;; (define-key global-map [backtab] 'function-key-error)
  837. ;; (define-key global-map [f1] 'function-key-error)
  838. ;; (define-key global-map [f2] 'function-key-error)
  839. ;; (define-key global-map [f3] 'function-key-error)
  840. ;; (define-key global-map [f4] 'function-key-error)
  841. ;; (define-key global-map [f5] 'function-key-error)
  842. ;; (define-key global-map [f6] 'function-key-error)
  843. ;; (define-key global-map [f7] 'function-key-error)
  844. ;; (define-key global-map [f8] 'function-key-error)
  845. ;; (define-key global-map [f9] 'function-key-error)
  846. ;; (define-key global-map [f10] 'function-key-error)
  847. ;; (define-key global-map [f11] 'function-key-error)
  848. ;; (define-key global-map [f12] 'function-key-error)
  849. ;; (define-key global-map [f13] 'function-key-error)
  850. ;; (define-key global-map [f14] 'function-key-error)
  851. ;; (define-key global-map [f15] 'function-key-error)
  852. ;; (define-key global-map [f16] 'function-key-error)
  853. ;; (define-key global-map [f17] 'function-key-error)
  854. ;; (define-key global-map [f18] 'function-key-error)
  855. ;; (define-key global-map [f19] 'function-key-error)
  856. ;; (define-key global-map [f20] 'function-key-error)
  857. ;; (define-key global-map [f21] 'function-key-error)
  858. ;; (define-key global-map [f22] 'function-key-error)
  859. ;; (define-key global-map [f23] 'function-key-error)
  860. ;; (define-key global-map [f24] 'function-key-error)
  861. ;; (define-key global-map [f25] 'function-key-error)
  862. ;; (define-key global-map [f26] 'function-key-error)
  863. ;; (define-key global-map [f27] 'function-key-error)
  864. ;; (define-key global-map [f28] 'function-key-error)
  865. ;; (define-key global-map [f29] 'function-key-error)
  866. ;; (define-key global-map [f30] 'function-key-error)
  867. ;; (define-key global-map [f31] 'function-key-error)
  868. ;; (define-key global-map [f32] 'function-key-error)
  869. ;; (define-key global-map [f33] 'function-key-error)
  870. ;; (define-key global-map [f34] 'function-key-error)
  871. ;; (define-key global-map [f35] 'function-key-error)
  872. ;; (define-key global-map [kp-backtab] 'function-key-error)
  873. ;; (define-key global-map [kp-space] 'function-key-error)
  874. ;; (define-key global-map [kp-tab] 'function-key-error)
  875. ;; (define-key global-map [kp-enter] 'function-key-error)
  876. ;; (define-key global-map [kp-f1] 'function-key-error)
  877. ;; (define-key global-map [kp-f2] 'function-key-error)
  878. ;; (define-key global-map [kp-f3] 'function-key-error)
  879. ;; (define-key global-map [kp-f4] 'function-key-error)
  880. ;; (define-key global-map [kp-multiply] 'function-key-error)
  881. ;; (define-key global-map [kp-add] 'function-key-error)
  882. ;; (define-key global-map [kp-separator] 'function-key-error)
  883. ;; (define-key global-map [kp-subtract] 'function-key-error)
  884. ;; (define-key global-map [kp-decimal] 'function-key-error)
  885. ;; (define-key global-map [kp-divide] 'function-key-error)
  886. ;; (define-key global-map [kp-0] 'function-key-error)
  887. ;; (define-key global-map [kp-1] 'function-key-error)
  888. ;; (define-key global-map [kp-2] 'function-key-error)
  889. ;; (define-key global-map [kp-3] 'function-key-error)
  890. ;; (define-key global-map [kp-4] 'function-key-error)
  891. ;; (define-key global-map [kp-5] 'recenter)
  892. ;; (define-key global-map [kp-6] 'function-key-error)
  893. ;; (define-key global-map [kp-7] 'function-key-error)
  894. ;; (define-key global-map [kp-8] 'function-key-error)
  895. ;; (define-key global-map [kp-9] 'function-key-error)
  896. ;; (define-key global-map [kp-equal] 'function-key-error)
  897. ;; X11R6 distinguishes these keys from the non-kp keys.
  898. ;; Make them behave like the non-kp keys unless otherwise bound.
  899. ;; FIXME: rather than list such mappings for every modifier-combination,
  900. ;; we should come up with a way to do it generically, something like
  901. ;; (define-key function-key-map [*-kp-home] [*-home])
  902. (define-key function-key-map [kp-home] [home])
  903. (define-key function-key-map [kp-left] [left])
  904. (define-key function-key-map [kp-up] [up])
  905. (define-key function-key-map [kp-right] [right])
  906. (define-key function-key-map [kp-down] [down])
  907. (define-key function-key-map [kp-prior] [prior])
  908. (define-key function-key-map [kp-next] [next])
  909. (define-key function-key-map [M-kp-next] [M-next])
  910. (define-key function-key-map [kp-end] [end])
  911. (define-key function-key-map [kp-begin] [begin])
  912. (define-key function-key-map [kp-insert] [insert])
  913. (define-key function-key-map [backspace] [?\C-?])
  914. (define-key function-key-map [delete] [?\C-?])
  915. (define-key function-key-map [kp-delete] [?\C-?])
  916. (define-key function-key-map [S-kp-end] [S-end])
  917. (define-key function-key-map [S-kp-down] [S-down])
  918. (define-key function-key-map [S-kp-next] [S-next])
  919. (define-key function-key-map [S-kp-left] [S-left])
  920. (define-key function-key-map [S-kp-right] [S-right])
  921. (define-key function-key-map [S-kp-home] [S-home])
  922. (define-key function-key-map [S-kp-up] [S-up])
  923. (define-key function-key-map [S-kp-prior] [S-prior])
  924. (define-key function-key-map [C-S-kp-end] [C-S-end])
  925. (define-key function-key-map [C-S-kp-down] [C-S-down])
  926. (define-key function-key-map [C-S-kp-next] [C-S-next])
  927. (define-key function-key-map [C-S-kp-left] [C-S-left])
  928. (define-key function-key-map [C-S-kp-right] [C-S-right])
  929. (define-key function-key-map [C-S-kp-home] [C-S-home])
  930. (define-key function-key-map [C-S-kp-up] [C-S-up])
  931. (define-key function-key-map [C-S-kp-prior] [C-S-prior])
  932. ;; Don't bind shifted keypad numeric keys, they reportedly
  933. ;; interfere with the feature of some keyboards to produce
  934. ;; numbers when NumLock is off.
  935. ;(define-key function-key-map [S-kp-1] [S-end])
  936. ;(define-key function-key-map [S-kp-2] [S-down])
  937. ;(define-key function-key-map [S-kp-3] [S-next])
  938. ;(define-key function-key-map [S-kp-4] [S-left])
  939. ;(define-key function-key-map [S-kp-6] [S-right])
  940. ;(define-key function-key-map [S-kp-7] [S-home])
  941. ;(define-key function-key-map [S-kp-8] [S-up])
  942. ;(define-key function-key-map [S-kp-9] [S-prior])
  943. (define-key function-key-map [C-S-kp-1] [C-S-end])
  944. (define-key function-key-map [C-S-kp-2] [C-S-down])
  945. (define-key function-key-map [C-S-kp-3] [C-S-next])
  946. (define-key function-key-map [C-S-kp-4] [C-S-left])
  947. (define-key function-key-map [C-S-kp-6] [C-S-right])
  948. (define-key function-key-map [C-S-kp-7] [C-S-home])
  949. (define-key function-key-map [C-S-kp-8] [C-S-up])
  950. (define-key function-key-map [C-S-kp-9] [C-S-prior])
  951. ;; Hitting C-SPC on text terminals, usually sends the ascii code 0 (aka C-@),
  952. ;; so we can't distinguish those two keys, but usually we consider C-SPC
  953. ;; (rather than C-@) as the "canonical" binding.
  954. (define-key function-key-map [?\C-@] [?\C-\s])
  955. ;; Many keyboards don't have a `backtab' key, so by convention the user
  956. ;; can use S-tab instead to access that binding.
  957. (define-key function-key-map [S-tab] [backtab])
  958. (define-key global-map [mouse-movement] 'ignore)
  959. (define-key global-map "\C-t" 'transpose-chars)
  960. (define-key esc-map "t" 'transpose-words)
  961. (define-key esc-map "\C-t" 'transpose-sexps)
  962. (define-key ctl-x-map "\C-t" 'transpose-lines)
  963. (define-key esc-map ";" 'comment-dwim)
  964. (define-key esc-map "j" 'indent-new-comment-line)
  965. (define-key esc-map "\C-j" 'indent-new-comment-line)
  966. (define-key ctl-x-map ";" 'comment-set-column)
  967. (define-key ctl-x-map "f" 'set-fill-column)
  968. (define-key ctl-x-map "$" 'set-selective-display)
  969. (define-key esc-map "@" 'mark-word)
  970. (define-key esc-map "f" 'forward-word)
  971. (define-key esc-map "b" 'backward-word)
  972. (define-key esc-map "d" 'kill-word)
  973. (define-key esc-map "\177" 'backward-kill-word)
  974. (define-key esc-map "<" 'beginning-of-buffer)
  975. (define-key esc-map ">" 'end-of-buffer)
  976. (define-key ctl-x-map "h" 'mark-whole-buffer)
  977. (define-key esc-map "\\" 'delete-horizontal-space)
  978. (defalias 'mode-specific-command-prefix (make-sparse-keymap))
  979. (defvar mode-specific-map (symbol-function 'mode-specific-command-prefix)
  980. "Keymap for characters following C-c.")
  981. (define-key global-map "\C-c" 'mode-specific-command-prefix)
  982. (global-set-key [M-right] 'right-word)
  983. (define-key esc-map [right] 'forward-word)
  984. (global-set-key [M-left] 'left-word)
  985. (define-key esc-map [left] 'backward-word)
  986. ;; ilya@math.ohio-state.edu says these bindings are standard on PC editors.
  987. (global-set-key [C-right] 'right-word)
  988. (global-set-key [C-left] 'left-word)
  989. ;; This is not quite compatible, but at least is analogous
  990. (global-set-key [C-delete] 'kill-word)
  991. (global-set-key [C-backspace] 'backward-kill-word)
  992. ;; This is "move to the clipboard", or as close as we come.
  993. (global-set-key [S-delete] 'kill-region)
  994. (global-set-key [C-M-left] 'backward-sexp)
  995. (define-key esc-map [C-left] 'backward-sexp)
  996. (global-set-key [C-M-right] 'forward-sexp)
  997. (define-key esc-map [C-right] 'forward-sexp)
  998. (global-set-key [C-M-up] 'backward-up-list)
  999. (define-key esc-map [C-up] 'backward-up-list)
  1000. (global-set-key [C-M-down] 'down-list)
  1001. (define-key esc-map [C-down] 'down-list)
  1002. (global-set-key [C-M-home] 'beginning-of-defun)
  1003. (define-key esc-map [C-home] 'beginning-of-defun)
  1004. (global-set-key [C-M-end] 'end-of-defun)
  1005. (define-key esc-map [C-end] 'end-of-defun)
  1006. (define-key esc-map "\C-f" 'forward-sexp)
  1007. (define-key esc-map "\C-b" 'backward-sexp)
  1008. (define-key esc-map "\C-u" 'backward-up-list)
  1009. (define-key esc-map "\C-@" 'mark-sexp)
  1010. (define-key esc-map [?\C-\ ] 'mark-sexp)
  1011. (define-key esc-map "\C-d" 'down-list)
  1012. (define-key esc-map "\C-k" 'kill-sexp)
  1013. ;;; These are dangerous in various situations,
  1014. ;;; so let's not encourage anyone to use them.
  1015. ;;;(define-key global-map [C-M-delete] 'backward-kill-sexp)
  1016. ;;;(define-key global-map [C-M-backspace] 'backward-kill-sexp)
  1017. (define-key esc-map [C-delete] 'backward-kill-sexp)
  1018. (define-key esc-map [C-backspace] 'backward-kill-sexp)
  1019. (define-key esc-map "\C-n" 'forward-list)
  1020. (define-key esc-map "\C-p" 'backward-list)
  1021. (define-key esc-map "\C-a" 'beginning-of-defun)
  1022. (define-key esc-map "\C-e" 'end-of-defun)
  1023. (define-key esc-map "\C-h" 'mark-defun)
  1024. (define-key ctl-x-map "nd" 'narrow-to-defun)
  1025. (define-key esc-map "(" 'insert-parentheses)
  1026. (define-key esc-map ")" 'move-past-close-and-reindent)
  1027. (define-key ctl-x-map "\C-e" 'eval-last-sexp)
  1028. (define-key ctl-x-map "m" 'compose-mail)
  1029. (define-key ctl-x-4-map "m" 'compose-mail-other-window)
  1030. (define-key ctl-x-5-map "m" 'compose-mail-other-frame)
  1031. (defvar ctl-x-r-map (make-sparse-keymap)
  1032. "Keymap for subcommands of C-x r.")
  1033. (define-key ctl-x-map "r" ctl-x-r-map)
  1034. (define-key esc-map "q" 'fill-paragraph)
  1035. (define-key ctl-x-map "." 'set-fill-prefix)
  1036. (define-key esc-map "{" 'backward-paragraph)
  1037. (define-key esc-map "}" 'forward-paragraph)
  1038. (define-key esc-map "h" 'mark-paragraph)
  1039. (define-key esc-map "a" 'backward-sentence)
  1040. (define-key esc-map "e" 'forward-sentence)
  1041. (define-key esc-map "k" 'kill-sentence)
  1042. (define-key ctl-x-map "\177" 'backward-kill-sentence)
  1043. (define-key ctl-x-map "[" 'backward-page)
  1044. (define-key ctl-x-map "]" 'forward-page)
  1045. (define-key ctl-x-map "\C-p" 'mark-page)
  1046. (define-key ctl-x-map "l" 'count-lines-page)
  1047. (define-key ctl-x-map "np" 'narrow-to-page)
  1048. ;; (define-key ctl-x-map "p" 'narrow-to-page)
  1049. (defvar abbrev-map (make-sparse-keymap)
  1050. "Keymap for abbrev commands.")
  1051. (define-key ctl-x-map "a" abbrev-map)
  1052. (define-key abbrev-map "l" 'add-mode-abbrev)
  1053. (define-key abbrev-map "\C-a" 'add-mode-abbrev)
  1054. (define-key abbrev-map "g" 'add-global-abbrev)
  1055. (define-key abbrev-map "+" 'add-mode-abbrev)
  1056. (define-key abbrev-map "ig" 'inverse-add-global-abbrev)
  1057. (define-key abbrev-map "il" 'inverse-add-mode-abbrev)
  1058. ;; (define-key abbrev-map "\C-h" 'inverse-add-global-abbrev)
  1059. (define-key abbrev-map "-" 'inverse-add-global-abbrev)
  1060. (define-key abbrev-map "e" 'expand-abbrev)
  1061. (define-key abbrev-map "'" 'expand-abbrev)
  1062. ;; (define-key ctl-x-map "\C-a" 'add-mode-abbrev)
  1063. ;; (define-key ctl-x-map "\+" 'add-global-abbrev)
  1064. ;; (define-key ctl-x-map "\C-h" 'inverse-add-mode-abbrev)
  1065. ;; (define-key ctl-x-map "\-" 'inverse-add-global-abbrev)
  1066. (define-key esc-map "'" 'abbrev-prefix-mark)
  1067. (define-key ctl-x-map "'" 'expand-abbrev)
  1068. (define-key ctl-x-map "\C-b" 'list-buffers)
  1069. (define-key ctl-x-map "z" 'repeat)
  1070. (define-key esc-map "\C-l" 'reposition-window)
  1071. (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
  1072. (define-key ctl-x-4-map "c" 'clone-indirect-buffer-other-window)
  1073. ;; Signal handlers
  1074. (define-key special-event-map [sigusr1] 'ignore)
  1075. (define-key special-event-map [sigusr2] 'ignore)
  1076. ;; Don't look for autoload cookies in this file.
  1077. ;; Local Variables:
  1078. ;; no-update-autoloads: t
  1079. ;; End:
  1080. ;;; bindings.el ends here