Commit 7621a944 authored by Joel Rosdahl's avatar Joel Rosdahl
Browse files

Support for symbolic mark types.

parent 04bb7e18
2001-04-01 Joel Rosdahl <joel@rosdahl.net>
* view-text.el (lyskom-view-text): Insert symbolic mark type.
* vars.el.in (kom-symbolic-marks-alist): Added.
* swedish-strings.el (lyskom-message): Changed mark-related
strings.
(lyskom-custom-strings): Added mark-related strings. More
documentation in kom-default-mark-doc.
* english-strings.el (lyskom-message): Changed mark-related
strings.
(lyskom-custom-strings): Added mark-related strings. More
documentation in kom-default-mark-doc.
* option-edit.el (lyskom-customize-buffer-format): Added
kom-symbolic-marks-alist.
(lyskom-custom-variables): Ditto.
(lyskom-widget-functions): Added mark-association.
(lyskom-mark-association-widget): New function.
(lyskom-widget-mark-association-action): New function.
(lyskom-widget-mark-association-match): New function.
(lyskom-widget-mark-association-validate): New function.
(lyskom-widget-mark-association-value-create): New function.
(lyskom-mark-association): New widget.
* komtypes.el (mark->symbolic-mark-type): New function.
* commands2.el (kom-list-marks): Insert symbolic mark type.
(lyskom-print-mark-summary-line): Ditto.
(lyskom-symbolic-mark-type-string): New function.
(lyskom-max-mark-width): New function.
* commands1.el (lyskom-read-mark-type): New function.
(lyskom-mark-text): Use lyskom-read-mark-type.
(kom-review-marked-texts): Use lyskom-read-mark-type.
(lyskom-review-marked-texts): Insert symbolic mark type.
2001-03-31 Ulrik Haugen <qha@lysator.liu.se>
* english-strings.el (lyskom-en-mode-map): added binding "r h" for
......
......@@ -1825,7 +1825,7 @@ converted so that the search is case insensitive."
;;; Markera och Avmarkera - Mark and Unmark a text
;;; Author: Inge Wallin
;;; Modified by: Linus Tolke, Johan Sundström
;;; Modified by: Linus Tolke, Johan Sundström, Joel Rosdahl
(def-kom-command kom-mark-text (&optional text-no)
"Mark the text TEXT-NO."
......@@ -1861,8 +1861,7 @@ the user for what mark to use."
(let ((mark
(or mark
kom-default-mark
(lyskom-read-num-range
0 255 (lyskom-get-string 'what-mark) t))))
(lyskom-read-mark-type (lyskom-get-string 'what-mark)))))
(lyskom-format-insert 'marking-textno text-no)
(if (blocking-do 'mark-text text-no mark)
......@@ -1873,18 +1872,56 @@ the user for what mark to use."
(cache-del-text-stat text-no)))
(defun lyskom-read-mark-type (prompt &optional nildefault)
"Ask user about symbolic mark type and return the (integer)
mark-type. Prompt with PROMPT. If NILDEFAULT is non-nil, nil is
returned if the user enters the empty string, otherwise the user is
prompted again."
(let ((mark-type -1)
(completion-ignore-case t)
(completions kom-symbolic-marks-alist)
(first-time t)
(default-chosen nil))
(while (and (not default-chosen)
(or (not (integerp mark-type))
(< mark-type 0)
(> mark-type 255)))
(if first-time
(setq first-time nil)
(lyskom-insert 'erroneous-mark))
(let ((mark (lyskom-completing-read
prompt
(lyskom-maybe-frob-completion-table
completions))))
(if (and nildefault
(stringp mark)
(string= mark ""))
(setq default-chosen t)
(setq mark-type
(let ((tmp (lyskom-string-assoc mark completions)))
(if tmp
;; Correct completion.
(cdr tmp)
;; Incorrect completion. Check for an integer.
(if (string-match "\\`[0-9]+\\'" mark)
(string-to-int mark)
-1)))))))
(if default-chosen
nil
mark-type)))
;;; ================================================================
;;; ]terse alla markerade - Review marked texts
;;; Author: Inge Wallin
;;; Modified by: Joel Rosdahl
(def-kom-command kom-review-marked-texts ()
"Review marked texts with a certain mark."
(interactive)
(lyskom-review-marked-texts
(lyskom-read-num-range
0 255 (lyskom-get-string 'what-mark-to-view) t)))
(lyskom-review-marked-texts
(lyskom-read-mark-type (lyskom-get-string 'what-mark-to-view) t)))
(def-kom-command kom-review-all-marked-texts ()
......@@ -1909,7 +1946,9 @@ If MARK-NO is nil, review all marked texts."
(if (eq (length text-list) 0)
(lyskom-insert (if (null mark-no)
(lyskom-get-string 'no-marked-texts)
(lyskom-format 'no-marked-texts-mark mark-no)))
(lyskom-format 'no-marked-texts-mark
(lyskom-symbolic-mark-type-string
mark-no))))
(let ((read-info (lyskom-create-read-info
'REVIEW-MARK nil
(lyskom-get-current-priority)
......
......@@ -1023,22 +1023,29 @@ Format is 23:29 if the text is written today. Otherwise 04-01."
;;; ============================================================
;;; kom-list-marks Lista markeringar
;;; Author: David Byers
;;; Modified by: Joel Rosdahl
(def-kom-command kom-list-marks (&optional which-mark)
"List texts marked with a particular mark number."
(interactive "P")
(when (not (numberp which-mark))
(setq which-mark (lyskom-read-num-range
0 255
(lyskom-get-string 'list-which-mark) nil nil nil t)))
(setq which-mark (lyskom-read-mark-type
(lyskom-get-string 'list-which-mark)
t)))
(let ((marks
(sort (listify-vector (blocking-do 'get-marks))
(lambda (a b) (< (mark->mark-type a) (mark->mark-type b))))))
(let ((time (blocking-do 'get-time))
(author-width (/ (- (lyskom-window-width) 26) 3)))
(lambda (a b) (< (mark->mark-type a) (mark->mark-type b)))))
(time (blocking-do 'get-time))
(author-width (max 0
(/ (- (lyskom-window-width)
23
(lyskom-max-mark-width))
3))))
;; Start fetching all text-stats and text to list them.
(lyskom-format-insert (concat "%-4#6s%-8#1s%-6#2s%-4#3s %-"
(lyskom-format-insert (concat "%-"
(int-to-string (1+ (lyskom-max-mark-width)))
"#6s%-8#1s%-6#2s%-4#3s %-"
(int-to-string author-width)
"#4s %#5s\n")
(lyskom-get-string 'Texts)
......@@ -1064,22 +1071,27 @@ Format is 23:29 if the text is written today. Otherwise 04-01."
(sit-for 0))))
; (lyskom-insert (make-string (1- (window-width)) ?-))
; (lyskom-insert "\n")
)))
))
(defun lyskom-print-mark-summary-line (mark text-stat text text-no year day)
"Handle the info, fetch the author and print it.
Args: TEXT-STAT TEXT TEXT-NO YEAR DAY.
The year and day is there to be able to choose format on the day.
Format is 23:29 if the text is written today. Otherwise 04-01."
(lyskom-format-insert "%3#1d " (mark->mark-type mark))
(lyskom-format-insert (format "%%-%d#1s " (lyskom-max-mark-width))
(mark->symbolic-mark-type mark))
(if (not (and text-stat text)) ;+++ B{ttre felhantering.
(lyskom-format-insert 'could-not-read text-no)
(let* ((lines (text-stat->no-of-lines text-stat))
(txt (text->decoded-text-mass text text-stat))
(eos (string-match (regexp-quote "\n") txt))
(subject (substring txt 0 eos))
;; length of the number %%%%%% :8
;; length for time is: 6
(author-and-subj-width (max 0
(- (lyskom-window-width)
23
(lyskom-max-mark-width))))
;; length of the number: 8
;; length for time: 6
(time (text-stat->creation-time text-stat))
(time (if (and (= year (time->year time))
(= day (time->yday time)))
......@@ -1087,10 +1099,10 @@ Format is 23:29 if the text is written today. Otherwise 04-01."
(time->min time))
(format "%02d-%02d" (1+ (time->mon time))
(time->mday time))))
;; length for lines is: 4
;; length for lines: 5
;; We split the rest between author and subject
(namelen (/ (- (lyskom-window-width) 26) 3))
(subjlen (/ (* (- (lyskom-window-width) 26) 2) 3))
(namelen (/ author-and-subj-width 3))
(subjlen (- author-and-subj-width namelen))
(format-string (concat "%=-8#1n%#2s%4#3d %=-"
(int-to-string namelen)
"#4P %[%#5@%=-"
......@@ -1105,6 +1117,16 @@ Format is 23:29 if the text is written today. Otherwise 04-01."
text-no)
subject))))
(defun lyskom-symbolic-mark-type-string (mark-no)
"Return a symbolic name string for the mark-type of MARK."
(or (car-safe (rassoc mark-no kom-symbolic-marks-alist))
(int-to-string mark-no)))
(defun lyskom-max-mark-width ()
(max 3
(apply 'max
(mapcar (function (lambda (x) (length (car x))))
kom-symbolic-marks-alist))))
;;; ============================================================
;;; kom-who-am-i - Vem r jag
......
......@@ -364,13 +364,14 @@ and you have finished reading. Please come back later.
(new-supervisor . "New supervisor: ")
(text-to-mark . "Mark which text? ")
(text-to-unmark . "Unmark which text? ")
(what-mark . "Set which mark? ")
(what-mark . "Set which mark type (name or 0-255)? ")
(erroneous-mark . "Erroneous mark type.\n")
(unmarking-textno . "Unmarking text %#1n...")
(marking-textno . "Marking text %#1n...")
(list-which-mark . "List texts with which mark (0-255, RET for all)? ")
(list-which-mark . "List texts with which mark type (name or 0-255, RET for all)? ")
(new-passwd-again . "Repeat the new password for confirmation: ")
(what-mark-to-view . "Review which mark? ")
(what-mark-to-view . "Review which mark type (name or 0-255, RET for all)? ")
(whos-passwd . "Change password for whom? (yourself) ")
(old-passwd . "Your current password: ")
(new-passwd . "The new password: ")
......@@ -427,7 +428,7 @@ and you have finished reading. Please come back later.
(no-marked-texts . "You have not marked any texts.\n")
(no-marked-texts-mark .
"You have not marked any texts with mark %#1d.\n")
"You have not marked any texts with mark type \"%#1s\".\n")
(weekdays . ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday"
"Friday" "Saturday" "Sunday"])
......@@ -664,10 +665,6 @@ The message you were sending to %#1M was:
(could-not-read . "You couldn't read the text (%#1n).\n")
(multiple-choice . "There are several alternatives.")
(what-mark-to-list . "List which mark? ")
(you-have-marks . "You have %#1d texts marked with %#2d.\n")
(you-have-marks-all . "You have %#1d marked texts.\n")
(does-not-exist . "Unknown command.") ; Only people fixing bugs or receiving bug reports should change these:
(summary-line . "%=-8#1n%#2s%4#3d %[%#4@%#5:P%] %[%#6@%#7r%]\n")
......@@ -825,8 +822,8 @@ Help: \\[describe-mode] ---")
(line . " /1 line/ ")
(lines ." /%#1d lines/ ")
(marked-by-you . "Marked by you (%#1d).\n")
(marked-by-you-and-others . "Marked by you (%#2d) and %#1?d%[someone else%]%[%#1d others%].\n")
(marked-by-you . "Marked by you (type: %#1s).\n")
(marked-by-you-and-others . "Marked by you (type: %#2s) and %#1?d%[someone else%]%[%#1d others%].\n")
(marked-by-several . "Marked by %#1d user%#1?d%[%]%[s%].\n")
(time-yyyy-mm-dd-hh-mm . "%4#1d-%02#2d-%02#3d %02#4d:%02#5d")
......@@ -2358,7 +2355,11 @@ Select whether to execute command or keyboard macro.")
(a-string . "The string")
(some-string . "A random string")
(unspecified . "Unspecified")
(symbolic-mark-association . "Association")
(symbolic-mark-name . "Symbolic name: ")
(mark-type-to-assoc . "Mark type to associate with: ")
;;
;; Misc doc strings
;;
......@@ -2670,8 +2671,17 @@ be saved in the server. Otherwise it will be saved in your .emacs.")
off, those texts are presented as any other texts.")
(kom-default-mark-doc . "\
The default value used for marking texts. If no value is selected, LysKOM
asks for a mark value every time. Values between 1 and 255 are allowed.")
The default mark type used for marking texts. A mark type is an integer
between 0 and 255 (inclusive). If no default mark type is selected, LysKOM
asks for a mark type every time a text is to be marked. This can be used
to separate different types of marks. You can, for example, mark texts
which contain valuable information with a certain integer and texts which
you should remember to comment some time with another integer.")
(kom-symbolic-marks-alist-doc . "\
To avoid having to memorize what the integer mark types are supposed to
mean, you can define a list of symbolic mark types. A symbolic mark type
is a descriptive string that is associated with an integer mark type.")
(kom-reading-puts-comments-in-pointers-last-doc . "\
Controls if comment links are listed before or after the body of a text.
......@@ -3300,6 +3310,8 @@ be saved in the server. Otherwise it will be saved in your .emacs.")
(kom-mosaic-command-tag . "Command to start NCSA Mosaic:")
(kom-netscape-command-tag . "Command to start Netscape Navigator:")
(kom-symbolic-marks-alist-tag . "Symbolic mark types:")
(kom-cite-string-tag . "Quotation indicator: ")
(kom-confirm-multiple-recipients-tag .
"Confirm multiple recipients: ")
......
......@@ -1466,6 +1466,10 @@ The MAPS must be consecutive. No gaps or overlaps are currently allowed."
"Return t if OBJECT is a mark."
(eq (car-safe object) 'MARK))
;;; Utilities
(defun mark->symbolic-mark-type (mark)
(lyskom-symbolic-mark-type-string (mark->mark-type mark)))
;;; ================================================================
;;; who-info
......
......@@ -158,6 +158,7 @@
"\n"
[kom-saved-file-name]
[kom-default-mark]
[kom-symbolic-marks-alist]
[kom-membership-default-priority]
[kom-membership-default-placement]
[kom-unsubscribe-makes-passive]
......@@ -495,6 +496,12 @@ customize buffer but do not save them to the server."
:format "%[%t%] (%v)"
:size 0)
(const (ask nil)))))
(kom-symbolic-marks-alist (repeat (mark-association
nil
:tag symbolic-mark-association
:mark-key-prompt symbolic-mark-name
:mark-value-prompt mark-type-to-assoc)
:indent 4))
(kom-reading-puts-comments-in-pointers-last (toggle (after before)))
(kom-autowrap (choice ((const (on t))
(const (off nil))
......@@ -688,6 +695,7 @@ customize buffer but do not save them to the server."
(language-choice . lyskom-language-widget)
(file . lyskom-file-widget)
(ansaphone . lyskom-ansaphone-reply-widget)
(mark-association . lyskom-mark-association-widget)
))
(defun lyskom-make-menu-tag (str)
......@@ -820,6 +828,9 @@ customize buffer but do not save them to the server."
(defun lyskom-person-widget (type &optional args propl)
(lyskom-build-simple-widget-spec 'lyskom-name nil propl))
(defun lyskom-mark-association-widget (type &optional args propl)
(lyskom-build-simple-widget-spec 'lyskom-mark-association nil propl))
(defun lyskom-command-widget (type &optional args propl)
(lyskom-build-simple-widget-spec 'lyskom-command nil propl))
......@@ -1496,6 +1507,68 @@ customize buffer but do not save them to the server."
':match 'lyskom-widget-kbd-macro-match)
;;;
;;; Mark association widget
;;;
(defun lyskom-widget-mark-association-action (widget &optional event)
(widget-value-set
widget
(cons
(lyskom-read-string (widget-get widget ':mark-key-prompt))
(lyskom-read-num-range 0
255
(widget-get widget ':mark-value-prompt)
t)))
(widget-setup))
(defun lyskom-widget-mark-association-match (widget value)
(and (consp value)
(let ((s (car value))
(i (cdr value)))
(and (stringp s)
(> (length s) 0)
(integerp i)
(>= i 0)
(<= i 255)))))
(defun lyskom-widget-mark-association-validate (widget)
(let ((value (widget-value widget)))
(if (lyskom-widget-mark-association-match widget value)
nil
(lyskom-widget-invalid-value widget))))
(defun lyskom-widget-mark-association-value-create (widget)
(let ((from (point))
(value (widget-value widget)))
(insert (format "%s <--> %s"
(car value)
(if (and (string= (car value) "...")
(= (cdr value) 0))
"..."
(cdr value))))
(widget-put widget ':value-from (copy-marker from))
(widget-put widget ':value-to (copy-marker (point)))))
(define-widget 'lyskom-mark-association 'default
"A mark association."
:tag "Mark association"
:format "%[%t%] %v\n"
:value '("..." . 0)
:help-echo (lyskom-custom-string 'change-this-name)
:match 'lyskom-widget-mark-association-match
:validate 'lyskom-widget-mark-association-validate
:action 'lyskom-widget-mark-association-action
:value-create 'lyskom-widget-mark-association-value-create
:value-delete 'lyskom-widget-value-delete
:value-get 'lyskom-widget-value-get
:value-to-external 'lyskom-widget-value-to-external
:value-to-internal 'lyskom-widget-value-to-internal)
;;;
;;; Help widget
;;;
(defun lyskom-widget-help-action (widget &optional event)
(let* ((value (widget-get widget ':value))
(spec (assq value (widget-get widget ':args)))
......
......@@ -340,13 +340,14 @@ du har l
(new-supervisor . "Ny organisatr: ")
(text-to-mark . "Vilket inlgg vill du markera? ")
(text-to-unmark . "Vilket inlgg vill du avmarkera? ")
(what-mark . "Vilken markering vill du stta? ")
(what-mark . "Vilken typ av markering vill du stta (namn eller 0-255)? ")
(erroneous-mark . "Felaktig markeringstyp.\n")
(unmarking-textno . "Avmarkering av text %#1n...")
(marking-textno . "Markering av text %#1n...")
(list-which-mark . "Lista vilken markering (0-255, RET fr alla)? ")
(list-which-mark . "Lista vilken markeringstyp (namn eller 0-255, RET fr alla)? ")
(new-passwd-again . "Mata in det nya lsenordet igen fr kontroll: ")
(what-mark-to-view . "Vilken markering vill du terse? ")
(what-mark-to-view . "terse vilken markeringstyp (namn eller 0-255, RET fr alla)? ")
(whos-passwd . "Vem vill du ndra lsenord fr? (dig sjlv) ")
(old-passwd . "Mata in ditt nuvarande lsenord: ")
(new-passwd . "Mata in det nya lsenordet: ")
......@@ -403,7 +404,7 @@ du har l
(no-marked-texts . "Du har inga markerade inlgg.\n")
(no-marked-texts-mark .
"Du har inga markerade inlgg med markeringen %#1d.\n")
"Du har inga markerade inlgg med markeringstypen \"%#1s\".\n")
;;; For later
; (northward . "norrut")
......@@ -645,10 +646,6 @@ Meddelandet du f
(does-not-exist . "Detta kommando finns inte.")
(summary-line . "%=-8#1n%#2s%4#3d %[%#4@%#5:P%] %[%#6@%#7r%]\n")
(what-mark-to-list . "Vilken markering vill du lista? ")
(you-have-marks . "Du har %#1d inlgg markerade markerade med %#2d.\n")
(you-have-marks-all . "Du har %#1d markerade inlgg.\n")
;; Only people fixing bugs or receiving bug reports should
;; change these:
......@@ -824,8 +821,8 @@ Annat se \\[describe-mode] ---")
(line . " /1 rad/ ")
(lines ." /%#1d rader/ ")
(marked-by-you . "Markerad av dig (%#1d).\n")
(marked-by-you-and-others . "Markerad av dig (%#2d) och %#1?d%[ngon annan%]%[%#1d andra%].\n")
(marked-by-you . "Markerad av dig (typ: %#1s).\n")
(marked-by-you-and-others . "Markerad av dig (typ: %#2s) och %#1?d%[ngon annan%]%[%#1d andra%].\n")
(marked-by-several . "Markerad av %#1d person%#1?d%[%]%[er%].\n")
(time-yyyy-mm-dd-hh-mm . "%4#1d-%02#2d-%02#3d %02#4d:%02#5d")
......@@ -2396,7 +2393,11 @@ Du m
(a-string . "En text")
(some-string . "En slumpmssig text")
(unspecified . "Ospecificerat")
(symbolic-mark-association . "Associering")
(symbolic-mark-name . "Symboliskt namn: ")
(mark-type-to-assoc . "Markeringstyp att associera till: ")
;;
;; Misc doc strings
;;
......@@ -2700,10 +2701,19 @@ i servern. Annars sparas det i din .emacs.")
(kom-default-mark-doc . "\
Det markeringsvrde som anvnds fr nya markeringar. Om inget markerings-
vrde r valt frgar LysKOM varje gng man markerar en text. Vrden mellan
1 och 255 r tilltna.")
Den markeringstyp som anvnds fr nya markeringar. En markeringstyp r ett
heltal mellan 0 och 255 (inklusive). Om ingen defaultmarkeringstyp r vald
frgar LysKOM efter markeringstyp varje gng man markerar en text. Detta
kan anvndas fr att hlla isr olika sorters markeringar. Till exempel
kan man markera inlgg som innehller intressant information med ett visst
tal och inlgg som man ska komma ihg att kommentera vid ett senare
tillflle med ett annat tal.")
(kom-symbolic-marks-alist-doc . "\
Fr att slippa behva memorera vad man tnkte sig att de heltaliga
markeringstyperna ska innebra kan man definiera en lista med symboliska
markeringstyper. En symbolisk markeringstyp r en beskrivande strng som
associeras med en heltalig markeringstyp.")
(kom-reading-puts-comments-in-pointers-last-doc . "\
Bestmmer om kommentarslnkar visas fre eller efter en text. Normalt brukar
......@@ -3341,6 +3351,8 @@ i servern. Annars sparas det i din .emacs.")
(kom-mosaic-command-tag . "Kommando fr att starta NCSA Mosaic:")
(kom-netscape-command-tag . "Kommando fr att starta Netscape Navigator:")
(kom-symbolic-marks-alist-tag . "Symboliska markeringstyper:")
(kom-cite-string-tag . "Citatmarkering: ")
(kom-confirm-multiple-recipients-tag .
"Bekrfta multipla mottagare: ")
......
......@@ -209,6 +209,10 @@ The value of this variable is the file name on which to save new texts."
"*If non-nil (must be an integer), the user is not asked for type of mark."
server)
(def-kom-var kom-symbolic-marks-alist '(("Standard" . 100))
"*Assoc list which maps symbolic mark strings to mark numbers."
server)
(def-kom-var kom-reading-puts-comments-in-pointers-last t
"*If non-nil, the texts are shown with comment references at the end."
server
......
......@@ -278,11 +278,11 @@ Note that this function must not be called asynchronously."
(if is-marked-by-me
(if (= num-marks 1)
(lyskom-format-insert 'marked-by-you
(mark->mark-type
(mark->symbolic-mark-type
is-marked-by-me))
(lyskom-format-insert 'marked-by-you-and-others
(1- num-marks)
(mark->mark-type
(mark->symbolic-mark-type
is-marked-by-me)))
(lyskom-format-insert 'marked-by-several num-marks))))
......
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