branch: scratch/psgml commit a6b19d374b580d7f4ddc71846f28c3a0df959970 Author: Stefan Monnier <monn...@iro.umontreal.ca> Commit: Stefan Monnier <monn...@iro.umontreal.ca>
* psgml-charent.el: Remove, for lack of copyright paperwork * psgml.el (sgml-charent-to-display-char, sgml-display-char-to-charent): Don't autoload from psgml-charent. (sgml-main-menu): Comment out the corresponding menu entries. --- psgml-charent.el | 118 ------------------------------------------------------ psgml-debug.el | 4 +- psgml-edit.el | 2 +- psgml-maint.el | 2 +- psgml.el | 12 +++--- 5 files changed, 11 insertions(+), 127 deletions(-) diff --git a/psgml-charent.el b/psgml-charent.el deleted file mode 100644 index b46e901..0000000 --- a/psgml-charent.el +++ /dev/null @@ -1,118 +0,0 @@ -;;; psgml-charent.el --- ??? -*- lexical-binding:t -*- - -;; Copyright (C) 1994, 2016 Free Software Foundation, Inc. - -;; Author: Steinar Bang, Falch Hurtigtrykk as., Oslo, 940711 -;; Lennart Staflin <le...@lysator.liu.se> -;; -;; 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 <http://www.gnu.org/licenses/>. - - -;;; Commentary: - -;; Functions to convert character entities into displayable characters -;; and displayable characters back into character entities. - -;; This should either use iso-cvt or do better with a multilingual set of entities - - -;;; Code: - -(require 'psgml-parse) - -;;;; Variable declarations - -(defvar sgml-display-char-list-filename - (expand-file-name "iso88591.map" - (file-name-directory (locate-library "psgml"))) - "*Name of file holding relations between character codes and character -names of displayable characters") - -(defvar sgml-display-char-alist-cache nil) - - -;;;; Function declarations - -(defun sgml-display-char-alist () - "Return the current display character alist. -Alist with entity name as key and display character as content." - (unless (file-exists-p sgml-display-char-list-filename) - (error "No display char file: %s" - sgml-display-char-list-filename)) - (sgml-cache-catalog sgml-display-char-list-filename - 'sgml-display-char-alist-cache - (function sgml-read-display-char-alist))) - -(defun sgml-read-display-char-alist () - (let (key disp-char alist) - (while (re-search-forward "^\\([0-9]+\\)[ \t]+\\(.+\\)$" nil t) - (setq key (buffer-substring (match-beginning 2) (match-end 2))) - (setq disp-char (string-to-number (buffer-substring (match-beginning 1) - (match-end 1)))) - (if (fboundp 'unibyte-char-to-multibyte) - (setq disp-char (unibyte-char-to-multibyte disp-char))) - (setq disp-char (char-to-string disp-char)) - (push (cons key disp-char) - alist)) - alist)) - -(defun sgml-charent-to-dispchar-alist () - "Association list to hold relations of the type - (CHARACTER-NAME . CHARACTER) - where - CHARACTER-NAME is a string holding a character name - CHARACTER is a string holding a single displayable character" - (sgml-need-dtd) - (let ((display-chars (sgml-display-char-alist)) - (alist nil)) - (sgml-map-entities - (function - (lambda (entity) - (let ((char (cdr (assoc (sgml-entity-text entity) - display-chars)))) - (when char - (push (cons (sgml-entity-name entity) char) alist))))) - (sgml-dtd-entities sgml-dtd-info)) - - alist)) - - -(defun sgml-charent-to-display-char () - "Replace character entities with their display character equivalents" - (interactive) - (let ((charent-to-char - (sgml-charent-to-dispchar-alist)) - charent replacement) - (save-excursion - (goto-char (point-min)) - (sgml-with-parser-syntax - (while (re-search-forward "&\\(\\w\\(\\w\\|\\s_\\)*\\);?" nil t) - (setq charent (buffer-substring-no-properties - (match-beginning 1) (match-end 1))) - (if (setq replacement (cdr (assoc charent charent-to-char))) - (replace-match replacement t t))))))) - -(defun sgml-display-char-to-charent () - "Replace displayable characters with their character entity equivalents" - (interactive) - (let ((case-fold-search nil)) - (save-excursion - (dolist (pair (sgml-charent-to-dispchar-alist)) - (goto-char (point-min)) - (while (search-forward (cdr pair) nil t) - (replace-match (concat "&" (car pair) ";") t t)))))) - - -(provide 'psgml-charent) -;;; psgml-charent.el ends here diff --git a/psgml-debug.el b/psgml-debug.el index 13eb901..12278a9 100644 --- a/psgml-debug.el +++ b/psgml-debug.el @@ -1,6 +1,6 @@ ;;; psgml-debug.el --- ??? -*- lexical-binding:t -*- -;; Copyright (C) 2016 Free Software Foundation, Inc. +;; Copyright (C) 2016-2017 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 @@ -222,7 +222,7 @@ (with-output-to-temp-buffer "*autoload*" (cl-loop for file in '("psgml-parse" "psgml-edit" "psgml-dtd" - "psgml-info" "psgml-charent") + "psgml-info") do (set-buffer (find-file-noselect (concat file ".el"))) (goto-char (point-min)) diff --git a/psgml-edit.el b/psgml-edit.el index 7300612..cbb2cc0 100644 --- a/psgml-edit.el +++ b/psgml-edit.el @@ -911,7 +911,7 @@ CURVALUE is nil or a string that will be used as default value." (format " Default: %s" curvalue) ""))) value) - (setq value + (setq value (cond ((or tokens notations) (let ((completion-ignore-case sgml-namecase-general)) (completing-read prompt diff --git a/psgml-maint.el b/psgml-maint.el index 7e27634..c0073f0 100644 --- a/psgml-maint.el +++ b/psgml-maint.el @@ -37,7 +37,7 @@ (defconst psgml-common-files '("psgml.el" "psgml-parse.el" "psgml-edit.el" "psgml-dtd.el" - "psgml-info.el" "psgml-charent.el" "psgml-api.el")) + "psgml-info.el" "psgml-api.el")) (defconst psgml-emacs-files '("psgml-other.el")) (defconst psgml-xemacs-files '("psgml-lucid.el")) diff --git a/psgml.el b/psgml.el index 4020379..60f987f 100644 --- a/psgml.el +++ b/psgml.el @@ -1,6 +1,6 @@ ;;; psgml.el --- SGML-editing mode with parsing support -*- lexical-binding:t -*- -;; Copyright (C) 1992-2002, 2016 Free Software Foundation, Inc. +;; Copyright (C) 1992-2002, 2016-2017 Free Software Foundation, Inc. ;; Author: Lennart Staflin <le...@lysator.liu.se> ;; James Clark <j...@clark.com> @@ -647,8 +647,12 @@ Should return a string suitable form printing in the echo area.") ["Kill Element" sgml-kill-element t] ["Untag Element" sgml-untag-element t] ["Trim and leave element" sgml-trim-and-leave-element t] - ["Decode Character Entities" sgml-charent-to-display-char t] - ["Encode Characters" sgml-display-char-to-charent t] + ;; FIXME: These 2 commands used to be in psgml-charent, but I wasn't able to + ;; get their author's copyright (Steinar Bang and Falch Hurtigtrykk). + ;; We should rewrite them, but I can't understand DTD enough to know how + ;; it's really supposed to work. --Stef + ;;["Decode Character Entities" sgml-charent-to-display-char t] + ;;["Encode Characters" sgml-display-char-to-charent t] "--" ("File Options" "---") ("User Options" "---") @@ -1277,8 +1281,6 @@ otherwise it will be added at the first legal position." t) (autoload 'sgml-describe-entity "psgml-info" "Describe the properties of an entity as declared in the current DTD." t) (autoload 'sgml-describe-element-type "psgml-info" "Describe the properties of an element type as declared in the current DTD." t) (autoload 'sgml-describe-dtd "psgml-info" "Display information about the current DTD." t) -(autoload 'sgml-charent-to-display-char "psgml-charent" "Replace character entities with their display character equivalents" t) -(autoload 'sgml-display-char-to-charent "psgml-charent" "Replace displayable characters with their character entity equivalents" t) ;;;; Last provisions