Commit 8c6905d4 authored by Pontus Freyhult's avatar Pontus Freyhult
Browse files

Implement session naming and list sessions, fixes bug 279.

parent 9494e77e
2004-11-11 Pontus Freyhult <pont@soua.net>
Fix bug 279, implement list sessions (with extras):
* vars.el.in (kom-session-nickname): New variable.
(mode-line-server-name): New variable.
* english-strings.el, swedish-strings.el (local):
Added session-list-unreads-in-conf.
(global): Added kom-list-sessions.
(lyskom-{sv,en}-list-prefix): Bound kom-list-sessions to l k.
(lyskom-custom-strings): Added automatic-session-name and
given-session-name. Added kom-session-nickname-doc and
kom-session-nickname-tag.
* startup.el (kom-start-anew): Cosmetical if not -> unless.
Call lyskom-mode-name-from-host after variables are read from
server.
* startup.el (lyskom-mode): Use mode-line-server-name in
mode-line-buffer-identification.
* option-edit.el (lyskom-customize-buffer-format): Added
kom-session-nickname.
(lyskom-custom-variables): Dito.
* lyskom-rest.el (lyskom-set-mode-line): Call
lyskom-mode-name-from-host.
(lyskom-session-nickname): New function.
(lyskom-mode-name-from-host): Use lyskom-session-nickname, update
mode-line-server-name.
* commands2.el (kom-list-sessions): New command.
Handle UTF-8 postings created by Rasmus Stens Weblatte:
* mime.el (lyskom-mime-decode-content-type): Allow whitespace
after ";" in content-types.
......
......@@ -748,6 +748,57 @@ send. If DONTSHOW is non-nil, don't display the sent message."
(def-kom-command kom-list-sessions ()
"List current LysKOM sessions and unread messages for each sessions."
(interactive)
(let ((total-letters 0)
(total-texts 0)
(total-confs 0)
(buflist (buffer-list))
(session-list nil))
(lyskom-save-excursion
(lyskom-traverse buf buflist
(when (lyskom-buffer-p buf)
(set-buffer buf)
(let ((letters 0)
(texts 0)
(confs 0))
(lyskom-traverse entry (lyskom-list-news)
(unless (zerop (car entry)) ; Ignore confs with 0 unread
(setq texts (+ (car entry)
texts))
(setq confs (1+ confs))
(when (= (conf-stat->conf-no (cdr entry))
lyskom-pers-no)
(setq letters (+ (car entry)
letters)))))
(setq total-texts (+ texts
total-texts))
(setq total-letters (+ letters
total-letters))
(setq total-confs (+ confs
total-confs))
(setq session-list (append (list (list (lyskom-session-nickname)
(lyskom-format "%#1P" lyskom-pers-no)
texts
letters
confs
kom-server-priority))
session-list))))))
(sort session-list (lambda (s1 s2)
(< (nth 5 s1)
(nth 5 s2))))
(lyskom-traverse session session-list
(lyskom-format-insert 'session-list-unreads-in-confs
(nth 0 session)
(nth 3 session)
(nth 2 session)
(nth 4 session)
))))
;;; ================================================================
;;; Lista Nyheter - List News
......
......@@ -770,6 +770,9 @@ The message you were sending to %#1M was:
(lp--only-last . "Number of text to read: ")
(session-list-unreads-in-confs .
"You have %#2?z%[%#2d unread letter%#2?d%[%]%[s%], in total %]%[%]%#3d unread text%#3?d%[%]%[s%] in %#4d conference%#4?d%[%]%[s%] in %#1s.\n")
(you-have-unreads . "You have %#1d unread text%#1?d%[%]%[s%] in %#2M\n")
(you-have-unreads-special . "You have %#1d uncommented text%#1?d%[%]%[s%] in %#2M\n")
(you-have-no-unreads . "You have read everything in %#1M\n")
......@@ -2134,6 +2137,7 @@ Change privileges for %#1P (%#1p)...")
(kom-list-conferences . "List conferences")
(kom-list-persons . "List users")
(kom-list-news . "List news")
(kom-list-sessions . "List sessions")
(kom-list-re . "List (using) regexps")
(kom-membership . "List memberships")
;; (kom-list-marks . "List marks")
......@@ -2676,6 +2680,7 @@ Change privileges for %#1P (%#1p)...")
(define-key lyskom-en-mode-map (kbd "R") 'kom-recover)
(define-key lyskom-en-mode-map (kbd "T") 'kom-display-time)
(define-key lyskom-en-list-prefix (kbd "k") 'kom-list-sessions)
(define-key lyskom-en-list-prefix (kbd "m") 'kom-list-marks)
(define-key lyskom-en-list-prefix (kbd "c") 'kom-list-conferences)
(define-key lyskom-en-list-prefix (kbd "n") 'kom-list-news)
......@@ -3081,6 +3086,9 @@ Select whether to execute command or keyboard macro.")
(discard-messages . "Nowhere - discard them")
(in-named-buffer . "In a named buffer:")
(automatic-session-name . "Automatic")
(given-session-name . "Use specified:")
(everybody-rcpt . "Everybody ")
(group-rcpt . "The recipient of the last group message ")
(sender-rcpt . "The sender of the most recent message ")
......@@ -3989,6 +3997,10 @@ up menus.")
This text is shown in the list of users when you have finished reading
everything.")
(kom-session-nickname-doc . "\
How the session name is determined. This is the name displayed in the
mode line and by List sessions.")
(kom-server-priority-doc . "\
Priority of this LysKOM session. The client can prompt you to go to
a session with unread texts when a text arrives in a session with a
......@@ -4426,6 +4438,7 @@ up menus.")
(kom-show-personal-message-date-tag . "Show date and time of messages:")
(kom-w3-simplify-body-tag . "Display HTML without document colors:")
(kom-mercial-tag . "Text to display when all is read:")
(kom-session-nickname-tag . "How session name is determined:")
(kom-server-priority-tag . "Session priority:")
(kom-server-priority-breaks-tag . "Prompt to go to next LysKOM:")
(kom-complete-numbers-before-names-tag . "Read conference numbers before names:")
......
......@@ -956,7 +956,9 @@ CONF can be a a conf-stat or a string."
(if (zerop letters)
(lyskom-remove-unread-buffer lyskom-buffer t)
(lyskom-add-unread-buffer lyskom-buffer t))
(force-mode-line-update)))
(lyskom-mode-name-from-host)
(force-mode-line-update)))
......@@ -4208,16 +4210,23 @@ One parameter - the prompt string."
(message "")
input-string))
(defun lyskom-session-nickname ()
"Return the nickname to use for this LysKOM session."
(if kom-session-nickname
kom-session-nickname
(let ((server (process-name (get-buffer-process (current-buffer)))))
(or (cdr (assoc server
(append kom-server-aliases
kom-builtin-server-aliases)))
(format "LysKOM(%s)" server)))))
;;; This really is a strange thing to do but...
;;
(defun lyskom-mode-name-from-host ()
"Calculate what to identify the buffer with."
(let ((server (process-name (get-buffer-process (current-buffer)))))
(or (cdr (assoc server
(append kom-server-aliases
kom-builtin-server-aliases)))
(format "LysKOM(%s)" server))))
(setq mode-line-server-name
(lyskom-session-nickname)))
(defvar lyskom-modeline-keymap nil)
(if lyskom-modeline-keymap
......
......@@ -190,6 +190,7 @@
[kom-review-priority]
[kom-server-priority]
[kom-server-priority-breaks]
[kom-session-nickname]
"\n"
[kom-read-depth-first]
[kom-reading-puts-comments-in-pointers-last]
......@@ -563,7 +564,6 @@ All key bindings:
(defun lyskom-custom-string (s)
(lyskom-get-string s 'lyskom-custom-strings))
(defvar lyskom-custom-variables-missing '(kom-permanent-filter-list
kom-quit-hook
lyskom-last-known-conf-no
......@@ -671,6 +671,11 @@ All key bindings:
(const (after-conf-letters-server-break after-conf-letters))
(const (when-done-server-break when-done))
(const (no-server-break nil)))))
(kom-session-nickname (choice ((const (automatic-session-name nil))
(string nil
:tag given-session-name
:help-echo select-buffer))))
(kom-login-hook (repeat (command nil :tag command)
:indent 4))
(kom-do-when-done (repeat (choice ((command nil :tag command)
......
......@@ -632,9 +632,13 @@ shown to other users."
(unless lyskom-dont-read-user-area
(setq ignored-user-area-vars (lyskom-read-options)))
(if (not kom-remember-password)
(unless kom-remember-password
(setq lyskom-default-password nil))
;Update mode-line string if needed (as early as possible).
(lyskom-mode-name-from-host)
(when (or session-priority kom-default-session-priority)
(setq lyskom-session-priority
(or session-priority kom-default-session-priority)))
......@@ -901,8 +905,10 @@ Functions and variables beginning with lyskom- are not intended for the user
to see, set of call."
(interactive)
(lyskom-clear-vars)
(lyskom-mode-name-from-host)
(setq mode-line-buffer-identification
(list (concat (lyskom-mode-name-from-host) ": ") 'mode-line-conf-name))
; Must start with a string to be handled properly, it seems.
(list "" 'mode-line-server-name ": " 'mode-line-conf-name))
(setq major-mode 'lyskom-mode)
(setq mode-name "LysKOM")
......
......@@ -774,6 +774,9 @@ Meddelandet du f
(lp--only-last . "Antal texter att lsa: ")
(session-list-unreads-in-confs .
"Du har %#2?z%[%#2d olsta brev och totalt %]%[%]%#3d olst%#3?d%[%]%[a%] i %#4d mte%#4?d%[%]%[n%] i %#1s.\n")
(you-have-unreads . "Du har %#1d olst%#1?d%[%]%[a%] inlgg i %#2M\n")
(you-have-unreads-special . "Du har %#1d okommentera%#1?d%[t%]%[de%] inlgg i %#2M\n")
(you-have-no-unreads . "Du har inget olst i %#1M\n")
......@@ -2161,6 +2164,7 @@ Nuvarande r
(kom-list-conferences . "Lista mten")
(kom-list-persons . "Lista personer")
(kom-list-news . "Lista nyheter")
(kom-list-sessions . "Lista sessioner")
(kom-list-re . "Lista (med) regexpar")
(kom-membership . "Lista medlemskap")
(kom-postpone . "Uppskjuta lsning")
......@@ -2748,6 +2752,7 @@ Nuvarande r
(define-key lyskom-sv-next-prefix (kbd "l") 'kom-next-kom)
(define-key lyskom-sv-next-prefix (kbd "o") 'kom-next-unread-kom)
(define-key lyskom-sv-list-prefix (kbd "k") 'kom-list-sessions)
(define-key lyskom-sv-list-prefix (kbd "M") 'kom-list-marks)
(define-key lyskom-sv-list-prefix (kbd "m") 'kom-list-conferences)
(define-key lyskom-sv-list-prefix (kbd "n") 'kom-list-news)
......@@ -3185,6 +3190,9 @@ Nuvarande r
(discard-messages . "Ingenstans ")
(in-named-buffer . "I namngiven buffert:")
(automatic-session-name . "Automatiskt")
(given-session-name . "Anvnd angivet:")
(everybody-rcpt . "Alla ")
(group-rcpt . "Senaste gruppmeddelandes mottagare")
(sender-rcpt . "Senaste meddelandes avsndare ")
......@@ -4099,6 +4107,10 @@ ta fram menyer.")
(kom-mercial-doc . "\
Denna text visas i vilkalistan d du har lst frdigt alla mten.")
(kom-session-nickname-doc . "\
Hur sessionsnamn bestms. Detta r det namn som visas i mode-raden och
av Lista sessioner.")
(kom-server-priority-doc . "\
Prioritet fr sessionen. Sessioner med hg prioritet kan avbryta andra
sessioner, beroende p instllningen av YYY.")
......@@ -4538,7 +4550,8 @@ ta fram menyer.")
(kom-show-personal-message-date-tag . "Visa datum fr alla meddelanden:")
(kom-w3-simplify-body-tag . "Visa HTML utan standardfrger:")
(kom-mercial-tag . "Text nr allt r utlst:")
(kom-server-priority-tag . "Sessionsprioritet:")
(kom-session-nickname-tag . "Hur bestms sessionsnamn:")
(kom-server-priority-tag . "Sessionsprioritet:")
(kom-server-priority-breaks-tag . "Byt till LysKOM med olsta:")
(kom-complete-numbers-before-names-tag . "Ls mtesnummer fre mtesnamn:")
(kom-keep-alive-interval-tag . "Intervall fr hll frbindelsen igng:")
......
......@@ -1601,6 +1601,16 @@ See `kom-server-priority' for information on setting the server
priority."
server)
(def-kom-var kom-session-nickname nil
"**Nickname for the current LysKOM session.
This variable contains the name of the current LysKOM session (a string)
or `nil'. If set, it will be used as the nickname for this LysKOM session.
See also `kom-server-aliases' and `kom-builtin-server-aliases'."
server)
(def-kom-var kom-view-text-hook nil
"**Hook that is called before a text is shown.
......@@ -4539,6 +4549,10 @@ environment variable for this, but it shouldn't be used if there is."
"Conf name that is present on the mode-line."
local)
(def-kom-var mode-line-server-name nil
"Server name that is present on the mode-line."
local)
;;; ============================================================
;;; History lists
......
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