"Abbrev table in use in Pascal-mode buffers.")
(define-abbrev-table 'pascal-mode-abbrev-table ())
-(defvar pascal-mode-map ()
+(defvar pascal-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map ";" 'electric-pascal-semi-or-dot)
+ (define-key map "." 'electric-pascal-semi-or-dot)
+ (define-key map ":" 'electric-pascal-colon)
+ (define-key map "=" 'electric-pascal-equal)
+ (define-key map "#" 'electric-pascal-hash)
+ (define-key map "\r" 'electric-pascal-terminate-line)
+ (define-key map "\t" 'electric-pascal-tab)
+ (define-key map "\M-\t" 'pascal-complete-word)
+ (define-key map "\M-?" 'pascal-show-completions)
+ (define-key map "\177" 'backward-delete-char-untabify)
+ (define-key map "\M-\C-h" 'pascal-mark-defun)
+ (define-key map "\C-c\C-b" 'pascal-insert-block)
+ (define-key map "\M-*" 'pascal-star-comment)
+ (define-key map "\C-c\C-c" 'pascal-comment-area)
+ (define-key map "\C-c\C-u" 'pascal-uncomment-area)
+ (define-key map "\M-\C-a" 'pascal-beg-of-defun)
+ (define-key map "\M-\C-e" 'pascal-end-of-defun)
+ (define-key map "\C-c\C-d" 'pascal-goto-defun)
+ (define-key map "\C-c\C-o" 'pascal-outline-mode)
+ ;; A command to change the whole buffer won't be used terribly
+ ;; often, so no need for a key binding.
+ ;; (define-key map "\C-cd" 'pascal-downcase-keywords)
+ ;; (define-key map "\C-cu" 'pascal-upcase-keywords)
+ ;; (define-key map "\C-cc" 'pascal-capitalize-keywords)
+ map)
"Keymap used in Pascal mode.")
-(if pascal-mode-map
- ()
- (setq pascal-mode-map (make-sparse-keymap))
- (define-key pascal-mode-map ";" 'electric-pascal-semi-or-dot)
- (define-key pascal-mode-map "." 'electric-pascal-semi-or-dot)
- (define-key pascal-mode-map ":" 'electric-pascal-colon)
- (define-key pascal-mode-map "=" 'electric-pascal-equal)
- (define-key pascal-mode-map "#" 'electric-pascal-hash)
- (define-key pascal-mode-map "\r" 'electric-pascal-terminate-line)
- (define-key pascal-mode-map "\t" 'electric-pascal-tab)
- (define-key pascal-mode-map "\M-\t" 'pascal-complete-word)
- (define-key pascal-mode-map "\M-?" 'pascal-show-completions)
- (define-key pascal-mode-map "\177" 'backward-delete-char-untabify)
- (define-key pascal-mode-map "\M-\C-h" 'pascal-mark-defun)
- (define-key pascal-mode-map "\C-c\C-b" 'pascal-insert-block)
- (define-key pascal-mode-map "\M-*" 'pascal-star-comment)
- (define-key pascal-mode-map "\C-c\C-c" 'pascal-comment-area)
- (define-key pascal-mode-map "\C-c\C-u" 'pascal-uncomment-area)
- (define-key pascal-mode-map "\M-\C-a" 'pascal-beg-of-defun)
- (define-key pascal-mode-map "\M-\C-e" 'pascal-end-of-defun)
- (define-key pascal-mode-map "\C-c\C-d" 'pascal-goto-defun)
- (define-key pascal-mode-map "\C-c\C-o" 'pascal-outline)
-;;; A command to change the whole buffer won't be used terribly
-;;; often, so no need for a key binding.
-; (define-key pascal-mode-map "\C-cd" 'pascal-downcase-keywords)
-; (define-key pascal-mode-map "\C-cu" 'pascal-upcase-keywords)
-; (define-key pascal-mode-map "\C-cc" 'pascal-capitalize-keywords)
- )
(defvar pascal-imenu-generic-expression
'((nil "^[ \t]*\\(function\\|procedure\\)[ \t\n]+\\([a-zA-Z0-9_.:]+\\)" 2))
(defconst pascal-exclude-str-start "{-----\\/----- EXCLUDED -----\\/-----")
(defconst pascal-exclude-str-end " -----/\\----- EXCLUDED -----/\\-----}")
-(defvar pascal-mode-syntax-table nil
+(defvar pascal-mode-syntax-table
+ (let ((st (make-syntax-table)))
+ (modify-syntax-entry ?\\ "." st)
+ (modify-syntax-entry ?\( "()1" st)
+ (modify-syntax-entry ?\) ")(4" st)
+ ;; This used to use comment-syntax `b'. But the only document I could
+ ;; find about the syntax of Pascal's comments said that (* ... } is
+ ;; a valid comment, just as { ... *) or (* ... *) or { ... }.
+ (modify-syntax-entry ?* ". 23" st)
+ (modify-syntax-entry ?{ "<" st)
+ (modify-syntax-entry ?} ">" st)
+ (modify-syntax-entry ?+ "." st)
+ (modify-syntax-entry ?- "." st)
+ (modify-syntax-entry ?= "." st)
+ (modify-syntax-entry ?% "." st)
+ (modify-syntax-entry ?< "." st)
+ (modify-syntax-entry ?> "." st)
+ (modify-syntax-entry ?& "." st)
+ (modify-syntax-entry ?| "." st)
+ (modify-syntax-entry ?_ "_" st)
+ (modify-syntax-entry ?\' "\"" st)
+ st)
"Syntax table in use in Pascal-mode buffers.")
-(if pascal-mode-syntax-table
- ()
- (setq pascal-mode-syntax-table (make-syntax-table))
- (modify-syntax-entry ?\\ "." pascal-mode-syntax-table)
- (modify-syntax-entry ?( "()1" pascal-mode-syntax-table)
- (modify-syntax-entry ?) ")(4" pascal-mode-syntax-table)
- (modify-syntax-entry ?* ". 23b" pascal-mode-syntax-table)
- (modify-syntax-entry ?{ "<" pascal-mode-syntax-table)
- (modify-syntax-entry ?} ">" pascal-mode-syntax-table)
- (modify-syntax-entry ?+ "." pascal-mode-syntax-table)
- (modify-syntax-entry ?- "." pascal-mode-syntax-table)
- (modify-syntax-entry ?= "." pascal-mode-syntax-table)
- (modify-syntax-entry ?% "." pascal-mode-syntax-table)
- (modify-syntax-entry ?< "." pascal-mode-syntax-table)
- (modify-syntax-entry ?> "." pascal-mode-syntax-table)
- (modify-syntax-entry ?& "." pascal-mode-syntax-table)
- (modify-syntax-entry ?| "." pascal-mode-syntax-table)
- (modify-syntax-entry ?_ "_" pascal-mode-syntax-table)
- (modify-syntax-entry ?\' "\"" pascal-mode-syntax-table))
+
(defconst pascal-font-lock-keywords (purecopy
(list
\\[pascal-beg-of-defun]\t- Move to beginning of current function.
\\[pascal-end-of-defun]\t- Move to end of current function.
\\[pascal-goto-defun]\t- Goto function prompted for in the minibuffer.
-\\[pascal-outline]\t- Enter pascal-outline-mode (see also pascal-outline).
+\\[pascal-outline-mode]\t- Enter `pascal-outline-mode'.
Variables controlling indentation/edit style:
(defun pascal-indent-command ()
"Indent for special part of code."
(let* ((indent-str (pascal-calculate-indent))
- (type (car indent-str))
- (ind (car (cdr indent-str))))
+ (type (car indent-str)))
(cond ((and (eq type 'paramlist)
(or (memq 'all pascal-auto-lineup)
(memq 'paramlist pascal-auto-lineup)))
(end-of-line)
(point-marker)
(re-search-backward "\\<case\\>" nil t)))
- (beg (point)) oldpos
+ (beg (point))
(ind 0))
;; Get right indent
(while (< (point) end)
(setq ind (current-column)))
(pascal-end-of-statement))))
(goto-char beg)
- (setq oldpos (marker-position end))
;; Indent all case statements
(while (< (point) end)
(if (re-search-forward
(forward-char 1)
(delete-horizontal-space)
(insert " "))
- (setq oldpos (point))
(pascal-end-of-statement))
(goto-char savepos)))
;;;
;;; Pascal-outline-mode
;;;
-(defvar pascal-outline-map nil "Keymap used in Pascal Outline mode.")
-
-(if pascal-outline-map
- nil
- (if (fboundp 'set-keymap-name)
- (set-keymap-name pascal-outline-map 'pascal-outline-map))
- (if (fboundp 'set-keymap-parent)
- (set-keymap-parent (setq pascal-outline-map (make-sparse-keymap))
- pascal-mode-map)
- (setq pascal-outline-map (copy-keymap pascal-mode-map)))
- (define-key pascal-outline-map "\M-\C-a" 'pascal-outline-prev-defun)
- (define-key pascal-outline-map "\M-\C-e" 'pascal-outline-next-defun)
- (define-key pascal-outline-map "\C-c\C-d" 'pascal-outline-goto-defun)
- (define-key pascal-outline-map "\C-c\C-s" 'pascal-show-all)
- (define-key pascal-outline-map "\C-c\C-h" 'pascal-hide-other-defuns))
-
-(defvar pascal-outline-mode nil "Non-nil while using Pascal Outline mode.")
-(make-variable-buffer-local 'pascal-outline-mode)
-(set-default 'pascal-outline-mode nil)
-(if (not (assoc 'pascal-outline-mode minor-mode-alist))
- (setq minor-mode-alist (append minor-mode-alist
- (list '(pascal-outline-mode " Outl")))))
-
-(defun pascal-outline (&optional arg)
+(defvar pascal-outline-map
+ (let ((map (make-sparse-keymap)))
+ (if (fboundp 'set-keymap-name)
+ (set-keymap-name pascal-outline-map 'pascal-outline-map))
+ (define-key map "\M-\C-a" 'pascal-outline-prev-defun)
+ (define-key map "\M-\C-e" 'pascal-outline-next-defun)
+ (define-key map "\C-c\C-d" 'pascal-outline-goto-defun)
+ (define-key map "\C-c\C-s" 'pascal-show-all)
+ (define-key map "\C-c\C-h" 'pascal-hide-other-defuns)
+ map)
+ "Keymap used in Pascal Outline mode.")
+
+(define-obsolete-function-alias 'pascal-outline 'pascal-outline-mode)
+(define-minor-mode pascal-outline-mode
"Outline-line minor mode for Pascal mode.
When in Pascal Outline mode, portions
of the text being edited may be made invisible. \\<pascal-outline-map>
\\[pascal-hide-other-defuns]\
\t- Hide everything but the current function (function under the cursor).
\\[pascal-outline]\t- Leave pascal-outline-mode."
- (interactive "P")
- (setq pascal-outline-mode
- (if (null arg) (not pascal-outline-mode) t))
- (if (fboundp 'redraw-mode-line)
- (redraw-mode-line))
- (if pascal-outline-mode
- (progn
- (setq selective-display t)
- (use-local-map pascal-outline-map))
- (progn
- (setq selective-display nil)
- (pascal-show-all)
- (use-local-map pascal-mode-map))))
+ :init-value nil :lighter " Outl" :keymap pascal-outline-map
+ (add-to-invisibility-spec '(pascal . t))
+ (unless pascal-outline-mode
+ (pascal-show-all)))
(defun pascal-outline-change (b e pascal-flag)
- (let ((modp (buffer-modified-p)))
- (unwind-protect
- (subst-char-in-region b e (if (= pascal-flag ?\n)
- ?\^M ?\n) pascal-flag)
- (set-buffer-modified-p modp))))
+ (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)
+ ;; 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.
+ (remove-overlays b e 'invisible 'pascal)
+ (when (eq pascal-flag ?\^M)
+ (let ((ol (make-overlay b e nil t nil)))
+ (overlay-put ol 'invisible 'pascal)
+ (overlay-put ol 'evaporate t)))))
(defun pascal-show-all ()
"Show all of the text in the buffer."
(provide 'pascal)
-;;; arch-tag: 04535136-fd93-40b4-a505-c9bebdc051f5
+;; arch-tag: 04535136-fd93-40b4-a505-c9bebdc051f5
;;; pascal.el ends here