diff options
| author | Stefan Monnier | 2007-08-10 06:52:54 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-08-10 06:52:54 +0000 |
| commit | 62fc0b713fd855a94153a2045dbf985b28e24770 (patch) | |
| tree | ad9d88607bcd79dbbb70e65a64c78e0bc5ed7953 | |
| parent | 3527bdcc4375b6991fc986d83fb5fc0203254ce8 (diff) | |
| download | emacs-62fc0b713fd855a94153a2045dbf985b28e24770.tar.gz emacs-62fc0b713fd855a94153a2045dbf985b28e24770.zip | |
*** empty log message ***
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/textmodes/bibtex-style.el | 155 |
3 files changed, 165 insertions, 0 deletions
| @@ -55,6 +55,8 @@ in to make it use the scrollbars from the system theme. | |||
| 55 | 55 | ||
| 56 | * New Modes and Packages in Emacs 22.2 | 56 | * New Modes and Packages in Emacs 22.2 |
| 57 | 57 | ||
| 58 | ** bibtex-style-mode helps you write BibTeX's *.bst files. | ||
| 59 | |||
| 58 | ** The new package css-mode.el provides a major mode for editing CSS files. | 60 | ** The new package css-mode.el provides a major mode for editing CSS files. |
| 59 | 61 | ||
| 60 | ** The new package vera-mode.el provides a major mode for editing Vera files. | 62 | ** The new package vera-mode.el provides a major mode for editing Vera files. |
| @@ -67,6 +69,8 @@ in to make it use the scrollbars from the system theme. | |||
| 67 | 69 | ||
| 68 | *** VC has some support for Mercurial (hg). | 70 | *** VC has some support for Mercurial (hg). |
| 69 | 71 | ||
| 72 | *** VC has some support for Bazaar (Bzr). | ||
| 73 | |||
| 70 | *** VC has some support for Git. | 74 | *** VC has some support for Git. |
| 71 | 75 | ||
| 72 | * Lisp Changes in Emacs 22.2. | 76 | * Lisp Changes in Emacs 22.2. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e53d67b2c41..43508f79101 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2007-08-10 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * emacs-lisp/backquote.el (backquote-delay-process): New function. | ||
| 4 | (backquote-process): Add internal arg `level'. Use the two to | ||
| 5 | correctly handle nested backquotes. | ||
| 6 | |||
| 1 | 2007-08-09 Riccardo Murri <riccardo.murri@gmail.com> | 7 | 2007-08-09 Riccardo Murri <riccardo.murri@gmail.com> |
| 2 | 8 | ||
| 3 | * vc-bzr.el (vc-bzr-registered): Use \0 instead of literal NULs. | 9 | * vc-bzr.el (vc-bzr-registered): Use \0 instead of literal NULs. |
diff --git a/lisp/textmodes/bibtex-style.el b/lisp/textmodes/bibtex-style.el new file mode 100644 index 00000000000..99c2f92cab0 --- /dev/null +++ b/lisp/textmodes/bibtex-style.el | |||
| @@ -0,0 +1,155 @@ | |||
| 1 | ;;; bibtex-style.el --- Major mode for BibTeX Style files | ||
| 2 | |||
| 3 | ;; Copyright (C) 2005,2007 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 6 | ;; Keywords: | ||
| 7 | |||
| 8 | ;; This file 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, or (at your option) | ||
| 11 | ;; any later version. | ||
| 12 | |||
| 13 | ;; This file is distributed in the hope that it will be useful, | ||
| 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | ;; GNU General Public License for more details. | ||
| 17 | |||
| 18 | ;; You should have received a copy of the GNU General Public License | ||
| 19 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | ||
| 20 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
| 21 | ;; Boston, MA 02110-1301, USA. | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | ;; Done: font-lock, imenu, outline, commenting, indentation. | ||
| 26 | ;; Todo: tab-completion. | ||
| 27 | ;; Bugs: | ||
| 28 | |||
| 29 | ;;; Code: | ||
| 30 | |||
| 31 | (defvar bibtex-style-mode-syntax-table | ||
| 32 | (let ((st (make-syntax-table))) | ||
| 33 | (modify-syntax-entry ?% "<" st) | ||
| 34 | (modify-syntax-entry ?\n ">" st) | ||
| 35 | (modify-syntax-entry ?\{ "(}" st) | ||
| 36 | (modify-syntax-entry ?\} "){" st) | ||
| 37 | (modify-syntax-entry ?\" "\"" st) | ||
| 38 | (modify-syntax-entry ?. "_" st) | ||
| 39 | (modify-syntax-entry ?' "'" st) | ||
| 40 | (modify-syntax-entry ?# "'" st) | ||
| 41 | (modify-syntax-entry ?* "." st) | ||
| 42 | (modify-syntax-entry ?= "." st) | ||
| 43 | (modify-syntax-entry ?$ "_" st) | ||
| 44 | st)) | ||
| 45 | |||
| 46 | |||
| 47 | (defconst bibtex-style-commands | ||
| 48 | '("ENTRY" "EXECUTE" "FUNCTION" "INTEGERS" "ITERATE" "MACRO" "READ" | ||
| 49 | "REVERSE" "SORT" "STRINGS")) | ||
| 50 | |||
| 51 | (defconst bibtex-style-functions | ||
| 52 | ;; From http://www.eeng.dcu.ie/local-docs/btxdocs/btxhak/btxhak/node4.html. | ||
| 53 | '("<" ">" "=" "+" "-" "*" ":=" | ||
| 54 | "add.period$" "call.type$" "change.case$" "chr.to.int$" "cite$" | ||
| 55 | "duplicate$" "empty$" "format.name$" "if$" "int.to.chr$" "int.to.str$" | ||
| 56 | "missing$" "newline$" "num.names$" "pop$" "preamble$" "purify$" "quote$" | ||
| 57 | "skip$" "stack$" "substring$" "swap$" "text.length$" "text.prefix$" | ||
| 58 | "top$" "type$" "warning$" "while$" "width$" "write$")) | ||
| 59 | |||
| 60 | (defvar bibtex-style-font-lock-keywords | ||
| 61 | `((,(regexp-opt bibtex-style-commands 'words) . font-lock-keyword-face) | ||
| 62 | ("\\w+\\$" . font-lock-keyword-face) | ||
| 63 | ("\\<\\(FUNCTION\\|MACRO\\)\\s-+{\\([^}\n]+\\)}" | ||
| 64 | (2 font-lock-function-name-face)))) | ||
| 65 | |||
| 66 | ;;;###autoload (add-to-list 'auto-mode-alist '("\\.bst\\'" . bibtex-style-mode)) | ||
| 67 | |||
| 68 | ;;;###autoload | ||
| 69 | (define-derived-mode bibtex-style-mode nil "BibStyle" | ||
| 70 | "Major mode for editing BibTeX style files." | ||
| 71 | (set (make-local-variable 'comment-start) "%") | ||
| 72 | (set (make-local-variable 'outline-regexp) "^[a-z]") | ||
| 73 | (set (make-local-variable 'imenu-generic-expression) | ||
| 74 | '((nil "\\<\\(FUNCTION\\|MACRO\\)\\s-+{\\([^}\n]+\\)}" 2))) | ||
| 75 | (set (make-local-variable 'indent-line-function) 'bibtex-style-indent-line) | ||
| 76 | (set (make-local-variable 'parse-sexp-ignore-comments) t) | ||
| 77 | (setq font-lock-defaults | ||
| 78 | '(bibtex-style-font-lock-keywords nil t | ||
| 79 | ((?. . "w"))))) | ||
| 80 | |||
| 81 | (defun bibtex-style-indent-line () | ||
| 82 | "Indent current line of BibTeX Style code." | ||
| 83 | (interactive) | ||
| 84 | (let* ((savep (point)) | ||
| 85 | (indent (condition-case nil | ||
| 86 | (save-excursion | ||
| 87 | (forward-line 0) | ||
| 88 | (skip-chars-forward " \t") | ||
| 89 | (if (>= (point) savep) (setq savep nil)) | ||
| 90 | (max (bibtex-style-calculate-indentation) 0)) | ||
| 91 | (error 0)))) | ||
| 92 | (if savep | ||
| 93 | (save-excursion (indent-line-to indent)) | ||
| 94 | (indent-line-to indent)))) | ||
| 95 | |||
| 96 | (defcustom bibtex-style-indent-basic 2 | ||
| 97 | "Basic amount of indentation to use in BibTeX Style mode." | ||
| 98 | :type 'integer) | ||
| 99 | |||
| 100 | (defun bibtex-style-calculate-indentation (&optional virt) | ||
| 101 | (or | ||
| 102 | ;; Stick the first line at column 0. | ||
| 103 | (and (= (point-min) (line-beginning-position)) 0) | ||
| 104 | ;; Commands start at column 0. | ||
| 105 | (and (looking-at (regexp-opt bibtex-style-commands 'words)) 0) | ||
| 106 | ;; Trust the current indentation, if such info is applicable. | ||
| 107 | (and virt (save-excursion (skip-chars-backward " \t{") (bolp)) | ||
| 108 | (current-column)) | ||
| 109 | ;; Put leading close-paren where the matching open brace would be. | ||
| 110 | (and (looking-at "}") | ||
| 111 | (condition-case nil | ||
| 112 | (save-excursion | ||
| 113 | (up-list -1) | ||
| 114 | (bibtex-style-calculate-indentation 'virt)) | ||
| 115 | (scan-error nil))) | ||
| 116 | ;; Align leading "if$" with previous command. | ||
| 117 | (and (looking-at "if\\$") | ||
| 118 | (condition-case nil | ||
| 119 | (save-excursion | ||
| 120 | (backward-sexp 3) | ||
| 121 | (bibtex-style-calculate-indentation 'virt)) | ||
| 122 | (scan-error | ||
| 123 | ;; There is no command before the "if$". | ||
| 124 | (condition-case nil | ||
| 125 | (save-excursion | ||
| 126 | (up-list -1) | ||
| 127 | (+ bibtex-style-indent-basic | ||
| 128 | (bibtex-style-calculate-indentation 'virt))) | ||
| 129 | (scan-error nil))))) | ||
| 130 | ;; Right after an opening brace. | ||
| 131 | (condition-case err (save-excursion (backward-sexp 1) nil) | ||
| 132 | (scan-error (goto-char (nth 2 err)) | ||
| 133 | (+ bibtex-style-indent-basic | ||
| 134 | (bibtex-style-calculate-indentation 'virt)))) | ||
| 135 | ;; Default, align with previous command. | ||
| 136 | (let ((fai ;; First arm of an "if$". | ||
| 137 | (condition-case nil | ||
| 138 | (save-excursion | ||
| 139 | (forward-sexp 2) | ||
| 140 | (forward-comment (point-max)) | ||
| 141 | (looking-at "if\\$")) | ||
| 142 | (scan-error nil)))) | ||
| 143 | (save-excursion | ||
| 144 | (condition-case err | ||
| 145 | (while (progn | ||
| 146 | (backward-sexp 1) | ||
| 147 | (save-excursion (skip-chars-backward " \t{") (not (bolp))))) | ||
| 148 | (scan-error nil)) | ||
| 149 | (+ (current-column) | ||
| 150 | (if (or fai (looking-at "ENTRY")) bibtex-style-indent-basic 0)))))) | ||
| 151 | |||
| 152 | |||
| 153 | (provide 'bibtex-style) | ||
| 154 | ;; arch-tag: b20ad41a-fd36-466e-8fd2-cc6137f9c55c | ||
| 155 | ;;; bibtex-style.el ends here | ||