erc-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Erc-commit] [commit][master] erc-goodies: New move-to-prompt module, wh


From: mwolson
Subject: [Erc-commit] [commit][master] erc-goodies: New move-to-prompt module, which is enabled by default.
Date: Sat, 19 Jan 2008 03:40:18 -0500

commit 17648a61717aa8273a7624bf220ef7a1d8befcf5
Author: Michael W. Olson <address@hidden>
Date:   Sat Jan 19 03:37:06 2008 -0500

    erc-goodies: New move-to-prompt module, which is enabled by default.

diff --git a/ChangeLog b/ChangeLog
index fd8ca2c..f18719d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,15 @@
        when module is removed.  Activate the functionality in all ERC
        buffers when the module is activated, rather than leaving it up to
        the user.
+       (move-to-prompt): New module that moves to the ERC prompt if a
+       user tries to type elsewhere in the buffer, and then inserts their
+       keystrokes there.  This is mostly taken from Johan Bockgard's init
+       file.
+       (erc-move-to-prompt): New function that implements this.
+       (erc-move-to-prompt-xemacs): New function that implements this for
+       XEmacs.
+       (erc-move-to-prompt-init-xemacs): New function to perform the
+       extra initialization step needed for XEmacs.
 
        * erc-page.el, erc-replace.el: Fix header and footer.
 
@@ -32,6 +41,8 @@
        Use erc-network-name function instead, and check to see whether
        that function is bound.  This fixes an error in process filter for
        people who did not have erc-services or erc-networks loaded.
+       (erc-modules): Add move-to-prompt module and enable it by
+       default.  Thanks to e1f for the suggestion.
 
 2008-01-18  Michael Olson  <address@hidden>
 
diff --git a/erc-goodies.el b/erc-goodies.el
index 4f8ce39..c29f155 100644
--- a/erc-goodies.el
+++ b/erc-goodies.el
@@ -130,6 +130,43 @@ Put this function on `erc-insert-post-hook' and/or 
`erc-send-post-hook'."
 If a command's function symbol is in this list, the typed command
 does not appear in the ERC buffer after the user presses ENTER.")
 
+;;; Move to prompt when typing text
+(define-erc-module move-to-prompt nil
+  "This mode causes the point to be moved to the prompt when typing text."
+  ((if (featurep 'xemacs)
+       (progn
+         (add-hook 'erc-mode-hook 'erc-move-to-prompt-init-xemacs)
+         (dolist (buffer (erc-buffer-list))
+           (with-current-buffer buffer
+             (erc-move-to-prompt-init-xemacs))))
+     (define-key erc-mode-map [remap self-insert-command]
+       'erc-move-to-prompt)))
+  ((if (featurep 'xemacs)
+       (progn
+         (remove-hook 'erc-mode-hook 'erc-move-to-prompt-init-xemacs)
+         (dolist (buffer (erc-buffer-list))
+           (with-current-buffer buffer
+             (remove-hook 'pre-command-hook 'erc-move-to-prompt-xemacs t))))
+     (define-key erc-mode-map [remap self-insert-command]
+       'self-insert-command))))
+
+(defun erc-move-to-prompt ()
+  "Move the point to the ERC prompt."
+  (interactive)
+  (when (and erc-input-marker (<= (point) erc-input-marker))
+    (goto-char (point-max)))
+  (call-interactively 'self-insert-command))
+
+(defun erc-move-to-prompt-xemacs ()
+  "Move the point to the ERC prompt if this is a self-inserting command."
+  (when (and erc-input-marker (<= (point) erc-input-marker)
+             (eq 'self-insert-command this-command))
+    (goto-char (point-max))))
+
+(defun erc-move-to-prompt-init-xemacs ()
+  "Initialize the move-to-prompt module for XEmacs."
+  (add-hook 'pre-command-hook 'erc-move-to-prompt-xemacs nil t))
+
 (define-erc-module noncommands nil
   "This mode distinguishies non-commands.
 Commands listed in `erc-insert-this' know how to display
diff --git a/erc.el b/erc.el
index 40559be..7262c25 100644
--- a/erc.el
+++ b/erc.el
@@ -1812,7 +1812,7 @@ buffer rather than a server buffer.")
 
 (defcustom erc-modules '(netsplit fill button match track completion readonly
                                  ring autojoin noncommands irccontrols
-                                 stamp menu list)
+                                 move-to-prompt stamp menu list)
   "A list of modules which ERC should enable.
 If you set the value of this without using `customize' remember to call
 \(erc-update-modules) after you change it.  When using `customize', modules
@@ -1854,6 +1854,8 @@ removed from the list will be disabled."
     (const :tag "log: Save buffers in logs" log)
     (const :tag "match: Highlight pals, fools, and other keywords" match)
     (const :tag "menu: Display a menu in ERC buffers" menu)
+    (const :tag "move-to-prompt: Move to the prompt when typing text"
+          move-to-prompt)
     (const :tag "netsplit: Detect netsplits" netsplit)
     (const :tag "noncommands: Don't display non-IRC commands after evaluation"
           noncommands)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]