[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/rcirc-update 0b367ec 06/18: Remove custom rcirc-completion imple
From: |
Philip Kaludercic |
Subject: |
feature/rcirc-update 0b367ec 06/18: Remove custom rcirc-completion implementation |
Date: |
Thu, 10 Jun 2021 11:43:38 -0400 (EDT) |
branch: feature/rcirc-update
commit 0b367ec39f41825f3eb2ce6acc4d2dd764ecc898
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Remove custom rcirc-completion implementation
* rcirc.el (rcirc-completion-at-point): Improve completion suggestions
(rcirc-completions): Remove variable
(rcirc-completion-start): Remove variable
(rcirc-complete): Remove function
(rcirc-mode-map): Bind TAB to completion-at-point
(rcirc-mode): Use cycling for completion
---
lisp/net/rcirc.el | 67 ++++++++++++++++++++-----------------------------------
1 file changed, 24 insertions(+), 43 deletions(-)
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index b919e03..d463a14 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -1023,50 +1023,30 @@ The list is updated automatically by
`defun-rcirc-command'.")
(if (re-search-backward "[[:space:]@]"
rcirc-prompt-end-marker t)
(1+ (point))
rcirc-prompt-end-marker)))
- (table (if (and (= beg rcirc-prompt-end-marker)
- (eq (char-after beg) ?/))
- (delete-dups
- (nconc (sort (copy-sequence rcirc-client-commands)
- 'string-lessp)
- (sort (copy-sequence rcirc-server-commands)
- 'string-lessp)))
- (rcirc-channel-nicks (rcirc-buffer-process)
- rcirc-target))))
+ (table (cond
+ ;; No completion before the prompt
+ ((< beg rcirc-prompt-end-marker) nil)
+ ;; Only complete nicks mid-message
+ ((> beg rcirc-prompt-end-marker)
+ (rcirc-channel-nicks (rcirc-buffer-process)
+ rcirc-target))
+ ;; Complete commands at the beginning of the
+ ;; message, when the first character is a dash
+ ((eq (char-after beg) ?/)
+ (mapcar
+ (lambda (cmd) (concat cmd " "))
+ (nconc (sort (copy-sequence rcirc-client-commands)
+ 'string-lessp)
+ (sort (copy-sequence rcirc-server-commands)
+ 'string-lessp))))
+ ;; Complete usernames right after the prompt by
+ ;; appending a colon after the name
+ ((mapcar
+ (lambda (str) (concat str ": "))
+ (rcirc-channel-nicks (rcirc-buffer-process)
+ rcirc-target))))))
(list beg (point) table))))
-(defvar rcirc-completions nil
- "List of possible completions to cycle through.")
-
-(defvar rcirc-completion-start nil
- "Point indicating where completion starts.")
-
-(defun rcirc-complete ()
- "Cycle through completions from list of nicks in channel or IRC commands.
-IRC command completion is performed only if `/' is the first input char."
- (interactive)
- (unless (rcirc-looking-at-input)
- (error "Point not located after rcirc prompt"))
- (if (eq last-command this-command)
- (setq rcirc-completions
- (append (cdr rcirc-completions) (list (car rcirc-completions))))
- (let ((completion-ignore-case t)
- (table (rcirc-completion-at-point)))
- (setq rcirc-completion-start (car table))
- (setq rcirc-completions
- (and rcirc-completion-start
- (all-completions (buffer-substring rcirc-completion-start
- (cadr table))
- (nth 2 table))))))
- (let ((completion (car rcirc-completions)))
- (when completion
- (delete-region rcirc-completion-start (point))
- (insert
- (cond
- ((= (aref completion 0) ?/) (concat completion " "))
- ((= rcirc-completion-start rcirc-prompt-end-marker)
- (format rcirc-nick-completion-format completion))
- (t completion))))))
-
(defun set-rcirc-decode-coding-system (coding-system)
"Set the decode CODING-SYSTEM used in this channel."
(interactive "zCoding system for incoming messages: ")
@@ -1082,7 +1062,7 @@ IRC command completion is performed only if `/' is the
first input char."
(define-key map (kbd "RET") 'rcirc-send-input)
(define-key map (kbd "M-p") 'rcirc-insert-prev-input)
(define-key map (kbd "M-n") 'rcirc-insert-next-input)
- (define-key map (kbd "TAB") 'rcirc-complete)
+ (define-key map (kbd "TAB") 'completion-at-point)
(define-key map (kbd "C-c C-b") 'rcirc-browse-url)
(define-key map (kbd "C-c C-c") 'rcirc-edit-multiline)
(define-key map (kbd "C-c C-j") 'rcirc-cmd-join)
@@ -1195,6 +1175,7 @@ This number is independent of the number of lines in the
buffer.")
(add-hook 'completion-at-point-functions
'rcirc-completion-at-point nil 'local)
+ (setq-local completion-cycle-threshold t)
(run-mode-hooks 'rcirc-mode-hook))
- feature/rcirc-update c300326 12/18: Add TAGMSG handler, (continued)
- feature/rcirc-update c300326 12/18: Add TAGMSG handler, Philip Kaludercic, 2021/06/10
- feature/rcirc-update fd96e3a 18/18: Allow hiding certain message types after reconnecting, Philip Kaludercic, 2021/06/10
- feature/rcirc-update 8ea5766 05/18: Recognize quoted commands in rcirc-process-input-line, Philip Kaludercic, 2021/06/10
- feature/rcirc-update 06af44e 08/18: Create framework for IRCv3 support, Philip Kaludercic, 2021/06/10
- feature/rcirc-update ab49a9a 10/18: Implement batch extension, Philip Kaludercic, 2021/06/10
- feature/rcirc-update f6e18c6 13/18: Implement invite-notify capability, Philip Kaludercic, 2021/06/10
- feature/rcirc-update 567e288 11/18: Implement message-ids extension, Philip Kaludercic, 2021/06/10
- feature/rcirc-update 95fdd4b 14/18: Allow filtering how nicks are presented, Philip Kaludercic, 2021/06/10
- feature/rcirc-update b67b1ee 15/18: Fix prompt doubling when reconnecting, Philip Kaludercic, 2021/06/10
- feature/rcirc-update 6898816 01/18: Default to libera instead of freenode, Philip Kaludercic, 2021/06/10
- feature/rcirc-update 0b367ec 06/18: Remove custom rcirc-completion implementation,
Philip Kaludercic <=
- feature/rcirc-update 4ff1f66 07/18: Replace defun-rcirc-command with rcirc-define-command, Philip Kaludercic, 2021/06/10
- feature/rcirc-update 849e71f 09/18: Implement server-time extension, Philip Kaludercic, 2021/06/10
- feature/rcirc-update 3a61e7b 17/18: Use defvar-local instead of setq-local where applicable, Philip Kaludercic, 2021/06/10
- feature/rcirc-update 13f6f78 16/18: Allow for optional arguments using rcirc-define-command, Philip Kaludercic, 2021/06/10
- feature/rcirc-update e6c99a7 04/18: Integrate formatting into rcirc-send-string, Philip Kaludercic, 2021/06/10