scribe.elc 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. (defvar scribe-mode-syntax-table nil "\
  2. Syntax table used while in scribe mode.")
  3. (defvar scribe-mode-abbrev-table nil "\
  4. Abbrev table used while in scribe mode.")
  5. (defvar scribe-fancy-paragraphs nil "\
  6. *Non-NIL makes Scribe mode use a different style of paragraph separation.")
  7. (defvar scribe-electric-quote nil "\
  8. *Non-NIL makes insert of double quote use `` or '' depending on context.")
  9. (defvar scribe-electric-parenthesis nil "\
  10. *Non-NIL makes parenthesis char ( (]}> ) automatically insert its close
  11. if typed after an @Command form.")
  12. (defconst scribe-open-parentheses "[({<" "\
  13. Open parenthesis characters for Scribe.")
  14. (defconst scribe-close-parentheses "])}>" "\
  15. Close parenthesis characters for Scribe. These should match up with
  16. scribe-open-parenthesis.")
  17. (if (null scribe-mode-syntax-table) (let ((st (syntax-table))) (unwind-protect (progn (setq scribe-mode-syntax-table (copy-syntax-table text-mode-syntax-table)) (set-syntax-table scribe-mode-syntax-table) (modify-syntax-entry 34 " ") (modify-syntax-entry 92 " ") (modify-syntax-entry 64 "w ") (modify-syntax-entry 60 "(> ") (modify-syntax-entry 62 ")< ") (modify-syntax-entry 91 "(] ") (modify-syntax-entry 93 ")[ ") (modify-syntax-entry 123 "(} ") (modify-syntax-entry 125 "){ ") (modify-syntax-entry 39 "w ")) (set-syntax-table st))))
  18. (defvar scribe-mode-map nil)
  19. (if scribe-mode-map nil (setq scribe-mode-map (make-sparse-keymap)) (define-key scribe-mode-map " " (quote scribe-tab)) (define-key scribe-mode-map " " (quote tab-to-tab-stop)) (define-key scribe-mode-map "s" (quote center-line)) (define-key scribe-mode-map "}" (quote up-list)) (define-key scribe-mode-map "S" (quote center-paragraph)) (define-key scribe-mode-map "\"" (quote scribe-insert-quote)) (define-key scribe-mode-map "(" (quote scribe-parenthesis)) (define-key scribe-mode-map "[" (quote scribe-parenthesis)) (define-key scribe-mode-map "{" (quote scribe-parenthesis)) (define-key scribe-mode-map "<" (quote scribe-parenthesis)) (define-key scribe-mode-map "c" (quote scribe-chapter)) (define-key scribe-mode-map "S" (quote scribe-section)) (define-key scribe-mode-map "s" (quote scribe-subsection)) (define-key scribe-mode-map "e" (quote scribe-insert-environment)) (define-key scribe-mode-map "" (quote scribe-bracket-region-be)) (define-key scribe-mode-map "[" (quote scribe-begin)) (define-key scribe-mode-map "]" (quote scribe-end)) (define-key scribe-mode-map "i" (quote scribe-italicize-word)) (define-key scribe-mode-map "b" (quote scribe-bold-word)) (define-key scribe-mode-map "u" (quote scribe-underline-word)))
  20. (defun scribe-mode nil "\
  21. Major mode for editing files of Scribe (a text formatter) source.
  22. Scribe-mode is similar text-mode, with a few extra commands added.
  23. \\{scribe-mode-map}
  24. Interesting variables:
  25. scribe-fancy-paragraphs
  26. Non-nil makes Scribe mode use a different style of paragraph separation.
  27. scribe-electric-quote
  28. Non-nil makes insert of double quote use `` or '' depending on context.
  29. scribe-electric-parenthesis
  30. Non-nil makes an open-parenthesis char (one of `([<{')
  31. automatically insert its close if typed after an @Command form." (interactive) (byte-code "ÃˆÑ ˆÒ!ˆÓ‰ˆÔ‰ˆÕÅÃ\"ˆ ‰ˆÖÆ!ˆ×‰ˆÖÇ!ˆ×ØQ‰ˆÖÉ!ˆÙ‰ ˆÖÊ!ˆØ‰
  32. ˆÖË!ˆÚÛÜ Ý%‰ ˆÖÍ!ˆƒa ‚bÞ‰ ˆÖÏ!ˆßà P‰ˆá!ˆâãä\"‡" [scribe-mode-map mode-name major-mode nil local-abbrev-table scribe-mode-abbrev-table comment-start comment-start-skip scribe-open-parentheses comment-column comment-end paragraph-start scribe-close-parentheses paragraph-separate scribe-fancy-paragraphs compile-command scribe-mode-syntax-table kill-all-local-variables use-local-map "Scribe" scribe-mode define-abbrev-table make-local-variable "@Comment[" "]" 0 concat "\\(^[
  33. ]\\)\\|\\(^@\\w+[" "].*[" "]$\\)" "^$" "scribe " buffer-file-name set-syntax-table run-hooks text-mode-hook scribe-mode-hook] 16))
  34. (defun scribe-tab nil (interactive) (byte-code "ÀˆÁc‡" [nil "@\\"] 1))
  35. (defun scribe nil "\
  36. Run Scribe on the current buffer." (interactive) (byte-code "ÀˆÁÂ!‡" [nil call-interactively compile] 2))
  37. (defun scribe-envelop-word (string count) "\
  38. Surround current word with Scribe construct @STRING[...]. COUNT
  39. specifies how many words to surround. A negative count means to skip
  40. backward." (byte-code "``ÉÊË !?…DÌh!ÍU…ÎÏ ^!ˆ`‰ˆÐÑ ÒQ!ƒ0ÓÔ!‚: bˆÕÖ!ˆÓÏ!ˆÎ ×]!ˆ`‰ˆbˆ
  41. GW…nŠØÙ
  42. H! Æ#†fØÙ
  43. H! Æ#)…n
  44. T‰…vʈ‚Hˆ
  45. GYƒ” bˆÚÛÜ#ˆbˆÚÝÜ#‚´ bˆ
  46. HcˆbˆÚÞ
  47. H#ˆ bˆÓß!ˆà!,‡" [spos epos ccoun noparens count scribe-open-parentheses t scribe-close-parentheses string 0 nil zerop char-syntax 119 forward-sexp -1 looking-at "@\\w[" "]" forward-char 2 skip-chars-backward "\\W" 1 search-forward char-to-string insert "@end(" ")" "@begin(" "@" 3 skip-chars-forward] 19))
  48. (defun scribe-underline-word (count) "\
  49. Underline COUNT words around point by means of Scribe constructs." (interactive "p") (byte-code "ÁˆÂÃ\"‡" [count nil scribe-envelop-word "u"] 3))
  50. (defun scribe-bold-word (count) "\
  51. Boldface COUNT words around point by means of Scribe constructs." (interactive "p") (byte-code "ÁˆÂÃ\"‡" [count nil scribe-envelop-word "b"] 3))
  52. (defun scribe-italicize-word (count) "\
  53. Italicize COUNT words around point by means of Scribe constructs." (interactive "p") (byte-code "ÁˆÂÃ\"‡" [count nil scribe-envelop-word "i"] 3))
  54. (defun scribe-begin nil (interactive) (byte-code "ÁˆÂcˆÃÄ!ˆÅÆÇ\"ˆÈÉÊQ!‡" [scribe-open-parentheses nil "
  55. " forward-char -1 scribe-envelop-word "Begin" 0 re-search-forward "[" "]"] 6))
  56. (defun scribe-end nil (interactive) (byte-code "ÁˆÂcˆÃÄ!ˆÅÆÇ\"ˆÈÉÊQ!‡" [scribe-open-parentheses nil "
  57. " forward-char -1 scribe-envelop-word "End" 0 re-search-forward "[" "]"] 6))
  58. (defun scribe-chapter nil (interactive) (byte-code "ÁˆÂcˆÃÄ!ˆÅÆÇ\"ˆÈÉÊQ!‡" [scribe-open-parentheses nil "
  59. " forward-char -1 scribe-envelop-word "Chapter" 0 re-search-forward "[" "]"] 6))
  60. (defun scribe-section nil (interactive) (byte-code "ÁˆÂcˆÃÄ!ˆÅÆÇ\"ˆÈÉÊQ!‡" [scribe-open-parentheses nil "
  61. " forward-char -1 scribe-envelop-word "Section" 0 re-search-forward "[" "]"] 6))
  62. (defun scribe-subsection nil (interactive) (byte-code "ÁˆÂcˆÃÄ!ˆÅÆÇ\"ˆÈÉÊQ!‡" [scribe-open-parentheses nil "
  63. " forward-char -1 scribe-envelop-word "SubSection" 0 re-search-forward "[" "]"] 6))
  64. (defun scribe-bracket-region-be (env min max) (interactive "sEnvironment:
  65. r") (byte-code "ÈŠbˆÄÅ Æ#ˆ
  66. bˆÄÇ Æ#)‡" [max env min nil insert "@end(" ")
  67. " "@begin("] 5))
  68. (defun scribe-insert-environment (env) (interactive "sEnvironment: ") (byte-code "ÁˆÂ``#ˆÃÄ!ˆÅcˆÆÇ!‡" [env nil scribe-bracket-region-be forward-line 1 10 forward-char -1] 4))
  69. (defun scribe-insert-quote (count) "\
  70. If scribe-electric-quote is non-NIL, insert ``, '' or \" according
  71. to preceding character. With numeric arg N, always insert N \" characters.
  72. Else just insert \"." (interactive "P") (byte-code "ƈ† ?ƒÇÈ!!‚óÆÆÆhÉUƒ#Ê‚ñoƒ+Ë‚ñŠÌË`ÍZÅ#…7`)ŠÌÎ`ÍZÅ#…E`)ŠÌÏ`ÐZÅ#…S`)‰ˆ ?ƒ|
  73. ?ƒeË‚y ?ƒn΂y
  74. Vƒx΂yË‚ñ ?…ƒ
  75. ?ƒŠÏ‚ñ …–
  76. ?…– Vƒ�Ï‚ñ …©
  77. ?…© Vƒ°Ë‚ñ
  78. …¼ ?…¼
  79. VƒÃÏ‚ñ
  80. …Ï ?…Ï
  81. VƒÖ΂ñ
  82. V…ß VƒæÏ‚ñ
  83. Vƒð΂ñËc+‡" [count scribe-electric-quote lastfore lastback lastquote t nil self-insert-command prefix-numeric-value 92 34 "``" search-backward 1000 "''" "\"" 100] 8))
  84. (defun scribe-parenthesis (count) "\
  85. If scribe-electric-parenthesis is non-NIL, insertion of an open-parenthesis
  86. character inserts the following close parenthesis character if the
  87. preceding text is of the form @Command." (interactive "P") (byte-code "ňÈÉ!!ˆÅÅņ ?ƒÅ‚TŠÊË!ˆ`‰ˆÌÍP!ˆÎgÏ\"…7Ð` S\"‰)ˆ …JÑÒÓh!!\"‰…TŠ
  88. Hc)+‡" [count at-command paren-char point-save scribe-electric-parenthesis nil scribe-open-parentheses scribe-close-parentheses self-insert-command prefix-numeric-value forward-char -1 skip-chars-backward "^
  89. " equal 64 /= string-match regexp-quote char-to-string] 11))