diff options
| author | Stefan Monnier <monnier@iro.umontreal.ca> | 2022-12-29 18:47:38 -0500 |
|---|---|---|
| committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2022-12-29 18:47:38 -0500 |
| commit | 697fcf7d80513257d90b7331297495bb9e01003d (patch) | |
| tree | bcb8167673acfcfaa1deb816656a47f8ddaf8761 | |
| parent | d92ab0476c2eacfddaa48bcfa293ae99d5a95756 (diff) | |
Fix up compilation warningsexternals/psgml
Use overlays for folding.
Remove XEmacs-related code.
| -rw-r--r-- | psgml-debug.el | 8 | ||||
| -rw-r--r-- | psgml-dtd.el | 6 | ||||
| -rw-r--r-- | psgml-edit.el | 42 | ||||
| -rw-r--r-- | psgml-fs.el | 16 | ||||
| -rw-r--r-- | psgml-info.el | 4 | ||||
| -rw-r--r-- | psgml-lucid.el | 240 | ||||
| -rw-r--r-- | psgml-maint.el | 93 | ||||
| -rw-r--r-- | psgml-other.el | 6 | ||||
| -rw-r--r-- | psgml-parse.el | 27 | ||||
| -rw-r--r-- | psgml-vars.el | 98 | ||||
| -rw-r--r-- | psgml-xpr.el | 4 | ||||
| -rw-r--r-- | psgml.el | 149 | ||||
| -rw-r--r-- | sgmldecl/fum.el | 8 | ||||
| -rw-r--r-- | testcase/testsuit.el | 6 |
14 files changed, 162 insertions, 545 deletions
diff --git a/psgml-debug.el b/psgml-debug.el index f47eb2c..fa4c05d 100644 --- a/psgml-debug.el +++ b/psgml-debug.el @@ -1,6 +1,6 @@ ;;; psgml-debug.el --- ??? -*- lexical-binding:t -*- -;; Copyright (C) 2016-2017 Free Software Foundation, Inc. +;; Copyright (C) 2016-2022 Free Software Foundation, Inc. ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License @@ -32,9 +32,9 @@ ;;;; Debugging -(define-key sgml-mode-map "\C-c," 'sgml-goto-cache) -(define-key sgml-mode-map "\C-c\C-x" 'sgml-dump-tree) -(define-key sgml-mode-map "\C-c." 'sgml-shortref-identify) +(define-key sgml-mode-map "\C-c," #'sgml-goto-cache) +(define-key sgml-mode-map "\C-c\C-x" #'sgml-dump-tree) +(define-key sgml-mode-map "\C-c." #'sgml-shortref-identify) (defun sgml-this-element () (interactive) diff --git a/psgml-dtd.el b/psgml-dtd.el index ab1f6df..376ea91 100644 --- a/psgml-dtd.el +++ b/psgml-dtd.el @@ -1,6 +1,6 @@ ;;; psgml-dtd.el --- DTD parser for SGML-editing mode with parsing support -*- lexical-binding:t -*- -;; Copyright (C) 1994, 2016 Free Software Foundation, Inc. +;; Copyright (C) 1994-2022 Free Software Foundation, Inc. ;; Author: Lennart Staflin <lenst@lysator.liu.se> @@ -611,7 +611,7 @@ Case transformed for general names." (sgml-skip-ps) (let ((tn (sgml-parse-entity-type))) (setq type (or (car tn) 'text)) - (unless (eq (cdr tn) "") + (unless (equal (cdr tn) "") (setq notation (cdr tn)))) extid) ((sgml-startnm-char-next) @@ -997,7 +997,7 @@ FORMS should produce the binary coding of element in VAR." (defun sgml-write-dtd (dtd file) "Save the parsed DTD in FILE. Construct the binary coded DTD (bdtd) in the current buffer." - (sgml-set-buffer-multibyte nil) + (set-buffer-multibyte nil) (insert ";;; This file was created by psgml on " (current-time-string) " -*-coding:binary-*-\n" diff --git a/psgml-edit.el b/psgml-edit.el index 71d660f..fbadcce 100644 --- a/psgml-edit.el +++ b/psgml-edit.el @@ -1,6 +1,6 @@ ;;; psgml-edit.el --- Editing commands for SGML-mode with parsing support -*- lexical-binding:t -*- -;; Copyright (C) 1994-1996, 2016-2017 Free Software Foundation, Inc. +;; Copyright (C) 1994-2022 Free Software Foundation, Inc. ;; Author: Lennart Staflin <lenst@lysator.liu.se> @@ -252,23 +252,26 @@ a list using attlist TO." ;;;; SGML mode: folding -;; FIXME: Replace use of `selective-display' with overlays! - (defun sgml-fold-region (beg end &optional unhide) "Hide (or if prefixarg unhide) region. If called from a program first two arguments are start and end of region. And optional third argument true unhides." (interactive "r\nP") - (setq selective-display t) - (with-silent-modifications - (subst-char-in-region beg end - (if unhide ?\r ?\n) - (if unhide ?\n ?\r) - 'noundo))) + (remove-overlays beg end 'invisible 'psgml-fold) + (unless unhide + ;; We use `front-advance' here because the invisible text begins at the + ;; very end of the heading, before the newline, so text inserted at FROM + ;; belongs to the heading rather than to the entry. + (let ((o (make-overlay beg end nil 'front-advance))) + (overlay-put o 'evaporate t) + (overlay-put o 'invisible 'psgml-fold) + ;; (overlay-put o 'isearch-open-invisible + ;; (or outline-isearch-open-invisible-function + ;; #'outline-isearch-open-invisible)) + ))) (defun sgml-fold-element () - "Fold the lines comprising the current element, leaving the first line visible. -This uses the selective display feature." + "Fold the lines comprising the current element, leaving the first line visible." (interactive) (sgml-parse-to-here) (cond ((and (eq sgml-current-tree sgml-top-tree) ; outside document element @@ -297,8 +300,7 @@ This uses the selective display feature." (point))))))) (defun sgml-fold-subelement () - "Fold all elements current elements content, leaving the first lines visible. -This uses the selective display feature." + "Fold all elements current elements content, leaving the first lines visible." (interactive) (let* ((el (sgml-find-element-of (point))) (c (sgml-element-content el))) @@ -1527,12 +1529,12 @@ Editing is done in a separate window." (defvar sgml-edit-attrib-mode-map (let ((map (make-sparse-keymap))) - (define-key map "\C-c\C-c" 'sgml-edit-attrib-finish) - (define-key map "\C-c\C-d" 'sgml-edit-attrib-default) - (define-key map "\C-c\C-k" 'sgml-edit-attrib-abort) - (define-key map "\C-a" 'sgml-edit-attrib-field-start) - (define-key map "\C-e" 'sgml-edit-attrib-field-end) - (define-key map "\t" 'sgml-edit-attrib-next) + (define-key map "\C-c\C-c" #'sgml-edit-attrib-finish) + (define-key map "\C-c\C-d" #'sgml-edit-attrib-default) + (define-key map "\C-c\C-k" #'sgml-edit-attrib-abort) + (define-key map "\C-a" #'sgml-edit-attrib-field-start) + (define-key map "\C-e" #'sgml-edit-attrib-field-end) + (define-key map "\t" #'sgml-edit-attrib-next) map)) ;; used as only for #DEFAULT in attribute editing. Binds all normally inserting @@ -1540,7 +1542,7 @@ Editing is done in a separate window." (defvar sgml-attr-default-keymap (let ((map (make-sparse-keymap))) (set-keymap-parent map sgml-edit-attrib-mode-map) - (define-key map [remap self-insert-command] 'sgml-attr-clean-and-insert) + (define-key map [remap self-insert-command] #'sgml-attr-clean-and-insert) map)) (put 'sgml-default 'local-map sgml-attr-default-keymap) diff --git a/psgml-fs.el b/psgml-fs.el index 318294e..fa51def 100644 --- a/psgml-fs.el +++ b/psgml-fs.el @@ -1,6 +1,6 @@ ;;; psgml-fs.el --- Format a SGML-file according to a style file -*- lexical-binding:t -*- -;; Copyright (C) 1995, 2000, 2016 Free Software Foundation, Inc. +;; Copyright (C) 1995-2022 Free Software Foundation, Inc. ;; Author: Lennart Staflin <lenst@lysator.liu.se> ;; Keywords: @@ -211,7 +211,7 @@ The value can be the style-sheet list, or it can be a file name (defun fs-do-style (e style) (let ((fs-current-element e)) - (let ((hang-from (eval (plist-get style 'hang-from)))) + (let ((hang-from (eval (plist-get style 'hang-from) t))) (when hang-from (setq fs-hang-from (format "%s%s " @@ -220,10 +220,10 @@ The value can be the style-sheet list, or it can be a file name ? ) hang-from)))) (let ((fs-char (nconc - (cl-loop for st on style by 'cddr - unless (memq (car st) fs-special-styles) - collect (cons (car st) - (eval (cadr st)))) + (cl-loop for st on style by #'cddr + unless (memq (car st) fs-special-styles) + collect (cons (car st) + (eval (cadr st) t))) fs-char))) (when (plist-get style 'block) (fs-para) @@ -236,7 +236,7 @@ The value can be the style-sheet list, or it can be a file name (append (plist-get style 'sub-style) fs-style))) (cond ((plist-get style 'text) - (let ((text (eval (plist-get style 'text)))) + (let ((text (eval (plist-get style 'text) t))) (when (stringp text) (fs-paraform-data text)))) (t @@ -247,7 +247,7 @@ The value can be the style-sheet list, or it can be a file name (function fs-paraform-entity))))) (let ((title (plist-get style 'title))) (when title - (setq title (eval title)) + (setq title (eval title t)) (with-current-buffer fs-buffer (setq fs-title title)))) (let ((after (plist-get style 'after))) diff --git a/psgml-info.el b/psgml-info.el index 7f1268d..916e93e 100644 --- a/psgml-info.el +++ b/psgml-info.el @@ -1,6 +1,6 @@ ;;; psgml-info.el --- ??? -*- lexical-binding:t -*- -;; Copyright (C) 1994, 1995, 2016 Free Software Foundation, Inc. +;; Copyright (C) 1994-2022 Free Software Foundation, Inc. ;; Author: Lennart Staflin <lenst@lysator.liu.se> @@ -529,7 +529,7 @@ (print-help-return-message)))) -(defalias 'sgml-general-dtd-info 'sgml-describe-dtd) +(defalias 'sgml-general-dtd-info #'sgml-describe-dtd) (provide 'psgml-info) diff --git a/psgml-lucid.el b/psgml-lucid.el deleted file mode 100644 index 392c328..0000000 --- a/psgml-lucid.el +++ /dev/null @@ -1,240 +0,0 @@ -;;; psgml-lucid.el --- Part of SGML-editing mode with parsing support - -;; Copyright (C) 1994, 2016 Free Software Foundation, Inc. - -;; Author: Lennart Staflin <lenst@lysator.liu.se> -;; William M. Perry <wmperry@indiana.edu> - -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License -;; as published by the Free Software Foundation; either version 3 -;; of the License, or (at your option) any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see <https://www.gnu.org/licenses/>. - - -;;; Commentary: - -;; Part of psgml.el - -;; Menus for use with Lucid Emacs - - -;;; Code: - -(require 'psgml) -;;(require 'easymenu) - -(eval-and-compile - (autoload 'sgml-do-set-option "psgml-edit")) -(eval-when-compile (require 'cl)) - -(defvar sgml-max-menu-size (/ (* (frame-height) 2) 3) - "*Max number of entries in Tags and Entities menus before they are split -into several panes.") - -;;;; Pop Up Menus - -(defun sgml-popup-menu (_event title entries) - "Display a popup menu." - (setq entries - (loop for ent in entries collect - (vector (car ent) - (list 'setq 'value (list 'quote (cdr ent))) - t))) - (cond ((> (length entries) sgml-max-menu-size) - (setq entries - (loop for i from 1 while entries collect - (let ((submenu - (subseq entries 0 (min (length entries) - sgml-max-menu-size)))) - (setq entries (nthcdr sgml-max-menu-size - entries)) - (cons - (format "%s '%s'-'%s'" - title - (sgml-range-indicator (aref (car submenu) 0)) - (sgml-range-indicator - (aref (car (last submenu)) 0))) - submenu)))))) - (sgml-lucid-get-popup-value (cons title entries))) - - -(defun sgml-range-indicator (string) - (substring string - 0 - (min (length string) sgml-range-indicator-max-length))) - - -(defun sgml-lucid-get-popup-value (menudesc) - (let ((value nil) - (event nil)) - (popup-menu menudesc) - (while (popup-up-p) - (setq event (next-command-event event)) - (cond ((misc-user-event-p event) - (cond - ((eq (event-object event) 'abort) - (signal 'quit nil)) - ((eq (event-object event) 'menu-no-selection-hook) - nil) - (t - (eval (event-object event))))) - ((button-release-event-p event) ; don't beep twice - nil) - (t - (beep) - (message "please make a choice from the menu.")))) - value)) - -(defun sgml-popup-multi-menu (_pos title menudesc) - "Display a popup menu. -MENUS is a list of menus on the form (TITLE ITEM1 ITEM2 ...). -ITEM should have to form (STRING EXPR) or STRING. The EXPR gets evaluated -if the item is selected." - (popup-menu - (cons title - (loop for menu in menudesc collect - (cons (car menu) ; title - (loop for item in (cdr menu) collect - (if (stringp item) - item - (vector (car item) (cadr item) t)))))))) - - -;;;; Lucid menu bar - -(defun sgml-make-options-menu (vars) - (loop for var in vars - for type = (sgml-variable-type var) - for desc = (sgml-variable-description var) - collect - (cond - ((eq type 'toggle) - (vector desc (list 'setq var (list 'not var)) - ':style 'toggle ':selected var)) - ((consp type) - (cons desc - (loop for c in type collect - (if (atom c) - (vector (prin1-to-string c) - `(setq ,var (, c)) - :style 'toggle - :selected `(eq ,var ',c)) - (vector (car c) - `(setq ,var ',(cdr c)) - :style 'toggle - :selected `(eq ,var ',(cdr c))))))) - (t - (vector desc - `(sgml-do-set-option ',var) - t))))) - - -(unless (or (not (boundp 'emacs-major-version)) - (and (boundp 'emacs-minor-version) - (< emacs-minor-version 10))) - (loop for ent on sgml-main-menu - if (vectorp (car ent)) - do (cond - ((equal (aref (car ent) 0) "File Options >") - (setcar ent - (cons "File Options" - (sgml-make-options-menu sgml-file-options)))) - ((equal (aref (car ent) 0) "User Options >") - (setcar ent - (cons "User Options" - (sgml-make-options-menu sgml-user-options))))))) - - -;;;; Key definitions - - - -;;;; Insert with properties - -(defun sgml-insert (props format &rest args) - (let ((start (point)) - tem) - (insert (apply (function format) - format - args)) - (remf props 'rear-nonsticky) ; not useful in Lucid - - ;; Copy face prop from category - (when (setq tem (getf props 'category)) - (when (setq tem (get tem 'face)) - (set-face-underline-p (make-face 'underline) t) - (setf (getf props 'face) tem))) - - (add-text-properties start (point) props) - - ;; A read-only value of 1 is used for the text after values - ;; and this should in Lucid be open at the front. - (if (eq 1 (getf props 'read-only)) - (set-extent-property - (extent-at start nil 'read-only) - 'start-open t)))) - - -;;;; Set face of markup - -(defun sgml-set-face-for (start end type) - (let ((face (cdr (assq type sgml-markup-faces))) - o) - (loop for e being the extents from start to end - do (when (extent-property e 'sgml-type) - (cond ((and (null o) - (eq type (extent-property e 'sgml-type))) - (setq o e)) - (t (delete-extent e))))) - - (cond (o - (set-extent-endpoints o start end)) - (face - (setq o (make-extent start end)) - (set-extent-property o 'sgml-type type) - (set-extent-property o 'face face) - (set-extent-property o 'start-open t) - (set-extent-face o face))))) - -(defun sgml-set-face-after-change (start end &optional pre-len) - ;; This should not be needed with start-open t - (when sgml-set-face - (let ((o (extent-at start nil 'sgml-type))) - (cond - ((null o)) - ((= start (extent-start-position o)) - (set-extent-endpoints o end (extent-end-position o))) - (t (delete-extent o)))))) - -;(defalias 'next-overlay-at 'next-overlay-change) ; fix bug in cl.el - -(defun sgml-clear-faces () - (interactive) - (loop for o being the overlays - if (extent-property o 'type) - do (delete-extent o))) - - -;;;; Functions not in Lucid Emacs - -(unless (fboundp 'frame-width) - (defalias 'frame-width 'screen-width)) - -(unless (fboundp 'buffer-substring-no-properties) - (defalias 'buffer-substring-no-properties 'buffer-substring)) - - -;;;; Provide - -(provide 'psgml-lucid) - - -;;; psgml-lucid.el ends here diff --git a/psgml-maint.el b/psgml-maint.el deleted file mode 100644 index ae11d01..0000000 --- a/psgml-maint.el +++ /dev/null @@ -1,93 +0,0 @@ -;;; psgml-maint.el --- Help functions to maintain PSGML source -*- lexical-binding:t -*- - -;; Copyright (C) 1996, 2017 Free Software Foundation, Inc. - -;; Author: Lennart Staflin <lenst@lysator.liu.se> -;; Version: $Id: psgml-maint.el,v 1.8 2005/02/09 15:28:58 lenst Exp $ -;; Keywords: - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see <https://www.gnu.org/licenses/>. -;; - - -;;; Commentary: - -;; This file contains commands used during installation and -;; compilation of psgml. - -;; psgml-compile-files Compiles the source files. The version of -;; Emacs used for compilation will determine -;; what files are compiled. - - -;;; Code: - -(require 'bytecomp) - -(defconst psgml-common-files - '("psgml.el" "psgml-parse.el" "psgml-edit.el" "psgml-dtd.el" - "psgml-info.el" "psgml-api.el")) - -(defconst psgml-emacs-files '("psgml-other.el")) -(defconst psgml-xemacs-files '("psgml-lucid.el")) -(defvar psgml-source-dir nil) - -(defconst psgml-elisp-source - (append psgml-common-files - (cond ((featurep 'xemacs) - psgml-xemacs-files) - (t - psgml-emacs-files)))) - - -(defun psgml-find-source-dir (&optional ask) - (if psgml-source-dir - t - (let ((cand (list "." "./psgml-1.3.2"))) - (while cand - (if (file-exists-p (expand-file-name "psgml-maint.el" (car cand))) - (progn - (setq psgml-source-dir (expand-file-name "." (car cand)) - cand nil)) - (setq cand (cdr cand)))) - (if (null psgml-source-dir) - (if ask - (setq psgml-source-dir - (expand-file-name - (read-file-name "Where is the psgml source? " - nil nil t))) - (error "No psgml source in current directory")))))) - - -(defun psgml-compile-files (&optional interactive-p) - "Compile the PSGML source files that needs compilation." - (interactive (list t)) - (psgml-find-source-dir interactive-p) - (let ((default-directory psgml-source-dir) - (load-path (cons psgml-source-dir load-path))) - (mapc #'psgml-byte-compile-file psgml-elisp-source) - (message "Done compiling"))) - - -(defun psgml-byte-compile-file (file) - (let ((dest (byte-compile-dest-file file))) - (if (file-newer-than-file-p file dest) - (byte-compile-file file)))) - -(defun psgml-install-elc () - "Print list of elc files to install." - (princ (mapconcat #'byte-compile-dest-file psgml-elisp-source " "))) - - -;;; psgml-maint.el ends here diff --git a/psgml-other.el b/psgml-other.el index ad1302e..1930f1d 100644 --- a/psgml-other.el +++ b/psgml-other.el @@ -1,6 +1,6 @@ ;;; psgml-other.el --- Part of SGML-editing mode with parsing support -*- lexical-binding:t -*- -;; Copyright (C) 1994, 2016 Free Software Foundation, Inc +;; Copyright (C) 1994-2022 Free Software Foundation, Inc ;; Author: Lennart Staflin <lenst@lysator.liu.se> @@ -20,7 +20,7 @@ ;;; Commentary: -;; Part of psgml.el. Code not compatible with XEmacs. +;; Part of psgml.el. ;;; Code: @@ -86,7 +86,7 @@ if the item is selected." (setq menus (sgml-split-long-menus menus)) (unless (cdr menus) (setq menus (list (car menus) '("---" "---")))) - (eval (car (x-popup-menu event (cons title menus))))) + (eval (car (x-popup-menu event (cons title menus))) t)) ;;;; Insert with properties diff --git a/psgml-parse.el b/psgml-parse.el index 96dde1d..ba78d04 100644 --- a/psgml-parse.el +++ b/psgml-parse.el @@ -1,7 +1,7 @@ ;;; psgml-parse.el --- Parser for SGML-editing mode with parsing support -*- lexical-binding:t -*- ;; $Id: psgml-parse.el,v 2.105 2008/06/21 16:13:51 lenst Exp $ -;; Copyright (C) 1994-1998, 2016-2019 Free Software Foundation, Inc. +;; Copyright (C) 1994-2022 Free Software Foundation, Inc. ;; Author: Lennart Staflin <lenst@lysator.liu.se> ;; Acknowledgment: @@ -30,7 +30,7 @@ ;;; Code: (require 'psgml) -(require (if (featurep 'xemacs) 'psgml-lucid 'psgml-other)) +(require 'psgml-other) ;;; Interface to psgml-dtd (eval-and-compile @@ -342,22 +342,6 @@ Applicable to XML.") (defvar mc-flag) -(defun sgml-set-buffer-multibyte (flag) - (cond ((featurep 'xemacs) - flag) - (t - (set-buffer-multibyte - (if (eq flag 'default) - (default-value 'enable-multibyte-characters) - flag))))) -;; Probably better. -- fx -;; (eval-and-compile -;; (if (fboundp 'set-buffer-multibyte) -;; (defalias 'sgml-set-buffer-multibyte -;; (if (fboundp 'set-buffer-multibyte) -;; 'set-buffer-multibyte -;; 'identity)))) - ;;;; State machine @@ -1200,7 +1184,7 @@ new compiled dtd will be created from file DTDFILE and parameter entity settings in ENTS." ;;(Assume the current buffer is a scratch buffer and is empty) (sgml-debug "Trying to load compiled DTD from %s..." cfile) - (sgml-set-buffer-multibyte nil) + (set-buffer-multibyte nil) (or (and (file-readable-p cfile) (let ((coding-system-for-read 'binary)) ;; fifth arg to insert-file-contents is not available in early @@ -2536,7 +2520,8 @@ overrides the entity type in entity look up." ;; An existing buffer may have been left unibyte by ;; processing a cdtd. ;; FIXME: looks strange, we haven't changed bufferw yet - (sgml-set-buffer-multibyte t)) + ;;(set-buffer-multibyte t) + ) (setq sgml-scratch-buffer (generate-new-buffer " *entity*"))) (let ((cb (current-buffer)) (dd default-directory) @@ -2553,7 +2538,7 @@ overrides the entity type in entity look up." (set (make-local-variable 'sgml-scratch-buffer) nil)) (setq sgml-last-entity-buffer (current-buffer)) (erase-buffer) - (sgml-set-buffer-multibyte 'default) + (set-buffer-multibyte t) (setq default-directory dd) (set-visited-file-name nil t) (set (make-local-variable 'sgml-current-file) nil) diff --git a/psgml-vars.el b/psgml-vars.el index 761e11b..4756e8d 100644 --- a/psgml-vars.el +++ b/psgml-vars.el @@ -1,6 +1,6 @@ ;;; psgml-vars.el --- ??? -*- lexical-binding:t -*- -;; Copyright (C) 2016 Free Software Foundation, Inc. +;; Copyright (C) 2016-2022 Free Software Foundation, Inc. ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License @@ -28,15 +28,13 @@ "If true, and sgml-auto-insert-required-elements also true, `sgml-insert-element' will insert a comment if there is an element required but there is more than one to choose from." - :type 'boolean - :group 'psgml) + :type 'boolean) (defcustom sgml-insert-end-tag-on-new-line nil "If true, `sgml-insert-element' will put the end-tag on a new line after the start-tag. Useful on slow terminals if you find the end-tag after the cursor irritating." - :type 'boolean - :group 'psgml) + :type 'boolean) (defcustom sgml-doctype nil "*If set, this should be the name of a file that contains the doctype @@ -44,8 +42,7 @@ declaration to use. Setting this variable automatically makes it local to the current buffer." :tag "Doctype file" :type '(choice (const :tag "Off" nil) - file) - :group 'psgml) + file)) (make-variable-buffer-local 'sgml-doctype) @@ -56,19 +53,16 @@ entity is not found in the catalogs will a given system identifier be used. If the variable is non-nil and a system identifier is given, the system identifier will be used for the entity. If no system identifier is given the catalogs will searched." - :type 'boolean - :group 'psgml) + :type 'boolean) (defcustom sgml-range-indicator-max-length 9 "*Maximum number of characters used from the first and last entry of a submenu to indicate the range of items in that menu." - :type 'integer - :group 'psgml) + :type 'integer) (defcustom sgml-default-doctype-name nil "*Document type name to use if no document type declaration is present." - :type '(choice (const :tag "Off" nil) string) - :group 'psgml) + :type '(choice (const :tag "Off" nil) string)) (defcustom sgml-markup-faces @@ -124,14 +118,12 @@ shortref- short reference" :type '(alist :key-type symbol :value-type face) :options '(start-tag end-tag comment pi sgml doctype entity shortref - ignored ms-start ms-end) - :group 'psgml) + ignored ms-start ms-end)) (defcustom sgml-set-face nil "*If non-nil, psgml will set the face of parsed markup." - :type 'boolean - :group 'psgml) + :type 'boolean) ;(put 'sgml-set-face 'sgml-desc "Set face of parsed markup") (defcustom sgml-auto-activate-dtd nil @@ -139,14 +131,12 @@ shortref- short reference" Activation means either to parse the document type declaration or to load a previously saved parsed DTD. The name of the activated DTD will be shown in the mode line." - :type 'boolean - :group 'psgml) + :type 'boolean) ;;(put 'sgml-auto-activate-dtd 'sgml-desc "Auto Activate DTD") (defcustom sgml-offer-save t "*If non-nil, ask about saving modified buffers before \\[sgml-validate] is run." - :type 'boolean - :group 'psgml) + :type 'boolean) (defvar sgml-parent-document nil "*How to handle the current file as part of a bigger document. @@ -180,21 +170,18 @@ Setting this variable automatically makes it local to the current buffer.") "*If non-nil, the Tags menu will tag a region if the region is considered active by emacs. If nil, region must be active and transient-mark-mode must be on for the region to be tagged." - :type 'boolean - :group 'psgml) + :type 'boolean) (defcustom sgml-normalize-trims t "*If non-nil, sgml-normalize will trim off white space from end of element when adding end tag." - :type 'boolean - :group 'psgml) + :type 'boolean) (defcustom sgml-omittag t "*Set to non-nil, if you use OMITTAG YES. Setting this variable automatically makes it local to the current buffer." - :type 'boolean - :group 'psgml) + :type 'boolean) (make-variable-buffer-local 'sgml-omittag) ;;(put 'sgml-omittag 'sgml-desc "OMITTAG") @@ -203,8 +190,7 @@ Setting this variable automatically makes it local to the current buffer." "*Set to non-nil, if you use SHORTTAG YES. Setting this variable automatically makes it local to the current buffer." - :type 'boolean - :group 'psgml) + :type 'boolean) (make-variable-buffer-local 'sgml-shorttag) ;(put 'sgml-shorttag 'sgml-desc "SHORTTAG") @@ -213,8 +199,7 @@ Setting this variable automatically makes it local to the current buffer." "*Set to non-nil, if you use NAMECASE GENERAL YES. Setting this variable automatically makes it local to the current buffer." - :type 'boolean - :group 'psgml) + :type 'boolean) (make-variable-buffer-local 'sgml-namecase-general) ;(put 'sgml-namecase-general 'sgml-desc "NAMECASE GENERAL") @@ -226,7 +211,6 @@ This can be the symbol `lower' or `upper'. Only effective if `sgml-namecase-general' is true." :type '(choice (const lower) (const upper)) - :group 'psgml ) (put 'sgml-general-insert-case 'sgml-type '(lower upper)) @@ -234,8 +218,7 @@ This can be the symbol `lower' or `upper'. Only effective if (defcustom sgml-insert-defaulted-attributes nil "*Controls whether defaulted attributes (not #FIXED) are inserted explicitly or not. nil means don't insert, t means insert." - :type 'boolean - :group 'psgml) + :type 'boolean) (defcustom sgml-minimize-attributes nil @@ -247,8 +230,7 @@ Actually two things are done Setting this variable automatically makes it local to the current buffer." :type '(choice (const :tag "No" nil) (const :tag "omit attribute name" t) - (const :tag "omit attributes with default value" max)) - :group 'psgml) + (const :tag "omit attributes with default value" max))) (make-variable-buffer-local 'sgml-minimize-attributes) (put 'sgml-minimize-attributes 'sgml-type @@ -257,16 +239,14 @@ Setting this variable automatically makes it local to the current buffer." (defcustom sgml-always-quote-attributes t "*Non-nil means quote all attribute values inserted after editing attributes. Setting this variable automatically makes it local to the current buffer." - :type 'boolean - :group 'psgml) + :type 'boolean) (make-variable-buffer-local 'sgml-always-quote-attributes) (defcustom sgml-auto-insert-required-elements t "*If non-nil, automatically insert required elements in the content of an inserted element." - :type 'boolean - :group 'psgml) + :type 'boolean) (defvar sgml-balanced-tag-edit t "*If non-nil, context menu inserts start-end tag pairs.") @@ -274,31 +254,26 @@ of an inserted element." (defcustom sgml-omittag-transparent (not sgml-balanced-tag-edit) "*If non-nil, will show legal tags inside elements with omitable start tags and legal tags beyond omitable end tags." - :type 'boolean - :group 'psgml) + :type 'boolean) (defcustom sgml-leave-point-after-insert nil "*If non-nil, the point will remain after inserted tag(s). If nil, the point will be placed before the inserted tag(s)." - :type 'boolean - :group 'psgml) + :type 'boolean) (defcustom sgml-warn-about-undefined-elements t "*If non-nil, print a warning when a tag for an undefined element is found." - :type 'boolean - :group 'psgml) + :type 'boolean) (defcustom sgml-warn-about-undefined-entities t "*If non-nil, print a warning when an undefined entity is found." - :type 'boolean - :group 'psgml) + :type 'boolean) (defcustom sgml-ignore-undefined-elements nil "*If non-nil, recover from an undefined element by ignoring the tag. If nil, recover from an undefined element by assuming it can occur any where and has content model ANY." - :type 'boolean - :group 'psgml) + :type 'boolean) (defcustom sgml-recompile-out-of-date-cdtd 'ask "*If non-nil, out of date compiled DTDs will be automatically recompiled. @@ -309,8 +284,7 @@ date, thus in such case it can be useful to set this variable to `nil'." :type '(choice (const :tag "No" nil) (const :tag "Yes" t) - (const :tag "Ask" ask)) - :group 'psgml) + (const :tag "Ask" ask))) (put 'sgml-recompile-out-of-date-cdtd 'sgml-type '(("No" . nil) ("Yes" . t) ("Ask" . ask))) @@ -318,24 +292,21 @@ date, thus in such case it can be useful to set this variable to (defcustom sgml-trace-entity-lookup nil "*If non-nil, log messages about catalog files used to look for external entities." - :type 'boolean - :group 'psgml) + :type 'boolean) (defcustom sgml-indent-step 2 "*How much to increment indent for every element level. If nil, no indentation. Setting this variable automatically makes it local to the current buffer." :type '(choice (const :tag "None" nil) - integer) - :group 'psgml) + integer)) (make-variable-buffer-local 'sgml-indent-step) (put 'sgml-indent-step 'sgml-type '(("None" . nil) 0 1 2 3 4 5 6 7 8)) (defcustom sgml-indent-data nil "*If non-nil, indent in data/mixed context also. Setting this variable automatically makes it local to the current buffer." - :type 'boolean - :group 'psgml) + :type 'boolean) (make-variable-buffer-local 'sgml-indent-data) @@ -346,8 +317,7 @@ listed individually. `sgml-exposed-tags' is local to each buffer in which it has been set; use `setq-default' to set it to a value that is shared among buffers." - :type '(repeat string) - :group 'psgml) + :type '(repeat string)) (make-variable-buffer-local 'sgml-exposed-tags) (put 'sgml-exposed-tags 'sgml-type 'list) @@ -375,7 +345,6 @@ Example: \"~/sgml/docbook.ced\" sgml-omittag nil sgml-shorttag t))) " - :group 'psgml :type '(repeat (list (string :tag "Menu entry") (string :tag "Doctype") (plist :tag "Options" :inline t))) @@ -397,7 +366,6 @@ Example: ((\"Version1\" \"<![%Version1[\\r]]>\") (\"New page\" \"<?NewPage>\")) " - :group 'psgml :type '(repeat (list (string :tag "Menu entry") (choice string sexp))) ) @@ -408,11 +376,10 @@ Example: (defcustom sgml-content-indent-function - 'sgml-indent-according-to-level + #'sgml-indent-according-to-level "*Function used to compute indentation level for element content. Function will be called with one argument, the element. Should return an integer." - :group 'psgml :type '(choice (const :tag "Indented according to nesting level" sgml-indent-according-to-level) @@ -424,11 +391,10 @@ Should return an integer." (defcustom sgml-attribute-indent-function - 'sgml-indent-according-to-stag + #'sgml-indent-according-to-stag "*Function used to compute indetation level for attributes. Function will be called with one argument, the element. Should return an integer." - :group 'psgml :type '(choice (const :tag "Indented according to nesting level" sgml-indent-according-to-level) diff --git a/psgml-xpr.el b/psgml-xpr.el index 6918127..68e222e 100644 --- a/psgml-xpr.el +++ b/psgml-xpr.el @@ -1,7 +1,7 @@ ;;; psgml-xpr.el --- Experimental additions for PSGML -*- lexical-binding:t -*- ;; $Id: psgml-xpr.el,v 2.3 2005/02/27 17:15:19 lenst Exp $ -;; Copyright (C) 2003, 2016 Free Software Foundation, Inc. +;; Copyright (C) 2003-2022 Free Software Foundation, Inc. ;; Author: Lennart Staflin <lenst@lysator.liu.se> ;; Keywords: languages @@ -59,7 +59,7 @@ (let ((sgml-psgml-pi-enable-outside-dtd t)) (sgml-parse-to-here))) -(define-key sgml-mode-map "\e\C-x" 'sgml-eval-psgml-pi) +(define-key sgml-mode-map "\e\C-x" #'sgml-eval-psgml-pi) @@ -1,12 +1,12 @@ ;;; psgml.el --- SGML-editing mode with parsing support -*- lexical-binding:t -*- -;; Copyright (C) 1992-2002, 2016-2017 Free Software Foundation, Inc. +;; Copyright (C) 1992-2022 Free Software Foundation, Inc. ;; Author: Lennart Staflin <lenst@lysator.liu.se> ;; James Clark <jjc@clark.com> ;; Maintainer: Lennart Staflin <lstaflin@gmail.com> ;; Keywords: languages -;; Version: 1.3.4 +;; Version: 1.3.5 ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License @@ -47,6 +47,11 @@ ;; unlimited lengths on names +;;; News: + +;; Since 1.3.4: +;; - Use overlays rather than the old `selective-diplay'. + ;;; Code: (defconst psgml-maintainer-address "emacs-devel@gnu.org") @@ -261,7 +266,7 @@ See `compilation-error-regexp-alist'.") (defvar sgml-show-context-function #'sgml-show-context-standard - "*Function to called to show context of and element. + "Function to called to show context of and element. Should return a string suitable form printing in the echo area.") (defconst sgml-file-options @@ -408,16 +413,15 @@ Should return a string suitable form printing in the echo area.") (sgml-insert-markup ,text)))) (defun sgml-insert-markup (text) - (let ((end (sgml-mouse-region)) - before after - old-text) - (when end - (setq old-text (buffer-substring (point) end)) - (delete-region (point) end)) - (setq before (point)) + (let* ((end (sgml-mouse-region)) + after + (old-text + (when end + (delete-and-extract-region (point) end))) + (before (point))) (if (stringp text) (insert text) - (eval text)) + (eval text t)) (setq after (point)) (goto-char before) (when (search-forward "\r" after t) @@ -427,11 +431,6 @@ Should return a string suitable form printing in the echo area.") (defun sgml-mouse-region () (let (start end) (cond - ((featurep 'xemacs) - (cond - ((null (mark-marker)) nil) - (t (setq start (region-beginning) - end (region-end))))) ((and transient-mark-mode mark-active) (setq start (region-beginning) @@ -518,63 +517,61 @@ Should return a string suitable form printing in the echo area.") (define-key map "\C-c\C-u" u-map) ;; Key commands - (define-key map "\t" 'sgml-indent-or-tab) + (define-key map "\t" #'sgml-indent-or-tab) ;; (define-key map "<" 'sgml-insert-tag) - (define-key map ">" 'sgml-close-angle) - (define-key map "/" 'sgml-slash) - (define-key map "\C-c#" 'sgml-make-character-reference) - (define-key map "\C-c-" 'sgml-untag-element) - (define-key map "\C-c+" 'sgml-insert-attribute) - (define-key map "\C-c/" 'sgml-insert-end-tag) - (define-key map "\C-c<" 'sgml-insert-tag) - (define-key map "\C-c=" 'sgml-change-element-name) - (define-key map "\C-c\C-a" 'sgml-edit-attributes) - (define-key map "\C-c\C-c" 'sgml-show-context) - (define-key map "\C-c\C-d" 'sgml-next-data-field) - (define-key map "\C-c\C-e" 'sgml-insert-element) - (define-key map "\C-c\C-f\C-e" 'sgml-fold-element) - (define-key map "\C-c\C-f\C-r" 'sgml-fold-region) - (define-key map "\C-c\C-f\C-s" 'sgml-fold-subelement) - (define-key map "\C-c\C-f\C-x" 'sgml-expand-element) - (define-key map "\C-c\C-i" 'sgml-add-element-to-element) - (define-key map "\C-c\C-k" 'sgml-kill-markup) - (define-key map "\C-c\r" 'sgml-split-element) - (define-key map "\C-c\C-n" 'sgml-up-element) - (define-key map "\C-c\C-o" 'sgml-next-trouble-spot) - (define-key map "\C-c\C-p" 'sgml-load-doctype) - (define-key map "\C-c\C-q" 'sgml-fill-element) - (define-key map "\C-c\C-r" 'sgml-tag-region) - (define-key map "\C-c\C-s" 'sgml-show-structure) - ;;(define-key map "\C-c\C-t" 'sgml-list-valid-tags) - (define-key map "\C-c\C-t" 'sgml-show-current-element-type) - (define-key map "\C-c\C-u\C-a" 'sgml-unfold-all) - (define-key map "\C-c\C-u\C-d" 'sgml-custom-dtd) - (define-key map "\C-c\C-u\C-e" 'sgml-unfold-element) - (define-key map "\C-c\C-u\C-l" 'sgml-unfold-line) - (define-key map "\C-c\C-u\C-m" 'sgml-custom-markup) - (define-key map "\C-c\C-v" 'sgml-validate) - (define-key map "\C-c\C-w" 'sgml-what-element) - (define-key map "\C-c\C-z" 'sgml-trim-and-leave-element) - - (define-key map "\e\C-a" 'sgml-beginning-of-element) - (define-key map "\e\C-e" 'sgml-end-of-element) - (define-key map "\e\C-f" 'sgml-forward-element) - (define-key map "\e\C-b" 'sgml-backward-element) - (define-key map "\e\C-d" 'sgml-down-element) - (define-key map "\e\C-u" 'sgml-backward-up-element) - (define-key map "\e\C-k" 'sgml-kill-element) - (define-key map "\e\C-@" 'sgml-mark-element) - ;;(define-key map [?\M-\C-\ ] 'sgml-mark-element) - (define-key map [(meta control h)] 'sgml-mark-current-element) - (define-key map "\e\C-t" 'sgml-transpose-element) - (define-key map "\M-\t" 'sgml-complete) - - (if (featurep 'xemacs) - (define-key map [button3] 'sgml-tags-menu) - (define-key map [?\M-\C-\ ] 'sgml-mark-element) - - ;;(define-key map [S-mouse-3] 'sgml-tags-menu) - (define-key map [S-mouse-3] 'sgml-right-menu)) + (define-key map ">" #'sgml-close-angle) + (define-key map "/" #'sgml-slash) + (define-key map "\C-c#" #'sgml-make-character-reference) + (define-key map "\C-c-" #'sgml-untag-element) + (define-key map "\C-c+" #'sgml-insert-attribute) + (define-key map "\C-c/" #'sgml-insert-end-tag) + (define-key map "\C-c<" #'sgml-insert-tag) + (define-key map "\C-c=" #'sgml-change-element-name) + (define-key map "\C-c\C-a" #'sgml-edit-attributes) + (define-key map "\C-c\C-c" #'sgml-show-context) + (define-key map "\C-c\C-d" #'sgml-next-data-field) + (define-key map "\C-c\C-e" #'sgml-insert-element) + (define-key map "\C-c\C-f\C-e" #'sgml-fold-element) + (define-key map "\C-c\C-f\C-r" #'sgml-fold-region) + (define-key map "\C-c\C-f\C-s" #'sgml-fold-subelement) + (define-key map "\C-c\C-f\C-x" #'sgml-expand-element) + (define-key map "\C-c\C-i" #'sgml-add-element-to-element) + (define-key map "\C-c\C-k" #'sgml-kill-markup) + (define-key map "\C-c\r" #'sgml-split-element) + (define-key map "\C-c\C-n" #'sgml-up-element) + (define-key map "\C-c\C-o" #'sgml-next-trouble-spot) + (define-key map "\C-c\C-p" #'sgml-load-doctype) + (define-key map "\C-c\C-q" #'sgml-fill-element) + (define-key map "\C-c\C-r" #'sgml-tag-region) + (define-key map "\C-c\C-s" #'sgml-show-structure) + ;;(define-key map "\C-c\C-t" #'sgml-list-valid-tags) + (define-key map "\C-c\C-t" #'sgml-show-current-element-type) + (define-key map "\C-c\C-u\C-a" #'sgml-unfold-all) + (define-key map "\C-c\C-u\C-d" #'sgml-custom-dtd) + (define-key map "\C-c\C-u\C-e" #'sgml-unfold-element) + (define-key map "\C-c\C-u\C-l" #'sgml-unfold-line) + (define-key map "\C-c\C-u\C-m" #'sgml-custom-markup) + (define-key map "\C-c\C-v" #'sgml-validate) + (define-key map "\C-c\C-w" #'sgml-what-element) + (define-key map "\C-c\C-z" #'sgml-trim-and-leave-element) + + (define-key map "\e\C-a" #'sgml-beginning-of-element) + (define-key map "\e\C-e" #'sgml-end-of-element) + (define-key map "\e\C-f" #'sgml-forward-element) + (define-key map "\e\C-b" #'sgml-backward-element) + (define-key map "\e\C-d" #'sgml-down-element) + (define-key map "\e\C-u" #'sgml-backward-up-element) + (define-key map "\e\C-k" #'sgml-kill-element) + (define-key map "\e\C-@" #'sgml-mark-element) + ;;(define-key map [?\M-\C-\ ] #'sgml-mark-element) + (define-key map [(meta control h)] #'sgml-mark-current-element) + (define-key map "\e\C-t" #'sgml-transpose-element) + (define-key map "\M-\t" #'sgml-complete) + + (define-key map [?\M-\C-\ ] #'sgml-mark-element) + + ;;(define-key map [S-mouse-3] #'sgml-tags-menu) + (define-key map [S-mouse-3] #'sgml-right-menu) map) "Main keymap for PSGML mode.") @@ -877,13 +874,13 @@ All bindings: (set-syntax-table sgml-mode-syntax-table) (set (make-local-variable 'comment-start) "<!-- ") (set (make-local-variable 'comment-end) " -->") - (set (make-local-variable 'comment-indent-function) 'sgml-comment-indent) + (set (make-local-variable 'comment-indent-function) #'sgml-comment-indent) ;; This will allow existing comments within declarations to be ;; recognized. [Does not work well with auto-fill, Lst/940205] ;;(setq comment-start-skip "--[ \t]*") (set (make-local-variable 'comment-start-skip) "<!--[ \t]*") ;; Added for psgml: - (set (make-local-variable 'indent-line-function) 'sgml-indent-line) + (set (make-local-variable 'indent-line-function) #'sgml-indent-line) (when (set (make-local-variable 'sgml-default-dtd-file) (sgml-default-dtd-file)) (unless (file-exists-p sgml-default-dtd-file) @@ -895,11 +892,11 @@ All bindings: (make-local-variable 'text-property-default-nonsticky) ;; see `sgml-set-face-for': (add-to-list 'text-property-default-nonsticky '(face . t))) + (add-to-invisibility-spec '(psgml-fold . t)) (add-hook 'post-command-hook #'sgml-command-post 'append 'local) (add-hook 'activate-menubar-hook #'sgml-update-all-options-menus nil 'local) - (add-hook 'which-func-functions #'sgml-current-element-name nil t) - (easy-menu-add sgml-main-menu)) + (add-hook 'which-func-functions #'sgml-current-element-name nil t)) ;; It would be nice to generalize the `auto-mode-interpreter-regexp' ;; machinery so that we could select xml-mode on the basis of the diff --git a/sgmldecl/fum.el b/sgmldecl/fum.el index e21bf1c..d3e25c0 100644 --- a/sgmldecl/fum.el +++ b/sgmldecl/fum.el @@ -1,6 +1,6 @@ ;;; fum.el --- -*- lexical-binding:t -*- -;; Copyright (C) 1995, 2017 Free Software Foundation, Inc. +;; Copyright (C) 1995-2022 Free Software Foundation, Inc. ;; Author: Lennart Staflin <lenst@lysator.liu.se> ;; Version: $Id: fum.el,v 1.1 2000/04/12 16:44:26 lenst Exp $ @@ -42,7 +42,7 @@ (erase-buffer) (cl-prettyexpand form))) -(define-key emacs-lisp-mode-map "\C-cm" 'macroexpand-next) +(define-key emacs-lisp-mode-map "\C-cm" #'macroexpand-next) (defun replace-grammar () (interactive) @@ -193,7 +193,7 @@ The check option can be `t', `nil', or a variable name." nil)))) (defalias 'sgml-parse-nt-64 ;; character number - 'sgml-parse-nt-56) + #'sgml-parse-nt-56) (defun sgml-parse-nt-76 (check) ;; minimum literal @@ -202,7 +202,7 @@ The check option can be `t', `nil', or a variable name." (sgml-parse-minimum-literal))) (defalias 'sgml-parse-nt-74 ;; public identifier - 'sgml-parse-nt-76) + #'sgml-parse-nt-76) (defun sgml-parse-nt-66 (check) ;; parameter literal diff --git a/testcase/testsuit.el b/testcase/testsuit.el index b4a2cf1..db696d3 100644 --- a/testcase/testsuit.el +++ b/testcase/testsuit.el @@ -1,6 +1,6 @@ ;;; testsuit.el --- Test Suite for PSGML -*- lexical-binding:t -*- -;; Copyright (C) 2017 Free Software Foundation, Inc. +;; Copyright (C) 2017-2022 Free Software Foundation, Inc. ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License @@ -46,7 +46,7 @@ (defun testsuit-pi-handler (string) (when (string-match "ASSERT\\>" string ) (let ((form (car (read-from-string (substring string (match-end 0)))))) - (cl-assert (eval form) nil + (cl-assert (eval form t) nil "Assertion fail: %S" form)))) @@ -85,7 +85,7 @@ (or (re-search-forward warning-pattern nil t) (error "No %s warning" warning-pattern))))) (`assert - (or (eval (cadr test)) + (or (eval (cadr test) t) (error "Fail: %s" (cadr test)))))) (when (and sgml-warning-message-flag (not warning-expected)) (error "Unexpected warnings")) )) |
