@ -83,6 +83,7 @@ automatic splitting in the twister configuration."
( let ( ( map ( make-sparse-keymap ) ) )
( let ( ( map ( make-sparse-keymap ) ) )
( define-key map " \C -c \C -c " 'twister-post-buffer )
( define-key map " \C -c \C -c " 'twister-post-buffer )
( define-key map " \C -c \C -k " 'twister-close-post )
( define-key map " \C -c \C -k " 'twister-close-post )
( define-key map " \C -i " 'pcomplete ) ;; \C-i == TAB
map ) " Keymap for `twister-post-mode' . " )
map ) " Keymap for `twister-post-mode' . " )
( define-derived-mode twister-post-mode text-mode " twister-post "
( define-derived-mode twister-post-mode text-mode " twister-post "
@ -182,5 +183,39 @@ so we use that if user is not specified."
( twister-rpc " getfollowing " ( if user user twister-user ) ) )
( twister-rpc " getfollowing " ( if user user twister-user ) ) )
( defun twister-completion-entries ( )
" Produce a list of entries to which completion can be matched.
For now, this is just the nicknames the user follows "
( mapcar ( lambda ( x ) ( concat " @ " x ) ) ( twister-getfollowing ) ) )
( defun twister-parse-completion-arguments ( )
( save-excursion
( let* ( ( thisp ( point ) )
( pt ( search-backward " @ " nil t ) ) ;; Only search @.... stuff
( ptt ( if pt pt thisp ) ) )
( list ( list " dummy "
( buffer-substring-no-properties ptt thisp ) )
( point-min ) ptt ) ) ) )
( defun twister-default-completion ( )
( pcomplete-here ( twister-completion-entries ) ) )
;; Define autocompletion for the twister-post-mode
( defun pcomplete-twister-post-setup ( )
" Setup `twister-post-mode' to use pcomplete "
( interactive )
( set ( make-local-variable 'pcomplete-parse-arguments-function )
'twister-parse-completion-arguments )
( set ( make-local-variable 'pcomplete-default-completion-function )
'twister-default-completion ) )
;; Enable this now, but this should be the users choice really
( add-hook 'twister-post-mode-hook 'pcomplete-twister-post-setup )
( provide 'twister )
( provide 'twister )
;;; twister.el ends here
;;; twister.el ends here