Mercurial > hg > xemacs
comparison xquery-mode.el @ 21:7b2c4ed36302
for new maritain
author | ht |
---|---|
date | Mon, 30 Nov 2020 16:00:15 +0000 |
parents | 75ab6d7af627 |
children |
comparison
equal
deleted
inserted
replaced
20:06827fc8ae79 | 21:7b2c4ed36302 |
---|---|
57 ) | 57 ) |
58 ("as\\s +\\(\\w*:?\\w+\\)" | 58 ("as\\s +\\(\\w*:?\\w+\\)" |
59 (1 font-lock-type-face) | 59 (1 font-lock-type-face) |
60 ) | 60 ) |
61 ) ;font-lock-list | 61 ) ;font-lock-list |
62 '(".xq\\'") ;auto-mode-list | 62 '(".xq[ml]?$") ;auto-mode-list |
63 nil ;function list | 63 '(xquery-set-indent-function xquery-set-up-syntax-table) ;function list |
64 "A Major mode for editing xquery." | 64 "A Major mode for editing xquery." |
65 ) | 65 ) |
66 | 66 |
67 | 67 |
68 | 68 |
71 (setq nxml-prolog-end (point-min)) | 71 (setq nxml-prolog-end (point-min)) |
72 (setq nxml-scan-end (copy-marker (point-min) nil)) | 72 (setq nxml-scan-end (copy-marker (point-min) nil)) |
73 (set (make-local-variable 'indent-line-function) 'xquery-indent-line) | 73 (set (make-local-variable 'indent-line-function) 'xquery-indent-line) |
74 (make-local-variable 'forward-sexp-function) | 74 (make-local-variable 'forward-sexp-function) |
75 (setq forward-sexp-function 'xquery-forward-sexp) | 75 (setq forward-sexp-function 'xquery-forward-sexp) |
76 (local-set-key "/" 'nxml-electric-slash) | 76 ;;(local-set-key "/" 'nxml-electric-slash) |
77 ) | 77 ) |
78 | 78 |
79 (defun xquery-forward-sexp (&optional arg) | 79 (defun xquery-forward-sexp (&optional arg) |
80 "Xquery forward s-expresssion. | 80 "Xquery forward s-expresssion. |
81 This function is not very smart, it tries to use | 81 This function is not very smart, it tries to use |
100 ;; set-up the syntax table correctly for parentheis type characters | 100 ;; set-up the syntax table correctly for parentheis type characters |
101 (modify-syntax-entry ?\{ "(}" (syntax-table)) | 101 (modify-syntax-entry ?\{ "(}" (syntax-table)) |
102 (modify-syntax-entry ?\} "){" (syntax-table)) | 102 (modify-syntax-entry ?\} "){" (syntax-table)) |
103 (modify-syntax-entry ?\[ "(]" (syntax-table)) | 103 (modify-syntax-entry ?\[ "(]" (syntax-table)) |
104 (modify-syntax-entry ?\] ")]" (syntax-table)) | 104 (modify-syntax-entry ?\] ")]" (syntax-table)) |
105 (modify-syntax-entry ?\< "(>1" (syntax-table)) | |
106 (modify-syntax-entry ?\> ")<4" (syntax-table)) | |
107 ;; xquery comments are like (: :) | |
108 (modify-syntax-entry ?\( "()1" (syntax-table)) | 105 (modify-syntax-entry ?\( "()1" (syntax-table)) |
109 (modify-syntax-entry ?\) ")(4" (syntax-table)) | 106 (modify-syntax-entry ?\) ")(4" (syntax-table)) |
110 ;; (modify-syntax-entry ?\: ".23" (syntax-table)) | 107 ;;(modify-syntax-entry ?\< "(>" (syntax-table)) |
108 ;;(modify-syntax-entry ?\> ")<" (syntax-table)) | |
109 ;; xquery comments are like (: :) -- handled above at mode decl | |
110 ;;(modify-syntax-entry ?\: ".23" (syntax-table)) | |
111 ) | 111 ) |
112 | 112 |
113 | 113 |
114 | 114 |
115 (defun xquery-indent-line () | 115 (defun xquery-indent-line () |
218 (if xquery-indent-debug | 218 (if xquery-indent-debug |
219 (message "xquery-indent-debug: everyting else")) | 219 (message "xquery-indent-debug: everyting else")) |
220 (save-excursion (xquery-previous-non-empty-line) (current-indentation))) | 220 (save-excursion (xquery-previous-non-empty-line) (current-indentation))) |
221 ))) | 221 ))) |
222 | 222 |
223 (when (featurep 'xemacs) | |
224 (unless (functionp 'looking-back) | |
225 ;; from GNU Emacs subr.el | |
226 (defun looking-back (regexp &optional limit greedy) | |
227 "Return non-nil if text before point matches regular expression | |
228 REGEXP. | |
229 Like `looking-at' except matches before point, and is slower. | |
230 LIMIT if non-nil speeds up the search by specifying a minimum | |
231 starting position, to avoid checking matches that would start | |
232 before LIMIT. | |
233 If GREEDY is non-nil, extend the match backwards as far as possible, | |
234 stopping when a single additional previous character cannot be part | |
235 of a match for REGEXP." | |
236 (let ((start (point)) | |
237 (pos | |
238 (save-excursion | |
239 (and (re-search-backward (concat "\\(?:" regexp | |
240 "\\)\\=") limit t) | |
241 (point))))) | |
242 (if (and greedy pos) | |
243 (save-restriction | |
244 (narrow-to-region (point-min) start) | |
245 (while (and (> pos (point-min)) | |
246 (save-excursion | |
247 (goto-char pos) | |
248 (backward-char 1) | |
249 (looking-at (concat "\\(?:" regexp | |
250 "\\)\\'")))) | |
251 (setq pos (1- pos))) | |
252 (save-excursion | |
253 (goto-char pos) | |
254 (looking-at (concat "\\(?:" regexp "\\)\\'"))))) | |
255 (not (null pos)))))) | |
223 | 256 |
224 (defun xquery-previous-non-empty-line () | 257 (defun xquery-previous-non-empty-line () |
225 "Move to the last non-empty line." | 258 "Move to the last non-empty line." |
226 (re-search-backward "\\S " (point-min) t) | 259 (re-search-backward "\\S " (point-min) t) |
227 ) | 260 ) |