Commit 09cf42be authored by David Byers's avatar David Byers
Browse files

Updated and renamed help files. Added clickability to help cross references.

Support optional attributes in the pseudo-xml parser.
parent 2e23470d
2002-06-07 David Byers <david.byers@swipnet.se>
* help-sv.xml: New file, renamed from help.sv.
* help-en.xml: New file, renamed from help.en.
* help-compile.el (lyskom-help-compile): Read from help-XX.xml
instead of help.XX.
Improve help data:
* help.en: Set language to "en", not "sv".
* help.en, help.sv: Put cross references in reading inside a list
element.
Fix some problems with help:
* help.el (lyskom-help-format-section): New.
(lyskom-help-format-refer): Make cross-references clickable.
2002-06-06 David Byers <david.byers@swipnet.se>
Fix some problems with help:
* help.el (lyskom-help-format-list): Fixed so it works.
(lyskom-help-format-item): Ditto.
(lyskom-help-show-section): This used to be
lyskom-help-format-section.
* help-compile.el (lyskom-help-parse-string): Support optional
attributes.
(lyskom-help-syntax): Added optional attributes.
(lyskom-help-syntax-required-attrs): New function.
(lyskom-help-syntax-optional-attrs): New function.
(lyskom-help-parse-help-file): Added optional attributes to bogus
toplevel syntax specification.
2002-06-05 David Byers <david.byers@swipnet.se>
* flags.el (lyskom-maybe-set-var-from-string): Refuse to set
variables from the user area that are not specified as
server-stored LysKOM variables.
2002-06-03 David Byers <david.byers@swipnet.se> 2002-06-03 David Byers <david.byers@swipnet.se>
* commands2.el (lyskom-send-message): Use new faces for dashed * commands2.el (lyskom-send-message): Use new faces for dashed
......
...@@ -2451,7 +2451,7 @@ The variable kom-keep-alive-interval controls the frequency of the request." ...@@ -2451,7 +2451,7 @@ The variable kom-keep-alive-interval controls the frequency of the request."
(lyskom-format-insert 'pers-is-member-of-conf pers-no conf-no)) (lyskom-format-insert 'pers-is-member-of-conf pers-no conf-no))
(lyskom-format-insert 'pers-is-not-member-of-conf pers-no conf-no)))) (lyskom-format-insert 'pers-is-not-member-of-conf pers-no conf-no))))
(def-kom-command kom-help () (def-kom-command kom-help (&optional section)
"Get some help with LysKOM." "Get some help with LysKOM."
(interactive) (interactive)
(let* ((alternatives (delq nil (let* ((alternatives (delq nil
...@@ -2461,7 +2461,7 @@ The variable kom-keep-alive-interval controls the frequency of the request." ...@@ -2461,7 +2461,7 @@ The variable kom-keep-alive-interval controls the frequency of the request."
(elt section 0)))) (elt section 0))))
lyskom-help-data))) lyskom-help-data)))
(completion-ignore-case t) (completion-ignore-case t)
(section nil)) (section section))
(while (null section) (while (null section)
(setq section (setq section
(lyskom-string-assoc (lyskom-string-assoc
...@@ -2473,7 +2473,7 @@ The variable kom-keep-alive-interval controls the frequency of the request." ...@@ -2473,7 +2473,7 @@ The variable kom-keep-alive-interval controls the frequency of the request."
'lyskom-help-history) 'lyskom-help-history)
alternatives))) alternatives)))
(lyskom-format-insert 'help-for (car section)) (lyskom-format-insert 'help-for (car section))
(lyskom-help-format-section (cdr section)))) (lyskom-help-show-section (cdr section))))
(def-kom-command kom-make-review-mark-as-read () (def-kom-command kom-make-review-mark-as-read ()
......
...@@ -1731,6 +1731,13 @@ Number of sessions: %21#1d (total) ...@@ -1731,6 +1731,13 @@ Number of sessions: %21#1d (total)
(kom-redirect-comments-e48 . "Comment redirection is not supported by the server") (kom-redirect-comments-e48 . "Comment redirection is not supported by the server")
(external-program-missing . "Can't find the external program \"%#1s\", that was required for this command.") (external-program-missing . "Can't find the external program \"%#1s\", that was required for this command.")
(ignored-user-area-var . "\
Ignoring variable %#1s i in your settings.
The variable is not a registered LysKOM variable and cannot be read
from the server. If the variable corresponds to a setting that has
been removed, you can fix the problem by giving the command \"Save
variables\".\n\n")
)) ))
......
...@@ -302,6 +302,10 @@ ...@@ -302,6 +302,10 @@
if the variable is in kom-dont-read-saved-variables." if the variable is in kom-dont-read-saved-variables."
(cond ((eq kom-dont-read-saved-variables t) nil) (cond ((eq kom-dont-read-saved-variables t) nil)
((memq (intern var) kom-dont-read-saved-variables) nil) ((memq (intern var) kom-dont-read-saved-variables) nil)
((not (or (memq (intern var) lyskom-elisp-variables)
; (memq (intern var) lyskom-global-non-boolean-variables)
(memq (intern var) lyskom-global-boolean-variables)))
(lyskom-format-insert-before-prompt 'ignored-user-area-var var))
(t (lyskom-set-var-from-string var string)))) (t (lyskom-set-var-from-string var string))))
(defun lyskom-set-var-from-string (var string) (defun lyskom-set-var-from-string (var string)
......
...@@ -72,35 +72,39 @@ Value returned is always nil." ...@@ -72,35 +72,39 @@ Value returned is always nil."
__result__)) __result__))
(defvar lyskom-help-syntax (defvar lyskom-help-syntax
'((help (language) (section) lyskom-help-parse-process-finish) '((help (language) nil (section) lyskom-help-parse-process-finish)
(section (id prompt) (p list h1 h2 h3 inline refer) lyskom-help-parse-process-section) (section (id prompt) nil (p list h1 h2 h3 inline refer) lyskom-help-parse-process-section)
(h1 nil (cref TEXT) nil) (h1 nil nil (cref TEXT) nil)
(h2 nil (cref TEXT) nil) (h2 nil nil (cref TEXT) nil)
(h3 nil (cref TEXT) nil) (h3 nil nil (cref TEXT) nil)
(p nil (b i cref TEXT) nil) (p nil nil (b i cref list TEXT) nil)
(b nil (cref TEXT) nil) (b nil nil (cref TEXT) nil)
(i nil (cref TEXT) nil) (i nil nil (cref TEXT) nil)
(list nil (item) nil) (list nil (header) (item) nil)
(item nil (b i cref TEXT) nil) (item nil nil (refer b i cref TEXT) nil)
(inline (id) nil lyskom-help-parse-process-section-ref) (inline (id) nil nil lyskom-help-parse-process-section-ref)
(refer (id) nil lyskom-help-parse-process-section-ref) (refer (id) nil nil lyskom-help-parse-process-section-ref)
(cref (id) nil lyskom-help-parse-process-command-ref) (cref (id) nil nil lyskom-help-parse-process-command-ref)
) )
"Syntax of the help language. "Syntax of the help language.
Each element is the syntax for a single tag. Each list consists of Each element is the syntax for a single tag. Each list consists of
TAG ATTRS CONTENTS") TAG ATTRS CONTENTS")
(defun lyskom-help-syntax-attrs (syntax) (defun lyskom-help-syntax-required-attrs (syntax)
"Return the required attributes of a syntax element" "Return the required attributes of a syntax element"
(elt syntax 1)) (elt syntax 1))
(defun lyskom-help-syntax-optional-attrs (syntax)
"Return the required attributes of a syntax element"
(elt syntax 2))
(defun lyskom-help-syntax-contents (syntax) (defun lyskom-help-syntax-contents (syntax)
"Return the allowed content types of a syntax element" "Return the allowed content types of a syntax element"
(elt syntax 2)) (elt syntax 3))
(defun lyskom-help-syntax-postprocess (syntax) (defun lyskom-help-syntax-postprocess (syntax)
"Return the allowed content types of a syntax element" "Return the allowed content types of a syntax element"
(elt syntax 3)) (elt syntax 4))
(defvar lyskom-help-parse-section-list nil) (defvar lyskom-help-parse-section-list nil)
...@@ -196,12 +200,20 @@ CONTAINING-SYNTAX is the syntax specification for the containing tag." ...@@ -196,12 +200,20 @@ CONTAINING-SYNTAX is the syntax specification for the containing tag."
(lyskom-help-syntax-contents containing-syntax)) (lyskom-help-syntax-contents containing-syntax))
(error "Tag %s not permitted in %s" tag (car containing-syntax))) (error "Tag %s not permitted in %s" tag (car containing-syntax)))
;; Check that the attributes are OK ;; Check that all required attributes are present
(lyskom-help-traverse required-attribute
(lyskom-help-syntax-required-attrs syntax)
(unless (assq required-attribute attrs)
(error "Missing required attribute %s to tag %s"
required-attribute tag)))
;; Check that all attributes are either required or optional
(unless (equal (mapcar 'car attrs) (lyskom-help-traverse attribute attrs
(lyskom-help-syntax-attrs syntax)) (unless (or (memq (car attribute) (lyskom-help-syntax-required-attrs syntax))
(error "Invalid attribute list %s to tag %s" (memq (car attribute) (lyskom-help-syntax-optional-attrs syntax)))
(mapcar 'car attrs) tag)) (error "Invalid attribute %s to tag %s" (car attribute) tag)))
;; Found a tag, but there is intervening text ;; Found a tag, but there is intervening text
;; If we were called with instructions to save this data, ;; If we were called with instructions to save this data,
...@@ -279,7 +291,7 @@ CONTAINING-SYNTAX is the syntax specification for the containing tag." ...@@ -279,7 +291,7 @@ CONTAINING-SYNTAX is the syntax specification for the containing tag."
(lyskom-help-replace-regexp "<!--[^>]*-->" "") (lyskom-help-replace-regexp "<!--[^>]*-->" "")
(lyskom-help-replace-regexp "\\s-+" " ") (lyskom-help-replace-regexp "\\s-+" " ")
(let ((parse (lyskom-help-parse-string (buffer-string) (let ((parse (lyskom-help-parse-string (buffer-string)
'(nil nil (help))))) '(toplevel nil nil (help)))))
parse)))) parse))))
(defun lyskom-help-parse-extract (parse tag) (defun lyskom-help-parse-extract (parse tag)
...@@ -289,13 +301,13 @@ CONTAINING-SYNTAX is the syntax specification for the containing tag." ...@@ -289,13 +301,13 @@ CONTAINING-SYNTAX is the syntax specification for the containing tag."
(setq result (setq result
(cons (list (intern (lyskom-help-data-get-attr 'id toplevel)) (cons (list (intern (lyskom-help-data-get-attr 'id toplevel))
(lyskom-help-data-get-attr 'prompt toplevel) (lyskom-help-data-get-attr 'prompt toplevel)
(lyskom-help-data-get-data toplevel)) toplevel)
result)))) result))))
(nreverse result))) (nreverse result)))
(defmacro lyskom-help-compile (language) (defmacro lyskom-help-compile (language)
`(quote ,(lyskom-help-parse-extract `(quote ,(lyskom-help-parse-extract
(lyskom-help-data-get-data (lyskom-help-data-get-data
(car (lyskom-help-parse-help-file (format "help.%s" language)))) (car (lyskom-help-parse-help-file (format "help-%s.xml" language))))
'section))) 'section)))
<!-- -*-mode: xml-*- --> <!-- -*-mode: xml-*- -->
<help language="sv"> <help language="en">
<section id="conferences" prompt="Conferences"> <section id="conferences" prompt="Conferences">
<h1>Conferences</h1> <h1>Conferences</h1>
...@@ -146,9 +146,11 @@ ...@@ -146,9 +146,11 @@
mentioned below. mentioned below.
</p> </p>
<refer id="filter" /> <list header="See also:">
<refer id="review" /> <item><refer id="filter" /></item>
<refer id="mark" /> <item><refer id="review" /></item>
<item><refer id="mark" /></item>
</list>
</section> </section>
<section id="filter" prompt="Avoiding certain texts"> <section id="filter" prompt="Avoiding certain texts">
......
...@@ -150,9 +150,11 @@ ...@@ -150,9 +150,11 @@
kö för att läsas. kö för att läsas.
</p> </p>
<refer id="filter" /> <list header="Se även:">
<refer id="review" /> <item><refer id="filter" /></item>
<refer id="mark" /> <item><refer id="review" /></item>
<item><refer id="mark" /></item>
</list>
</section> </section>
<section id="filter" prompt="Slippa läsa inlägg"> <section id="filter" prompt="Slippa läsa inlägg">
......
...@@ -88,13 +88,14 @@ ...@@ -88,13 +88,14 @@
(inline . lyskom-help-format-inline) (inline . lyskom-help-format-inline)
(refer . lyskom-help-format-refer) (refer . lyskom-help-format-refer)
(cref . lyskom-help-format-cref) (cref . lyskom-help-format-cref)
(section . lyskom-help-format-section)
(TEXT . lyskom-help-format-TEXT)) (TEXT . lyskom-help-format-TEXT))
) )
(defun lyskom-help-get-section (section) (defun lyskom-help-get-section (section)
(elt (assq section lyskom-help-data) 2)) (elt (assq section lyskom-help-data) 2))
(defun lyskom-help-format-section (section) (defun lyskom-help-show-section (section)
"Format and insert section SECTION." "Format and insert section SECTION."
(lyskom-do-help-format (lyskom-help-get-section section))) (lyskom-do-help-format (lyskom-help-get-section section)))
...@@ -113,9 +114,13 @@ ...@@ -113,9 +114,13 @@
(let ((start (point-marker))) (let ((start (point-marker)))
(lyskom-traverse el (lyskom-help-data-get-data data) (lyskom-traverse el (lyskom-help-data-get-data data)
(lyskom-do-help-format el)) (lyskom-do-help-format el))
(add-text-properties start (point) props) (add-text-properties start (point-max) props)
(set-marker start nil))) (set-marker start nil)))
(defun lyskom-help-format-section (section)
"Format and insert section SECTION."
(lyskom-do-help-format (lyskom-help-data-get-data section)))
(defun lyskom-help-format-h1 (data) (defun lyskom-help-format-h1 (data)
(lyskom-insert "\n\n") (lyskom-insert "\n\n")
(lyskom-help-format-text-properties data '(face lyskom-help-h1-face)) (lyskom-help-format-text-properties data '(face lyskom-help-h1-face))
...@@ -141,20 +146,35 @@ ...@@ -141,20 +146,35 @@
(defun lyskom-help-format-list (data) (defun lyskom-help-format-list (data)
(lyskom-insert "\n") (lyskom-insert "\n")
(lyskom-traverse el data (lyskom-do-help-format el)) (when (lyskom-help-data-get-attr 'header data)
(lyskom-insert (lyskom-help-data-get-attr 'header data))
(lyskom-insert "\n"))
(lyskom-do-help-format (lyskom-help-data-get-data data))
(lyskom-insert "\n")) (lyskom-insert "\n"))
(defun lyskom-help-format-item (data) (defun lyskom-help-format-item (data)
(lyskom-insert " * ") (lyskom-insert " * ")
(lyskom-traverse el data (lyskom-do-help-format el)) (lyskom-do-help-format (lyskom-help-data-get-data data))
(lyskom-insert "\n")) (lyskom-insert "\n"))
(defun lyskom-help-format-refer (data) (defun lyskom-help-format-refer (data)
(let* ((id (intern (lyskom-help-data-get-attr 'id data))) (let* ((id (intern (lyskom-help-data-get-attr 'id data)))
(section (lyskom-help-get-section id))) (section (lyskom-help-get-section id))
(cond (section (lyskom-insert (string (or (lyskom-help-data-get-attr 'prompt section)
(lyskom-help-data-get-attr 'prompt section))) (format "%s" id))))
(t (lyskom-insert (format "%s" id)))))) (lyskom-format-insert
"%#2@%#1s"
string
`(face underline
mouse-face highlight
lyskom-button t
lyskom-button-text ""
lyskom-button-type func
lyskom-buffer ,(current-buffer)
lyskom-button-arg (kom-help (,string . ,id)))))
)
(defun lyskom-help-format-cref (data) (defun lyskom-help-format-cref (data)
(let* ((command (intern (lyskom-help-data-get-attr 'id data))) (let* ((command (intern (lyskom-help-data-get-attr 'id data)))
...@@ -187,7 +207,7 @@ ...@@ -187,7 +207,7 @@
(lyskom-do-help-format el)) (lyskom-do-help-format el))
(save-excursion (save-excursion
(save-restriction (save-restriction
(narrow-to-region start (point)) (narrow-to-region start (point-max))
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward "^\\s-+" nil t) (while (re-search-forward "^\\s-+" nil t)
(replace-match "" nil nil)) (replace-match "" nil nil))
......
...@@ -1744,6 +1744,13 @@ Antal sessioner: %21#1d (totalt) ...@@ -1744,6 +1744,13 @@ Antal sessioner: %21#1d (totalt)
(kom-redirect-comments-e48 . "Omdirigering av kommentarer stds inte av servern") (kom-redirect-comments-e48 . "Omdirigering av kommentarer stds inte av servern")
(external-program-missing . "Hittar inte det externa programmet \"%#1s\" som krvs fr att genomfra kommandot.") (external-program-missing . "Hittar inte det externa programmet \"%#1s\" som krvs fr att genomfra kommandot.")
(ignored-user-area-var . "\
Ignorerar variabeln %#1s i dina instllningar.
Variabeln r inte en registrerad LysKOM-variabel och kan drfr inte
lsas frn servern. Om variabeln motsvarar en instllning som har
tagits bort s kan du tgrda genom att ge kommandot \"Spara
variabler\".\n\n")
)) ))
(lyskom-language-var local lyskom-month-names sv (lyskom-language-var local lyskom-month-names sv
......
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