aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier2010-09-20 16:57:01 +0200
committerStefan Monnier2010-09-20 16:57:01 +0200
commit3672149f83cf8c99f0d100f1a6e4419360b0fa43 (patch)
tree04b89e41a447344774b7a6a2343dd39623dde31f /lisp
parent549d0e1ec428bf4d1448a3143d7374e2b860de25 (diff)
downloademacs-3672149f83cf8c99f0d100f1a6e4419360b0fa43.tar.gz
emacs-3672149f83cf8c99f0d100f1a6e4419360b0fa43.zip
* lisp/progmodes/pascal.el (pascal-mode): Use define-derived-mode.
Set invisibility spec for pascal's outline mode. (pascal-outline-change): Clean up calling convention. (pascal-show-all, pascal-hide-other-defuns): Update callers.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/progmodes/pascal.el110
2 files changed, 52 insertions, 63 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 583a2130052..dadc344e9fc 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
12010-09-20 Stefan Monnier <monnier@iro.umontreal.ca> 12010-09-20 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * progmodes/pascal.el (pascal-mode): Use define-derived-mode.
4 Set invisibility spec for pascal's outline mode.
5 (pascal-outline-change): Clean up calling convention.
6 (pascal-show-all, pascal-hide-other-defuns): Update callers.
7
3 * progmodes/prolog.el (prolog-smie-forward-token) 8 * progmodes/prolog.el (prolog-smie-forward-token)
4 (prolog-smie-backward-token): New functions. 9 (prolog-smie-backward-token): New functions.
5 (prolog-mode-variables): Use them to parse "!," correctly. 10 (prolog-mode-variables): Use them to parse "!," correctly.
diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el
index d19fa08bf6c..acd49e71dd8 100644
--- a/lisp/progmodes/pascal.el
+++ b/lisp/progmodes/pascal.el
@@ -223,7 +223,7 @@ The name of the function or case is included between the braces."
223 "*List of contexts where auto lineup of :'s or ='s should be done. 223 "*List of contexts where auto lineup of :'s or ='s should be done.
224Elements can be of type: 'paramlist', 'declaration' or 'case', which will 224Elements can be of type: 'paramlist', 'declaration' or 'case', which will
225do auto lineup in parameterlist, declarations or case-statements 225do auto lineup in parameterlist, declarations or case-statements
226respectively. The word 'all' will do all lineups. '(case paramlist) for 226respectively. The word 'all' will do all lineups. '(case paramlist) for
227instance will do lineup in case-statements and parameterlist, while '(all) 227instance will do lineup in case-statements and parameterlist, while '(all)
228will do all lineups." 228will do all lineups."
229 :type '(set :extra-offset 8 229 :type '(set :extra-offset 8
@@ -311,7 +311,7 @@ are handled in another way, and should not be added to this list."
311 311
312 312
313;;;###autoload 313;;;###autoload
314(defun pascal-mode () 314(define-derived-mode pascal-mode prog-mode "Pascal"
315 "Major mode for editing Pascal code. \\<pascal-mode-map> 315 "Major mode for editing Pascal code. \\<pascal-mode-map>
316TAB indents for Pascal code. Delete converts tabs to spaces as it moves back. 316TAB indents for Pascal code. Delete converts tabs to spaces as it moves back.
317 317
@@ -334,60 +334,47 @@ Other useful functions are:
334 334
335Variables controlling indentation/edit style: 335Variables controlling indentation/edit style:
336 336
337 pascal-indent-level (default 3) 337 `pascal-indent-level' (default 3)
338 Indentation of Pascal statements with respect to containing block. 338 Indentation of Pascal statements with respect to containing block.
339 pascal-case-indent (default 2) 339 `pascal-case-indent' (default 2)
340 Indentation for case statements. 340 Indentation for case statements.
341 pascal-auto-newline (default nil) 341 `pascal-auto-newline' (default nil)
342 Non-nil means automatically newline after semicolons and the punctuation 342 Non-nil means automatically newline after semicolons and the punctuation
343 mark after an end. 343 mark after an end.
344 pascal-indent-nested-functions (default t) 344 `pascal-indent-nested-functions' (default t)
345 Non-nil means nested functions are indented. 345 Non-nil means nested functions are indented.
346 pascal-tab-always-indent (default t) 346 `pascal-tab-always-indent' (default t)
347 Non-nil means TAB in Pascal mode should always reindent the current line, 347 Non-nil means TAB in Pascal mode should always reindent the current line,
348 regardless of where in the line point is when the TAB command is used. 348 regardless of where in the line point is when the TAB command is used.
349 pascal-auto-endcomments (default t) 349 `pascal-auto-endcomments' (default t)
350 Non-nil means a comment { ... } is set after the ends which ends cases and 350 Non-nil means a comment { ... } is set after the ends which ends cases and
351 functions. The name of the function or case will be set between the braces. 351 functions. The name of the function or case will be set between the braces.
352 pascal-auto-lineup (default t) 352 `pascal-auto-lineup' (default t)
353 List of contexts where auto lineup of :'s or ='s should be done. 353 List of contexts where auto lineup of :'s or ='s should be done.
354 354
355See also the user variables pascal-type-keywords, pascal-start-keywords and 355See also the user variables `pascal-type-keywords', `pascal-start-keywords' and
356pascal-separator-keywords. 356`pascal-separator-keywords'.
357 357
358Turning on Pascal mode calls the value of the variable pascal-mode-hook with 358Turning on Pascal mode calls the value of the variable pascal-mode-hook with
359no args, if that value is non-nil." 359no args, if that value is non-nil."
360 (interactive) 360 (set (make-local-variable 'local-abbrev-table) pascal-mode-abbrev-table)
361 (kill-all-local-variables) 361 (set (make-local-variable 'indent-line-function) 'pascal-indent-line)
362 (use-local-map pascal-mode-map) 362 (set (make-local-variable 'comment-indent-function) 'pascal-indent-comment)
363 (setq major-mode 'pascal-mode) 363 (set (make-local-variable 'parse-sexp-ignore-comments) nil)
364 (setq mode-name "Pascal") 364 (set (make-local-variable 'blink-matching-paren-dont-ignore-comments) t)
365 (setq local-abbrev-table pascal-mode-abbrev-table) 365 (set (make-local-variable 'case-fold-search) t)
366 (set-syntax-table pascal-mode-syntax-table) 366 (set (make-local-variable 'comment-start) "{")
367 (make-local-variable 'indent-line-function) 367 (set (make-local-variable 'comment-start-skip) "(\\*+ *\\|{ *")
368 (setq indent-line-function 'pascal-indent-line) 368 (set (make-local-variable 'comment-end) "}")
369 (make-local-variable 'comment-indent-function)
370 (setq comment-indent-function 'pascal-indent-comment)
371 (make-local-variable 'parse-sexp-ignore-comments)
372 (setq parse-sexp-ignore-comments nil)
373 (make-local-variable 'blink-matching-paren-dont-ignore-comments)
374 (setq blink-matching-paren-dont-ignore-comments t)
375 (make-local-variable 'case-fold-search)
376 (setq case-fold-search t)
377 (make-local-variable 'comment-start)
378 (setq comment-start "{")
379 (make-local-variable 'comment-start-skip)
380 (setq comment-start-skip "(\\*+ *\\|{ *")
381 (make-local-variable 'comment-end)
382 (setq comment-end "}")
383 ;; Font lock support 369 ;; Font lock support
384 (make-local-variable 'font-lock-defaults) 370 (set (make-local-variable 'font-lock-defaults)
385 (setq font-lock-defaults '(pascal-font-lock-keywords nil t)) 371 '(pascal-font-lock-keywords nil t))
386 ;; Imenu support 372 ;; Imenu support
387 (make-local-variable 'imenu-generic-expression) 373 (set (make-local-variable 'imenu-generic-expression)
388 (setq imenu-generic-expression pascal-imenu-generic-expression) 374 pascal-imenu-generic-expression)
389 (setq imenu-case-fold-search t) 375 (set (make-local-variable 'imenu-case-fold-search) t)
390 (run-mode-hooks 'pascal-mode-hook)) 376 ;; Pascal-mode's own hide/show support.
377 (add-to-invisibility-spec '(pascal . t)))
391 378
392 379
393 380
@@ -1478,18 +1465,12 @@ Pascal Outline mode provides some additional commands.
1478 (unless pascal-outline-mode 1465 (unless pascal-outline-mode
1479 (pascal-show-all))) 1466 (pascal-show-all)))
1480 1467
1481(defun pascal-outline-change (b e pascal-flag) 1468(defun pascal-outline-change (b e hide)
1482 (save-excursion
1483 ;; This used to use selective display so the boundaries used by the
1484 ;; callers didn't have to be precise, since it just looked for \n or \^M
1485 ;; and switched them.
1486 (goto-char b) (setq b (line-end-position))
1487 (goto-char e) (setq e (line-end-position)))
1488 (when (> e b) 1469 (when (> e b)
1489 ;; We could try and optimize this in the case where the region is 1470 ;; We could try and optimize this in the case where the region is
1490 ;; already hidden. But I'm not sure it's worth the trouble. 1471 ;; already hidden. But I'm not sure it's worth the trouble.
1491 (remove-overlays b e 'invisible 'pascal) 1472 (remove-overlays b e 'invisible 'pascal)
1492 (when (eq pascal-flag ?\^M) 1473 (when hide
1493 (let ((ol (make-overlay b e nil t nil))) 1474 (let ((ol (make-overlay b e nil t nil)))
1494 (overlay-put ol 'invisible 'pascal) 1475 (overlay-put ol 'invisible 'pascal)
1495 (overlay-put ol 'evaporate t))))) 1476 (overlay-put ol 'evaporate t)))))
@@ -1497,7 +1478,7 @@ Pascal Outline mode provides some additional commands.
1497(defun pascal-show-all () 1478(defun pascal-show-all ()
1498 "Show all of the text in the buffer." 1479 "Show all of the text in the buffer."
1499 (interactive) 1480 (interactive)
1500 (pascal-outline-change (point-min) (point-max) ?\n)) 1481 (pascal-outline-change (point-min) (point-max) nil))
1501 1482
1502(defun pascal-hide-other-defuns () 1483(defun pascal-hide-other-defuns ()
1503 "Show only the current defun." 1484 "Show only the current defun."
@@ -1505,42 +1486,45 @@ Pascal Outline mode provides some additional commands.
1505 (save-excursion 1486 (save-excursion
1506 (let ((beg (progn (if (not (looking-at "\\(function\\|procedure\\)\\>")) 1487 (let ((beg (progn (if (not (looking-at "\\(function\\|procedure\\)\\>"))
1507 (pascal-beg-of-defun)) 1488 (pascal-beg-of-defun))
1508 (point))) 1489 (line-beginning-position)))
1509 (end (progn (pascal-end-of-defun) 1490 (end (progn (pascal-end-of-defun)
1510 (backward-sexp 1) 1491 (backward-sexp 1)
1511 (search-forward "\n\\|\^M" nil t) 1492 (line-beginning-position 2)))
1512 (point)))
1513 (opoint (point-min))) 1493 (opoint (point-min)))
1494 ;; BEG at BOL.
1495 ;; OPOINT at EOL.
1496 ;; END at BOL.
1514 (goto-char (point-min)) 1497 (goto-char (point-min))
1515 1498
1516 ;; Hide all functions before current function 1499 ;; Hide all functions before current function
1517 (while (re-search-forward "^\\(function\\|procedure\\)\\>" beg 'move) 1500 (while (re-search-forward "^[ \t]*\\(function\\|procedure\\)\\>"
1518 (pascal-outline-change opoint (1- (match-beginning 0)) ?\^M) 1501 beg 'move)
1519 (setq opoint (point)) 1502 (pascal-outline-change opoint (line-end-position 0) t)
1503 (setq opoint (line-end-position))
1520 ;; Functions may be nested 1504 ;; Functions may be nested
1521 (if (> (progn (pascal-end-of-defun) (point)) beg) 1505 (if (> (progn (pascal-end-of-defun) (point)) beg)
1522 (goto-char opoint))) 1506 (goto-char opoint)))
1523 (if (> beg opoint) 1507 (if (> beg opoint)
1524 (pascal-outline-change opoint (1- beg) ?\^M)) 1508 (pascal-outline-change opoint (1- beg) t))
1525 1509
1526 ;; Show current function 1510 ;; Show current function
1527 (pascal-outline-change beg end ?\n) 1511 (pascal-outline-change (1- beg) end nil)
1528 ;; Hide nested functions 1512 ;; Hide nested functions
1529 (forward-char 1) 1513 (forward-char 1)
1530 (while (re-search-forward "^\\(function\\|procedure\\)\\>" end 'move) 1514 (while (re-search-forward "^\\(function\\|procedure\\)\\>" end 'move)
1531 (setq opoint (point)) 1515 (setq opoint (line-end-position))
1532 (pascal-end-of-defun) 1516 (pascal-end-of-defun)
1533 (pascal-outline-change opoint (point) ?\^M)) 1517 (pascal-outline-change opoint (line-end-position) t))
1534 1518
1535 (goto-char end) 1519 (goto-char end)
1536 (setq opoint end) 1520 (setq opoint end)
1537 1521
1538 ;; Hide all function after current function 1522 ;; Hide all function after current function
1539 (while (re-search-forward "^\\(function\\|procedure\\)\\>" nil 'move) 1523 (while (re-search-forward "^\\(function\\|procedure\\)\\>" nil 'move)
1540 (pascal-outline-change opoint (1- (match-beginning 0)) ?\^M) 1524 (pascal-outline-change opoint (line-end-position 0) t)
1541 (setq opoint (point)) 1525 (setq opoint (line-end-position))
1542 (pascal-end-of-defun)) 1526 (pascal-end-of-defun))
1543 (pascal-outline-change opoint (point-max) ?\^M) 1527 (pascal-outline-change opoint (point-max) t)
1544 1528
1545 ;; Hide main program 1529 ;; Hide main program
1546 (if (< (progn (forward-line -1) (point)) end) 1530 (if (< (progn (forward-line -1) (point)) end)
@@ -1548,7 +1532,7 @@ Pascal Outline mode provides some additional commands.
1548 (goto-char beg) 1532 (goto-char beg)
1549 (pascal-end-of-defun) 1533 (pascal-end-of-defun)
1550 (backward-sexp 1) 1534 (backward-sexp 1)
1551 (pascal-outline-change (point) (point-max) ?\^M)))))) 1535 (pascal-outline-change (line-end-position) (point-max) t))))))
1552 1536
1553(defun pascal-outline-next-defun () 1537(defun pascal-outline-next-defun ()
1554 "Move to next function/procedure, hiding all others." 1538 "Move to next function/procedure, hiding all others."