diff options
| author | Thuna | 2022-11-23 04:14:36 +0100 |
|---|---|---|
| committer | Philip Kaludercic | 2023-05-04 10:06:32 +0200 |
| commit | 8eb6e33691d1c8e95e25e086e1b04669ea4fffdb (patch) | |
| tree | 4d9f0afbb4eb814021de4095d7524d1ff996c838 | |
| parent | 2901a3443c7daa15cbe01947ace3e0980e419028 (diff) | |
| download | emacs-8eb6e33691d1c8e95e25e086e1b04669ea4fffdb.tar.gz emacs-8eb6e33691d1c8e95e25e086e1b04669ea4fffdb.zip | |
Fix rcirc messages printing in the wrong place
* lisp/net/rcirc.el (rcirc-send-message): Print the message before
sending it to the server.
(rcirc-print): Get the time with subsecond precision.
* lisp/calendar/parse-time.el (parse-time-string
parse-iso8601-time-string): Accept optional second FORM arguments,
with the same meaning as in `decode-time'. Mention as such in the
docstring. (Bug#59501)
Copyright-paperwork-exempt: yes
| -rw-r--r-- | lisp/calendar/parse-time.el | 16 | ||||
| -rw-r--r-- | lisp/net/rcirc.el | 10 |
2 files changed, 15 insertions, 11 deletions
diff --git a/lisp/calendar/parse-time.el b/lisp/calendar/parse-time.el index 1b667a6852e..a62361121fc 100644 --- a/lisp/calendar/parse-time.el +++ b/lisp/calendar/parse-time.el | |||
| @@ -147,7 +147,7 @@ letters, digits, plus or minus signs or colons." | |||
| 147 | ;;;###autoload(put 'parse-time-rules 'risky-local-variable t) | 147 | ;;;###autoload(put 'parse-time-rules 'risky-local-variable t) |
| 148 | 148 | ||
| 149 | ;;;###autoload | 149 | ;;;###autoload |
| 150 | (defun parse-time-string (string) | 150 | (defun parse-time-string (string &optional form) |
| 151 | "Parse the time in STRING into (SEC MIN HOUR DAY MON YEAR DOW DST TZ). | 151 | "Parse the time in STRING into (SEC MIN HOUR DAY MON YEAR DOW DST TZ). |
| 152 | STRING should be an ISO 8601 time string, e.g., \"2020-01-15T16:12:21-08:00\", | 152 | STRING should be an ISO 8601 time string, e.g., \"2020-01-15T16:12:21-08:00\", |
| 153 | or something resembling an RFC 822 (or later) date-time, e.g., | 153 | or something resembling an RFC 822 (or later) date-time, e.g., |
| @@ -156,9 +156,11 @@ somewhat liberal in what format it accepts, and will attempt to | |||
| 156 | return a \"likely\" value even for somewhat malformed strings. | 156 | return a \"likely\" value even for somewhat malformed strings. |
| 157 | The values returned are identical to those of `decode-time', but | 157 | The values returned are identical to those of `decode-time', but |
| 158 | any unknown values other than DST are returned as nil, and an | 158 | any unknown values other than DST are returned as nil, and an |
| 159 | unknown DST value is returned as -1." | 159 | unknown DST value is returned as -1. |
| 160 | |||
| 161 | See `decode-time' for the meaning of FORM." | ||
| 160 | (condition-case () | 162 | (condition-case () |
| 161 | (iso8601-parse string) | 163 | (iso8601-parse string form) |
| 162 | (wrong-type-argument | 164 | (wrong-type-argument |
| 163 | (let ((time (list nil nil nil nil nil nil nil -1 nil)) | 165 | (let ((time (list nil nil nil nil nil nil nil -1 nil)) |
| 164 | (temp (parse-time-tokenize (downcase string)))) | 166 | (temp (parse-time-tokenize (downcase string)))) |
| @@ -199,12 +201,14 @@ unknown DST value is returned as -1." | |||
| 199 | (setf (nth (pop slots) time) new-val)))))))) | 201 | (setf (nth (pop slots) time) new-val)))))))) |
| 200 | time)))) | 202 | time)))) |
| 201 | 203 | ||
| 202 | (defun parse-iso8601-time-string (date-string) | 204 | (defun parse-iso8601-time-string (date-string &optional form) |
| 203 | "Parse an ISO 8601 time string, such as \"2020-01-15T16:12:21-08:00\". | 205 | "Parse an ISO 8601 time string, such as \"2020-01-15T16:12:21-08:00\". |
| 204 | Fall back on parsing something resembling an RFC 822 (or later) date-time. | 206 | Fall back on parsing something resembling an RFC 822 (or later) date-time. |
| 205 | This function is like `parse-time-string' except that it returns | 207 | This function is like `parse-time-string' except that it returns |
| 206 | a Lisp timestamp when successful." | 208 | a Lisp timestamp when successful. |
| 207 | (when-let ((time (parse-time-string date-string))) | 209 | |
| 210 | See `decode-time' for the meaning of FORM." | ||
| 211 | (when-let ((time (parse-time-string date-string form))) | ||
| 208 | (encode-time time))) | 212 | (encode-time time))) |
| 209 | 213 | ||
| 210 | (provide 'parse-time) | 214 | (provide 'parse-time) |
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 97a314eb8ab..937f4046adb 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el | |||
| @@ -1233,9 +1233,9 @@ If SILENT is non-nil, do not print the message in any irc buffer." | |||
| 1233 | (let ((response (if noticep "NOTICE" "PRIVMSG"))) | 1233 | (let ((response (if noticep "NOTICE" "PRIVMSG"))) |
| 1234 | (rcirc-get-buffer-create process target) | 1234 | (rcirc-get-buffer-create process target) |
| 1235 | (dolist (msg (rcirc-split-message message)) | 1235 | (dolist (msg (rcirc-split-message message)) |
| 1236 | (rcirc-send-string process response target : msg) | ||
| 1237 | (unless silent | 1236 | (unless silent |
| 1238 | (rcirc-print process (rcirc-nick process) response target msg))))) | 1237 | (rcirc-print process (rcirc-nick process) response target msg)) |
| 1238 | (rcirc-send-string process response target : msg)))) | ||
| 1239 | 1239 | ||
| 1240 | (defvar-local rcirc-input-ring nil | 1240 | (defvar-local rcirc-input-ring nil |
| 1241 | "Ring object for input.") | 1241 | "Ring object for input.") |
| @@ -2034,7 +2034,7 @@ connection." | |||
| 2034 | (not (string= sender (rcirc-nick process)))) | 2034 | (not (string= sender (rcirc-nick process)))) |
| 2035 | (let* ((buffer (rcirc-target-buffer process sender response target text)) | 2035 | (let* ((buffer (rcirc-target-buffer process sender response target text)) |
| 2036 | (time (if-let ((time (rcirc-get-tag "time"))) | 2036 | (time (if-let ((time (rcirc-get-tag "time"))) |
| 2037 | (parse-iso8601-time-string time) | 2037 | (parse-iso8601-time-string time t) |
| 2038 | (current-time))) | 2038 | (current-time))) |
| 2039 | (inhibit-read-only t)) | 2039 | (inhibit-read-only t)) |
| 2040 | (with-current-buffer buffer | 2040 | (with-current-buffer buffer |
| @@ -2204,7 +2204,7 @@ The message is logged in `rcirc-log', and is later written to | |||
| 2204 | disk. PROCESS is the process object for the current connection." | 2204 | disk. PROCESS is the process object for the current connection." |
| 2205 | (let ((filename (funcall rcirc-log-filename-function process target)) | 2205 | (let ((filename (funcall rcirc-log-filename-function process target)) |
| 2206 | (time (and-let* ((time (rcirc-get-tag "time"))) | 2206 | (time (and-let* ((time (rcirc-get-tag "time"))) |
| 2207 | (parse-iso8601-time-string time)))) | 2207 | (parse-iso8601-time-string time t)))) |
| 2208 | (unless (null filename) | 2208 | (unless (null filename) |
| 2209 | (let ((cell (assoc-string filename rcirc-log-alist)) | 2209 | (let ((cell (assoc-string filename rcirc-log-alist)) |
| 2210 | (line (concat (format-time-string rcirc-time-format time) | 2210 | (line (concat (format-time-string rcirc-time-format time) |
| @@ -2996,7 +2996,7 @@ If ARG is given, opens the URL in a new browser window." | |||
| 2996 | "Insert a timestamp." | 2996 | "Insert a timestamp." |
| 2997 | (goto-char (point-min)) | 2997 | (goto-char (point-min)) |
| 2998 | (let ((time (and-let* ((time (rcirc-get-tag "time"))) | 2998 | (let ((time (and-let* ((time (rcirc-get-tag "time"))) |
| 2999 | (parse-iso8601-time-string time)))) | 2999 | (parse-iso8601-time-string time t)))) |
| 3000 | (insert (rcirc-facify (format-time-string rcirc-time-format time) | 3000 | (insert (rcirc-facify (format-time-string rcirc-time-format time) |
| 3001 | 'rcirc-timestamp)))) | 3001 | 'rcirc-timestamp)))) |
| 3002 | 3002 | ||