Commit 3672149f authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* 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.
parent 549d0e1e
2010-09-20 Stefan Monnier <monnier@iro.umontreal.ca> 2010-09-20 Stefan Monnier <monnier@iro.umontreal.ca>
   
* 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.
* progmodes/prolog.el (prolog-smie-forward-token) * progmodes/prolog.el (prolog-smie-forward-token)
(prolog-smie-backward-token): New functions. (prolog-smie-backward-token): New functions.
(prolog-mode-variables): Use them to parse "!," correctly. (prolog-mode-variables): Use them to parse "!," correctly.
......
...@@ -223,7 +223,7 @@ The name of the function or case is included between the braces." ...@@ -223,7 +223,7 @@ The name of the function or case is included between the braces."
"*List of contexts where auto lineup of :'s or ='s should be done. "*List of contexts where auto lineup of :'s or ='s should be done.
Elements can be of type: 'paramlist', 'declaration' or 'case', which will Elements can be of type: 'paramlist', 'declaration' or 'case', which will
do auto lineup in parameterlist, declarations or case-statements do auto lineup in parameterlist, declarations or case-statements
respectively. The word 'all' will do all lineups. '(case paramlist) for respectively. The word 'all' will do all lineups. '(case paramlist) for
instance will do lineup in case-statements and parameterlist, while '(all) instance will do lineup in case-statements and parameterlist, while '(all)
will do all lineups." will do all lineups."
:type '(set :extra-offset 8 :type '(set :extra-offset 8
...@@ -311,7 +311,7 @@ are handled in another way, and should not be added to this list." ...@@ -311,7 +311,7 @@ are handled in another way, and should not be added to this list."
;;;###autoload ;;;###autoload
(defun pascal-mode () (define-derived-mode pascal-mode prog-mode "Pascal"
"Major mode for editing Pascal code. \\<pascal-mode-map> "Major mode for editing Pascal code. \\<pascal-mode-map>
TAB indents for Pascal code. Delete converts tabs to spaces as it moves back. TAB indents for Pascal code. Delete converts tabs to spaces as it moves back.
...@@ -334,60 +334,47 @@ Other useful functions are: ...@@ -334,60 +334,47 @@ Other useful functions are:
Variables controlling indentation/edit style: Variables controlling indentation/edit style:
pascal-indent-level (default 3) `pascal-indent-level' (default 3)
Indentation of Pascal statements with respect to containing block. Indentation of Pascal statements with respect to containing block.
pascal-case-indent (default 2) `pascal-case-indent' (default 2)
Indentation for case statements. Indentation for case statements.
pascal-auto-newline (default nil) `pascal-auto-newline' (default nil)
Non-nil means automatically newline after semicolons and the punctuation Non-nil means automatically newline after semicolons and the punctuation
mark after an end. mark after an end.
pascal-indent-nested-functions (default t) `pascal-indent-nested-functions' (default t)
Non-nil means nested functions are indented. Non-nil means nested functions are indented.
pascal-tab-always-indent (default t) `pascal-tab-always-indent' (default t)
Non-nil means TAB in Pascal mode should always reindent the current line, Non-nil means TAB in Pascal mode should always reindent the current line,
regardless of where in the line point is when the TAB command is used. regardless of where in the line point is when the TAB command is used.
pascal-auto-endcomments (default t) `pascal-auto-endcomments' (default t)
Non-nil means a comment { ... } is set after the ends which ends cases and Non-nil means a comment { ... } is set after the ends which ends cases and
functions. The name of the function or case will be set between the braces. functions. The name of the function or case will be set between the braces.
pascal-auto-lineup (default t) `pascal-auto-lineup' (default t)
List of contexts where auto lineup of :'s or ='s should be done. List of contexts where auto lineup of :'s or ='s should be done.
See also the user variables pascal-type-keywords, pascal-start-keywords and See also the user variables `pascal-type-keywords', `pascal-start-keywords' and
pascal-separator-keywords. `pascal-separator-keywords'.
Turning on Pascal mode calls the value of the variable pascal-mode-hook with Turning on Pascal mode calls the value of the variable pascal-mode-hook with
no args, if that value is non-nil." no args, if that value is non-nil."
(interactive) (set (make-local-variable 'local-abbrev-table) pascal-mode-abbrev-table)
(kill-all-local-variables) (set (make-local-variable 'indent-line-function) 'pascal-indent-line)
(use-local-map pascal-mode-map) (set (make-local-variable 'comment-indent-function) 'pascal-indent-comment)
(setq major-mode 'pascal-mode) (set (make-local-variable 'parse-sexp-ignore-comments) nil)
(setq mode-name "Pascal") (set (make-local-variable 'blink-matching-paren-dont-ignore-comments) t)
(setq local-abbrev-table pascal-mode-abbrev-table) (set (make-local-variable 'case-fold-search) t)
(set-syntax-table pascal-mode-syntax-table) (set (make-local-variable 'comment-start) "{")
(make-local-variable 'indent-line-function) (set (make-local-variable 'comment-start-skip) "(\\*+ *\\|{ *")
(setq indent-line-function 'pascal-indent-line) (set (make-local-variable 'comment-end) "}")
(make-local-variable 'comment-indent-function)
(setq comment-indent-function 'pascal-indent-comment)
(make-local-variable 'parse-sexp-ignore-comments)
(setq parse-sexp-ignore-comments nil)
(make-local-variable 'blink-matching-paren-dont-ignore-comments)
(setq blink-matching-paren-dont-ignore-comments t)
(make-local-variable 'case-fold-search)
(setq case-fold-search t)
(make-local-variable 'comment-start)
(setq comment-start "{")
(make-local-variable 'comment-start-skip)
(setq comment-start-skip "(\\*+ *\\|{ *")
(make-local-variable 'comment-end)
(setq comment-end "}")
;; Font lock support ;; Font lock support
(make-local-variable 'font-lock-defaults) (set (make-local-variable 'font-lock-defaults)
(setq font-lock-defaults '(pascal-font-lock-keywords nil t)) '(pascal-font-lock-keywords nil t))
;; Imenu support ;; Imenu support
(make-local-variable 'imenu-generic-expression) (set (make-local-variable 'imenu-generic-expression)
(setq imenu-generic-expression pascal-imenu-generic-expression) pascal-imenu-generic-expression)
(setq imenu-case-fold-search t) (set (make-local-variable 'imenu-case-fold-search) t)
(run-mode-hooks 'pascal-mode-hook)) ;; Pascal-mode's own hide/show support.
(add-to-invisibility-spec '(pascal . t)))
...@@ -1478,18 +1465,12 @@ Pascal Outline mode provides some additional commands. ...@@ -1478,18 +1465,12 @@ Pascal Outline mode provides some additional commands.
(unless pascal-outline-mode (unless pascal-outline-mode
(pascal-show-all))) (pascal-show-all)))
(defun pascal-outline-change (b e pascal-flag) (defun pascal-outline-change (b e hide)
(save-excursion
;; This used to use selective display so the boundaries used by the
;; callers didn't have to be precise, since it just looked for \n or \^M
;; and switched them.
(goto-char b) (setq b (line-end-position))
(goto-char e) (setq e (line-end-position)))
(when (> e b) (when (> e b)
;; We could try and optimize this in the case where the region is ;; We could try and optimize this in the case where the region is
;; already hidden. But I'm not sure it's worth the trouble. ;; already hidden. But I'm not sure it's worth the trouble.
(remove-overlays b e 'invisible 'pascal) (remove-overlays b e 'invisible 'pascal)
(when (eq pascal-flag ?\^M) (when hide
(let ((ol (make-overlay b e nil t nil))) (let ((ol (make-overlay b e nil t nil)))
(overlay-put ol 'invisible 'pascal) (overlay-put ol 'invisible 'pascal)
(overlay-put ol 'evaporate t))))) (overlay-put ol 'evaporate t)))))
...@@ -1497,7 +1478,7 @@ Pascal Outline mode provides some additional commands. ...@@ -1497,7 +1478,7 @@ Pascal Outline mode provides some additional commands.
(defun pascal-show-all () (defun pascal-show-all ()
"Show all of the text in the buffer." "Show all of the text in the buffer."
(interactive) (interactive)
(pascal-outline-change (point-min) (point-max) ?\n)) (pascal-outline-change (point-min) (point-max) nil))
(defun pascal-hide-other-defuns () (defun pascal-hide-other-defuns ()
"Show only the current defun." "Show only the current defun."
...@@ -1505,42 +1486,45 @@ Pascal Outline mode provides some additional commands. ...@@ -1505,42 +1486,45 @@ Pascal Outline mode provides some additional commands.
(save-excursion (save-excursion
(let ((beg (progn (if (not (looking-at "\\(function\\|procedure\\)\\>")) (let ((beg (progn (if (not (looking-at "\\(function\\|procedure\\)\\>"))
(pascal-beg-of-defun)) (pascal-beg-of-defun))
(point))) (line-beginning-position)))
(end (progn (pascal-end-of-defun) (end (progn (pascal-end-of-defun)
(backward-sexp 1) (backward-sexp 1)
(search-forward "\n\\|\^M" nil t) (line-beginning-position 2)))
(point)))
(opoint (point-min))) (opoint (point-min)))
;; BEG at BOL.
;; OPOINT at EOL.
;; END at BOL.
(goto-char (point-min)) (goto-char (point-min))
;; Hide all functions before current function ;; Hide all functions before current function
(while (re-search-forward "^\\(function\\|procedure\\)\\>" beg 'move) (while (re-search-forward "^[ \t]*\\(function\\|procedure\\)\\>"
(pascal-outline-change opoint (1- (match-beginning 0)) ?\^M) beg 'move)
(setq opoint (point)) (pascal-outline-change opoint (line-end-position 0) t)
(setq opoint (line-end-position))
;; Functions may be nested ;; Functions may be nested
(if (> (progn (pascal-end-of-defun) (point)) beg) (if (> (progn (pascal-end-of-defun) (point)) beg)
(goto-char opoint))) (goto-char opoint)))
(if (> beg opoint) (if (> beg opoint)
(pascal-outline-change opoint (1- beg) ?\^M)) (pascal-outline-change opoint (1- beg) t))
;; Show current function ;; Show current function
(pascal-outline-change beg end ?\n) (pascal-outline-change (1- beg) end nil)
;; Hide nested functions ;; Hide nested functions
(forward-char 1) (forward-char 1)
(while (re-search-forward "^\\(function\\|procedure\\)\\>" end 'move) (while (re-search-forward "^\\(function\\|procedure\\)\\>" end 'move)
(setq opoint (point)) (setq opoint (line-end-position))
(pascal-end-of-defun) (pascal-end-of-defun)
(pascal-outline-change opoint (point) ?\^M)) (pascal-outline-change opoint (line-end-position) t))
(goto-char end) (goto-char end)
(setq opoint end) (setq opoint end)
;; Hide all function after current function ;; Hide all function after current function
(while (re-search-forward "^\\(function\\|procedure\\)\\>" nil 'move) (while (re-search-forward "^\\(function\\|procedure\\)\\>" nil 'move)
(pascal-outline-change opoint (1- (match-beginning 0)) ?\^M) (pascal-outline-change opoint (line-end-position 0) t)
(setq opoint (point)) (setq opoint (line-end-position))
(pascal-end-of-defun)) (pascal-end-of-defun))
(pascal-outline-change opoint (point-max) ?\^M) (pascal-outline-change opoint (point-max) t)
;; Hide main program ;; Hide main program
(if (< (progn (forward-line -1) (point)) end) (if (< (progn (forward-line -1) (point)) end)
...@@ -1548,7 +1532,7 @@ Pascal Outline mode provides some additional commands. ...@@ -1548,7 +1532,7 @@ Pascal Outline mode provides some additional commands.
(goto-char beg) (goto-char beg)
(pascal-end-of-defun) (pascal-end-of-defun)
(backward-sexp 1) (backward-sexp 1)
(pascal-outline-change (point) (point-max) ?\^M)))))) (pascal-outline-change (line-end-position) (point-max) t))))))
(defun pascal-outline-next-defun () (defun pascal-outline-next-defun ()
"Move to next function/procedure, hiding all others." "Move to next function/procedure, hiding all others."
......
2010-09-20 Stefan Monnier <monnier@iro.umontreal.ca>
* indent/prolog.prolog: Use normal spacing around !.
2010-09-18 Stefan Monnier <monnier@iro.umontreal.ca> 2010-09-18 Stefan Monnier <monnier@iro.umontreal.ca>
* indent/octave.m: Remove one more `fixindent'. Use `end'. * indent/octave.m: Remove one more `fixindent'. Use `end'.
...@@ -22,7 +26,8 @@ ...@@ -22,7 +26,8 @@
(icalendar-testsuite--do-test-export): Code formatting. (icalendar-testsuite--do-test-export): Code formatting.
(icalendar-testsuite--test-parse-vtimezone): Doc fix. (icalendar-testsuite--test-parse-vtimezone): Doc fix.
(icalendar-testsuite--do-test-import) (icalendar-testsuite--do-test-import)
(icalendar-testsuite--do-test-cycle): Use icalendar-testsuite--compare-strings (icalendar-testsuite--do-test-cycle):
Use icalendar-testsuite--compare-strings
(icalendar-testsuite--run-import-tests): Comment added. (icalendar-testsuite--run-import-tests): Comment added.
(icalendar-testsuite--run-import-tests) (icalendar-testsuite--run-import-tests)
(icalendar-testsuite--run-real-world-tests): Fix expected results. (icalendar-testsuite--run-real-world-tests): Fix expected results.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment