erc-commit
[Top][All Lists]
Advanced

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

[Erc-commit] [commit][master] erc-goodies: Add new keep-place module.


From: mwolson
Subject: [Erc-commit] [commit][master] erc-goodies: Add new keep-place module.
Date: Thu, 24 Jan 2008 21:10:05 -0500

commit 6a8fc4a4e50d8eee904a1d1681885abd6f4fa9bc
Author: Michael W. Olson <address@hidden>
Date:   Thu Jan 24 21:03:33 2008 -0500

    erc-goodies: Add new keep-place module.

diff --git a/ChangeLog b/ChangeLog
index 57402f0..0270b2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 
        * NEWS: Update.
 
+       * erc-goodies.el (keep-place): New module which keeps your place
+       in unvisited ERC buffers when new messages arrive.  This is mostly
+       taken from Johan Bockgård's init file.
+       (erc-noncommands-list): Move to correct place.
+
        * erc-networks.el: Add a module definition.
 
        * erc-services.el (erc-nickserv-identify-mode): Force-enable the
@@ -12,6 +17,8 @@
 
        * erc.el: On second thought, don't load erc-networks.  Just enable
        the networks module by default.
+       (erc-modules): Add option for keep-place and networks.  Enable
+       networks by default.
 
 2008-01-24  Michael Olson  <address@hidden>
 
@@ -100,7 +107,7 @@
        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
+       keystrokes there.  This is mostly taken from Johan Bockgård's init
        file.
        (erc-move-to-prompt): New function that implements this.
        (erc-move-to-prompt-xemacs): New function that implements this for
diff --git a/NEWS b/NEWS
index fba8b52..b53b76c 100644
--- a/NEWS
+++ b/NEWS
@@ -144,6 +144,9 @@ file buffer.
 if a user tries to type elsewhere in the buffer, and then inserts
 their keystrokes after the prompt.  It is enabled by default.
 
+**** New module keep-place keeps your place in unvisited ERC buffers
+when new messages arrive.
+
 **** Enable scroll-to-bottom in all ERC buffers when the module is enabled,
 rather than having the user do it manually.
 
diff --git a/erc-goodies.el b/erc-goodies.el
index 091a90e..ff06546 100644
--- a/erc-goodies.el
+++ b/erc-goodies.el
@@ -118,18 +118,6 @@ Put this function on `erc-insert-post-hook' and/or 
`erc-send-post-hook'."
   (put-text-property (point-min) (point-max) 'front-sticky t)
   (put-text-property (point-min) (point-max) 'rear-nonsticky t))
 
-;; Distinguish non-commands
-(defvar erc-noncommands-list '(erc-cmd-ME
-                               erc-cmd-COUNTRY
-                               erc-cmd-SV
-                               erc-cmd-SM
-                               erc-cmd-SMV
-                               erc-cmd-LASTLOG)
-  "List of commands that are aliases for CTCP ACTION or for erc messages.
-
-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."
@@ -154,6 +142,33 @@ does not appear in the ERC buffer after the user presses 
ENTER.")
   "Initialize the move-to-prompt module for XEmacs."
   (add-hook 'pre-command-hook 'erc-move-to-prompt nil t))
 
+;;; Keep place in unvisited channels
+(define-erc-module keep-place nil
+  "Leave point above un-viewed text in other channels."
+  ((add-hook 'erc-insert-pre-hook  'erc-keep-place))
+  ((remove-hook 'erc-insert-pre-hook  'erc-keep-place)))
+
+(defun erc-keep-place (ignored)
+  "Move point away from the last line in a non-selected ERC buffer."
+  (when (and (not (eq (window-buffer (selected-window))
+                      (current-buffer)))
+             (>= (point) erc-insert-marker))
+    (deactivate-mark)
+    (goto-char (erc-beg-of-input-line))
+    (forward-line -1)))
+
+;;; Distinguish non-commands
+(defvar erc-noncommands-list '(erc-cmd-ME
+                               erc-cmd-COUNTRY
+                               erc-cmd-SV
+                               erc-cmd-SM
+                               erc-cmd-SMV
+                               erc-cmd-LASTLOG)
+  "List of commands that are aliases for CTCP ACTION or for erc messages.
+
+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.")
+
 (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 4c54fe7..079faf2 100644
--- a/erc.el
+++ b/erc.el
@@ -1844,12 +1844,13 @@ removed from the list will be disabled."
           capab-identify)
     (const :tag "completion: Complete nicknames and commands (programmable)"
           completion)
-    (const :tag "dcc: Provide Direct Client-to-Client support" dcc)
     (const :tag "hecomplete: Complete nicknames and commands (old)" hecomplete)
+    (const :tag "dcc: Provide Direct Client-to-Client support" dcc)
     (const :tag "fill: Wrap long lines" fill)
     (const :tag "identd: Launch an identd server on port 8113" identd)
     (const :tag "irccontrols: Highlight or remove IRC control characters"
           irccontrols)
+    (const :tag "keep-place: Leave point above un-viewed text" keep-place)
     (const :tag "list: List channels in a separate buffer" list)
     (const :tag "list-old: List channels in a separate buffer (old)" list-old)
     (const :tag "log: Save buffers in logs" log)




reply via email to

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