diff options
| author | Eli Zaretskii | 2005-11-19 13:12:05 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2005-11-19 13:12:05 +0000 |
| commit | ad8121fe5d0077621b93eabdb294834591d0475d (patch) | |
| tree | a9cf918cbf0a3a28b6fdbae5803672340c7fa05c | |
| parent | a4b1de6e8d435b66bcb5217642ed80404c7d04f9 (diff) | |
| download | emacs-ad8121fe5d0077621b93eabdb294834591d0475d.tar.gz emacs-ad8121fe5d0077621b93eabdb294834591d0475d.zip | |
(rcirc-mangle-text): Add bold face property without replacing existing
properties.
(rcirc-my-nick, rcirc-other-nick, rcirc-server)
(rcirc-nick-in-message, rcirc-prompt): Use min-colors and remove tty specs.
(rcirc-server-prefix, rcirc-server): New faces.
(rcirc-url-regexp): Generate with rx macro.
(rcirc-last-server-message-time): New variable.
(rcirc-filter): Record time of last message.
(rcirc-keepalive): Kill processes that did not send a message
since the last ping.
(rcirc-mode): Give rcirc-topic a local binding here.
| -rw-r--r-- | lisp/ChangeLog | 15 | ||||
| -rw-r--r-- | lisp/net/rcirc.el | 171 |
2 files changed, 129 insertions, 57 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 04d341fbfd9..7872c490a0b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2005-11-16 Ryan Yeske <rcyeske@gmail.com> | ||
| 2 | |||
| 3 | * net/rcirc.el (rcirc-mangle-text): Add bold face property without | ||
| 4 | replacing existing properties. | ||
| 5 | (rcirc-my-nick, rcirc-other-nick, rcirc-server) | ||
| 6 | (rcirc-nick-in-message, rcirc-prompt): Use min-colors and remove | ||
| 7 | tty specs. | ||
| 8 | (rcirc-server-prefix, rcirc-server): New faces. | ||
| 9 | (rcirc-url-regexp): Generate with rx macro. | ||
| 10 | (rcirc-last-server-message-time): New variable. | ||
| 11 | (rcirc-filter): Record time of last message. | ||
| 12 | (rcirc-keepalive): Kill processes that did not send a message | ||
| 13 | since the last ping. | ||
| 14 | (rcirc-mode): Give rcirc-topic a local binding here. | ||
| 15 | |||
| 1 | 2005-11-19 Michael Cadilhac <michael.cadilhac@lrde.org> (tiny change) | 16 | 2005-11-19 Michael Cadilhac <michael.cadilhac@lrde.org> (tiny change) |
| 2 | 17 | ||
| 3 | * subr.el (read-passwd): Fontify the prompt as we do with other | 18 | * subr.el (read-passwd): Fontify the prompt as we do with other |
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 7df8e5a5603..93476a0997e 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el | |||
| @@ -257,7 +257,7 @@ respectively." | |||
| 257 | (defvar rcirc-process-output nil) | 257 | (defvar rcirc-process-output nil) |
| 258 | (defvar rcirc-topic nil) | 258 | (defvar rcirc-topic nil) |
| 259 | (defvar rcirc-keepalive-timer nil) | 259 | (defvar rcirc-keepalive-timer nil) |
| 260 | (make-variable-buffer-local 'rcirc-topic) | 260 | (defvar rcirc-last-server-message-time nil) |
| 261 | (defun rcirc-connect (server port nick user-name full-name startup-channels) | 261 | (defun rcirc-connect (server port nick user-name full-name startup-channels) |
| 262 | "Return a connection to SERVER on PORT. | 262 | "Return a connection to SERVER on PORT. |
| 263 | 263 | ||
| @@ -290,6 +290,8 @@ STARTUP-CHANNELS will automatically be joined on startup." | |||
| 290 | (setq rcirc-process-output nil) | 290 | (setq rcirc-process-output nil) |
| 291 | (make-local-variable 'rcirc-startup-channels) | 291 | (make-local-variable 'rcirc-startup-channels) |
| 292 | (setq rcirc-startup-channels startup-channels) | 292 | (setq rcirc-startup-channels startup-channels) |
| 293 | (make-local-variable 'rcirc-last-server-message-time) | ||
| 294 | (setq rcirc-last-server-message-time (current-time)) | ||
| 293 | 295 | ||
| 294 | ;; identify | 296 | ;; identify |
| 295 | (rcirc-send-string process (concat "NICK " nick)) | 297 | (rcirc-send-string process (concat "NICK " nick)) |
| @@ -313,11 +315,16 @@ STARTUP-CHANNELS will automatically be joined on startup." | |||
| 313 | ,@body)) | 315 | ,@body)) |
| 314 | 316 | ||
| 315 | (defun rcirc-keepalive () | 317 | (defun rcirc-keepalive () |
| 316 | "Send keep alive pings to active rcirc processes." | 318 | "Send keep alive pings to active rcirc processes. |
| 319 | Kill processes that have not received a server message since the | ||
| 320 | last ping." | ||
| 317 | (if (rcirc-process-list) | 321 | (if (rcirc-process-list) |
| 318 | (mapc (lambda (process) | 322 | (mapc (lambda (process) |
| 319 | (with-rcirc-process-buffer process | 323 | (with-rcirc-process-buffer process |
| 320 | (rcirc-send-string process (concat "PING " rcirc-server)))) | 324 | (if (> (cadr (time-since rcirc-last-server-message-time)) |
| 325 | rcirc-keepalive-seconds) | ||
| 326 | (kill-process process) | ||
| 327 | (rcirc-send-string process (concat "PING " rcirc-server))))) | ||
| 321 | (rcirc-process-list)) | 328 | (rcirc-process-list)) |
| 322 | (cancel-timer rcirc-keepalive-timer) | 329 | (cancel-timer rcirc-keepalive-timer) |
| 323 | (setq rcirc-keepalive-timer nil))) | 330 | (setq rcirc-keepalive-timer nil))) |
| @@ -380,6 +387,7 @@ Function is called with PROCESS COMMAND SENDER ARGS and LINE.") | |||
| 380 | "Called when PROCESS receives OUTPUT." | 387 | "Called when PROCESS receives OUTPUT." |
| 381 | (rcirc-debug process output) | 388 | (rcirc-debug process output) |
| 382 | (with-rcirc-process-buffer process | 389 | (with-rcirc-process-buffer process |
| 390 | (setq rcirc-last-server-message-time (current-time)) | ||
| 383 | (setq rcirc-process-output (concat rcirc-process-output output)) | 391 | (setq rcirc-process-output (concat rcirc-process-output output)) |
| 384 | (when (= (aref rcirc-process-output | 392 | (when (= (aref rcirc-process-output |
| 385 | (1- (length rcirc-process-output))) ?\n) | 393 | (1- (length rcirc-process-output))) ?\n) |
| @@ -582,6 +590,8 @@ If buffer is nil, return the target of the current buffer." | |||
| 582 | (setq rcirc-process process) | 590 | (setq rcirc-process process) |
| 583 | (make-local-variable 'rcirc-target) | 591 | (make-local-variable 'rcirc-target) |
| 584 | (setq rcirc-target target) | 592 | (setq rcirc-target target) |
| 593 | (make-local-variable 'rcirc-topic) | ||
| 594 | (setq rcirc-topic nil) | ||
| 585 | 595 | ||
| 586 | (make-local-variable 'rcirc-short-buffer-name) | 596 | (make-local-variable 'rcirc-short-buffer-name) |
| 587 | (setq rcirc-short-buffer-name nil) | 597 | (setq rcirc-short-buffer-name nil) |
| @@ -850,8 +860,8 @@ Create the buffer if it doesn't exist." | |||
| 850 | (process-buffer process)))) | 860 | (process-buffer process)))) |
| 851 | 861 | ||
| 852 | (defun rcirc-format-response-string (process sender response target text) | 862 | (defun rcirc-format-response-string (process sender response target text) |
| 853 | (concat (when rcirc-time-format | 863 | (concat (rcirc-facify (format-time-string rcirc-time-format (current-time)) |
| 854 | (format-time-string rcirc-time-format (current-time))) | 864 | 'rcirc-timestamp) |
| 855 | (cond ((or (string= response "PRIVMSG") | 865 | (cond ((or (string= response "PRIVMSG") |
| 856 | (string= response "NOTICE") | 866 | (string= response "NOTICE") |
| 857 | (string= response "ACTION")) | 867 | (string= response "ACTION")) |
| @@ -880,14 +890,15 @@ Create the buffer if it doesn't exist." | |||
| 880 | (t | 890 | (t |
| 881 | (rcirc-mangle-text | 891 | (rcirc-mangle-text |
| 882 | process | 892 | process |
| 883 | (rcirc-facify | 893 | (concat (rcirc-facify "*** " 'rcirc-server-prefix) |
| 884 | (concat "*** " | 894 | (rcirc-facify |
| 885 | (when (not (string= sender (rcirc-server process))) | 895 | (concat |
| 886 | (concat (rcirc-user-nick sender) " ")) | 896 | (when (not (string= sender (rcirc-server process))) |
| 887 | (when (zerop (string-to-number response)) | 897 | (concat (rcirc-user-nick sender) " ")) |
| 888 | (concat response " ")) | 898 | (when (zerop (string-to-number response)) |
| 889 | text) | 899 | (concat response " ")) |
| 890 | 'rcirc-server)))))) | 900 | text) |
| 901 | 'rcirc-server))))))) | ||
| 891 | 902 | ||
| 892 | (defvar rcirc-activity-type nil) | 903 | (defvar rcirc-activity-type nil) |
| 893 | (make-variable-buffer-local 'rcirc-activity-type) | 904 | (make-variable-buffer-local 'rcirc-activity-type) |
| @@ -1446,11 +1457,16 @@ With a prefix arg, prompt for new topic." | |||
| 1446 | "Return a copy of STRING with FACE property added." | 1457 | "Return a copy of STRING with FACE property added." |
| 1447 | (propertize (or string "") 'face face 'rear-nonsticky t)) | 1458 | (propertize (or string "") 'face face 'rear-nonsticky t)) |
| 1448 | 1459 | ||
| 1449 | ;; shy grouping must be used within this regexp | ||
| 1450 | (defvar rcirc-url-regexp | 1460 | (defvar rcirc-url-regexp |
| 1451 | "\\b\\(?:\\(?:www\\.\\|\\(?:s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\ | 1461 | (rx word-boundary |
| 1452 | \\|wais\\|mailto\\):\\)\\(?://[-a-zA-Z0-9_.]+:[0-9]*\\)?\\(?:[-a-zA-Z0-9_=!?#$\ | 1462 | (or "www." |
| 1453 | @~`%&*+|\\/:;.,]\\|\\w\\)+\\(?:[-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)" | 1463 | (and (or "http" "https" "ftp" "file" "gopher" "news" "telnet" "wais" |
| 1464 | "mailto") | ||
| 1465 | "://" | ||
| 1466 | (1+ (char "a-zA-Z0-9_.")) | ||
| 1467 | (optional ":" (1+ (char "0-9"))))) | ||
| 1468 | (1+ (char "-a-zA-Z0-9_=!?#$\@~`%&*+|\\/:;.,")) | ||
| 1469 | (char "-a-zA-Z0-9_=!?#$\@~`%&*+|\\/:;")) | ||
| 1454 | "Regexp matching URL's. Set to nil to disable URL features in rcirc.") | 1470 | "Regexp matching URL's. Set to nil to disable URL features in rcirc.") |
| 1455 | 1471 | ||
| 1456 | (defun rcirc-browse-url (&optional arg) | 1472 | (defun rcirc-browse-url (&optional arg) |
| @@ -1498,14 +1514,21 @@ FUNCTION takes 3 arguments, MATCH-START, MATCH-END, and STRING." | |||
| 1498 | "Return TEXT with properties added based on various patterns." | 1514 | "Return TEXT with properties added based on various patterns." |
| 1499 | ;; ^B | 1515 | ;; ^B |
| 1500 | (setq text | 1516 | (setq text |
| 1501 | (rcirc-map-regexp (lambda (start end string) | 1517 | (rcirc-map-regexp |
| 1502 | (add-text-properties | 1518 | (lambda (start end string) |
| 1503 | start end | 1519 | (let ((orig-face (get-text-property start 'face string))) |
| 1504 | (list 'face 'bold 'rear-nonsticky t) | 1520 | (add-text-properties |
| 1505 | string)) | 1521 | start end |
| 1506 | ".*?" | 1522 | (list 'face (if (listp orig-face) |
| 1507 | text)) | 1523 | (append orig-face |
| 1508 | (while (string-match "\\(.*\\)[]\\(.*\\)" text) ; deal with | 1524 | (list 'bold)) |
| 1525 | (list orig-face 'bold)) | ||
| 1526 | 'rear-nonsticky t) | ||
| 1527 | string))) | ||
| 1528 | ".*?" | ||
| 1529 | text)) | ||
| 1530 | ;; TODO: deal with ^_ and ^C colors sequences | ||
| 1531 | (while (string-match "\\(.*\\)[]\\(.*\\)" text) | ||
| 1509 | (setq text (concat (match-string 1 text) | 1532 | (setq text (concat (match-string 1 text) |
| 1510 | (match-string 2 text)))) | 1533 | (match-string 2 text)))) |
| 1511 | ;; my nick | 1534 | ;; my nick |
| @@ -1527,7 +1550,10 @@ FUNCTION takes 3 arguments, MATCH-START, MATCH-END, and STRING." | |||
| 1527 | (lambda (start end string) | 1550 | (lambda (start end string) |
| 1528 | (let ((orig-face (get-text-property start 'face string))) | 1551 | (let ((orig-face (get-text-property start 'face string))) |
| 1529 | (add-text-properties start end | 1552 | (add-text-properties start end |
| 1530 | (list 'face (list orig-face 'bold) | 1553 | (list 'face (if (listp orig-face) |
| 1554 | (append orig-face | ||
| 1555 | (list 'bold)) | ||
| 1556 | (list orig-face 'bold)) | ||
| 1531 | 'rear-nonsticky t | 1557 | 'rear-nonsticky t |
| 1532 | 'mouse-face 'highlight | 1558 | 'mouse-face 'highlight |
| 1533 | 'keymap rcirc-browse-url-map) | 1559 | 'keymap rcirc-browse-url-map) |
| @@ -1836,51 +1862,82 @@ Passwords are read from `rcirc-authinfo-file-name' (which see)." | |||
| 1836 | :group 'rcirc | 1862 | :group 'rcirc |
| 1837 | :group 'faces) | 1863 | :group 'faces) |
| 1838 | 1864 | ||
| 1839 | (defface rcirc-my-nick | 1865 | (defface rcirc-my-nick ; font-lock-function-name-face |
| 1840 | '((((type tty) (class color)) (:foreground "blue" :weight bold)) | 1866 | '((((class color) (min-colors 88) (background light)) (:foreground "Blue1")) |
| 1841 | (((class color) (background light)) (:foreground "Blue")) | 1867 | (((class color) (min-colors 88) (background dark)) (:foreground "LightSkyBlue")) |
| 1842 | (((class color) (background dark)) (:foreground "LightSkyBlue")) | 1868 | (((class color) (min-colors 16) (background light)) (:foreground "Blue")) |
| 1843 | (t (:inverse-video t :bold t))) | 1869 | (((class color) (min-colors 16) (background dark)) (:foreground "LightSkyBlue")) |
| 1870 | (((class color) (min-colors 8)) (:foreground "blue" :weight bold)) | ||
| 1871 | (t (:inverse-video t :weight bold))) | ||
| 1844 | "The face used to highlight my messages." | 1872 | "The face used to highlight my messages." |
| 1845 | :group 'rcirc-faces) | 1873 | :group 'rcirc-faces) |
| 1846 | 1874 | ||
| 1847 | (defface rcirc-other-nick | 1875 | (defface rcirc-other-nick ; font-lock-variable-name-face |
| 1848 | '((((type tty) (class color)) (:foreground "yellow" :weight light)) | 1876 | '((((class grayscale) (background light)) |
| 1849 | (((class grayscale) (background light)) | 1877 | (:foreground "Gray90" :weight bold :slant italic)) |
| 1850 | (:foreground "Gray90" :bold t :italic t)) | ||
| 1851 | (((class grayscale) (background dark)) | 1878 | (((class grayscale) (background dark)) |
| 1852 | (:foreground "DimGray" :bold t :italic t)) | 1879 | (:foreground "DimGray" :weight bold :slant italic)) |
| 1853 | (((class color) (background light)) (:foreground "DarkGoldenrod")) | 1880 | (((class color) (min-colors 88) (background light)) (:foreground "DarkGoldenrod")) |
| 1854 | (((class color) (background dark)) (:foreground "LightGoldenrod")) | 1881 | (((class color) (min-colors 88) (background dark)) (:foreground "LightGoldenrod")) |
| 1855 | (t (:bold t :italic t))) | 1882 | (((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod")) |
| 1883 | (((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod")) | ||
| 1884 | (((class color) (min-colors 8)) (:foreground "yellow" :weight light)) | ||
| 1885 | (t (:weight bold :slant italic))) | ||
| 1856 | "The face used to highlight other messages." | 1886 | "The face used to highlight other messages." |
| 1857 | :group 'rcirc-faces) | 1887 | :group 'rcirc-faces) |
| 1858 | 1888 | ||
| 1859 | (defface rcirc-server | 1889 | (defface rcirc-server ; font-lock-comment-face |
| 1860 | '((((type tty pc) (class color) (background light)) (:foreground "red")) | 1890 | '((((class grayscale) (background light)) |
| 1861 | (((type tty pc) (class color) (background dark)) (:foreground "red1")) | 1891 | (:foreground "DimGray" :weight bold :slant italic)) |
| 1862 | (((class grayscale) (background light)) | ||
| 1863 | (:foreground "DimGray" :bold t :italic t)) | ||
| 1864 | (((class grayscale) (background dark)) | 1892 | (((class grayscale) (background dark)) |
| 1865 | (:foreground "LightGray" :bold t :italic t)) | 1893 | (:foreground "LightGray" :weight bold :slant italic)) |
| 1866 | (((class color) (background light)) (:foreground "gray40")) | 1894 | (((class color) (min-colors 88) (background light)) |
| 1867 | (((class color) (background dark)) (:foreground "chocolate1")) | 1895 | (:foreground "Firebrick")) |
| 1868 | (t (:bold t :italic t))) | 1896 | (((class color) (min-colors 88) (background dark)) |
| 1897 | (:foreground "chocolate1")) | ||
| 1898 | (((class color) (min-colors 16) (background light)) | ||
| 1899 | (:foreground "red")) | ||
| 1900 | (((class color) (min-colors 16) (background dark)) | ||
| 1901 | (:foreground "red1")) | ||
| 1902 | (((class color) (min-colors 8) (background light)) | ||
| 1903 | ) | ||
| 1904 | (((class color) (min-colors 8) (background dark)) | ||
| 1905 | ) | ||
| 1906 | (t (:weight bold :slant italic))) | ||
| 1869 | "The face used to highlight server messages." | 1907 | "The face used to highlight server messages." |
| 1870 | :group 'rcirc-faces) | 1908 | :group 'rcirc-faces) |
| 1871 | 1909 | ||
| 1872 | (defface rcirc-nick-in-message | 1910 | (defface rcirc-server-prefix ; font-lock-comment-delimiter-face |
| 1873 | '((((type tty) (class color)) (:foreground "cyan" :weight bold)) | 1911 | '((default :inherit font-lock-comment-face) |
| 1874 | (((class grayscale) (background light)) (:foreground "LightGray" :bold t)) | 1912 | (((class grayscale))) |
| 1875 | (((class grayscale) (background dark)) (:foreground "DimGray" :bold t)) | 1913 | (((class color) (min-colors 16))) |
| 1876 | (((class color) (background light)) (:foreground "Purple")) | 1914 | (((class color) (min-colors 8) (background light)) |
| 1877 | (((class color) (background dark)) (:foreground "Cyan")) | 1915 | :foreground "red") |
| 1878 | (t (:bold t))) | 1916 | (((class color) (min-colors 8) (background dark)) |
| 1917 | :foreground "red1")) | ||
| 1918 | "The face used to highlight server prefixes." | ||
| 1919 | :group 'rcirc-faces) | ||
| 1920 | |||
| 1921 | (defface rcirc-timestamp | ||
| 1922 | '((t (:inherit default))) | ||
| 1923 | "The face used to highlight timestamps." | ||
| 1924 | :group 'rcirc-faces) | ||
| 1925 | |||
| 1926 | (defface rcirc-nick-in-message ; font-lock-keyword-face | ||
| 1927 | '((((class grayscale) (background light)) (:foreground "LightGray" :weight bold)) | ||
| 1928 | (((class grayscale) (background dark)) (:foreground "DimGray" :weight bold)) | ||
| 1929 | (((class color) (min-colors 88) (background light)) (:foreground "Purple")) | ||
| 1930 | (((class color) (min-colors 88) (background dark)) (:foreground "Cyan1")) | ||
| 1931 | (((class color) (min-colors 16) (background light)) (:foreground "Purple")) | ||
| 1932 | (((class color) (min-colors 16) (background dark)) (:foreground "Cyan")) | ||
| 1933 | (((class color) (min-colors 8)) (:foreground "cyan" :weight bold)) | ||
| 1934 | (t (:weight bold))) | ||
| 1879 | "The face used to highlight instances of nick within messages." | 1935 | "The face used to highlight instances of nick within messages." |
| 1880 | :group 'rcirc-faces) | 1936 | :group 'rcirc-faces) |
| 1881 | 1937 | ||
| 1882 | (defface rcirc-prompt | 1938 | (defface rcirc-prompt ; comint-highlight-prompt |
| 1883 | '((((background dark)) (:foreground "cyan")) | 1939 | '((((min-colors 88) (background dark)) (:foreground "cyan1")) |
| 1940 | (((background dark)) (:foreground "cyan")) | ||
| 1884 | (t (:foreground "dark blue"))) | 1941 | (t (:foreground "dark blue"))) |
| 1885 | "The face to use to highlight prompts." | 1942 | "The face to use to highlight prompts." |
| 1886 | :group 'rcirc-faces) | 1943 | :group 'rcirc-faces) |