[Top][All Lists]

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

[PATCH] ERC: Hide identification password sent to Nickserv

From: vibhavp
Subject: [PATCH] ERC: Hide identification password sent to Nickserv
Date: Sun, 15 Mar 2015 15:23:45 +0530

I've added a feature to Emacs which hides the password sent to nickserv
for nick identification by changing the password's "display" test
property with a dotted string. Here's an example:
ERC> /msg nickserv identify foobar
When sent to ERC, the ERC buffer displays this as:
ERC> /msg nickserv identify .....
I've also added this to the default list of modules, so passwords are
hidden by default. Feel free to point out anything wrong in the
attached patch.
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog
index 4f5fced..bbdb74e 100644
--- a/lisp/erc/ChangeLog
+++ b/lisp/erc/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-15  Vibhav Pant  <address@hidden>
+       * erc-goodies.el (erc-hide-ident-password): New function.
+       (hide-nickserv-password): New module.
+       * erc-el: Add hide-nickserv-password to erc-modules.
 2015-03-03  Kelvin White  <address@hidden>
        * erc.el: Add old version string back to file header for
diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el
index ca2d14a..84f7f1f 100644
--- a/lisp/erc/erc-goodies.el
+++ b/lisp/erc/erc-goodies.el
@@ -550,6 +550,27 @@ See also `unmorse-region'."
       ;; Unmorse region
       (unmorse-region (point-min) (point-max)))))
+;; Hide Nickserv identify password
+(define-erc-module hide-nickserv-password nil
+  "This mode hides the identify password sent to Nickserv.
+It replaces each character of the password with '.'"
+  ((add-hook 'erc-send-modify-hook 'erc-hide-ident-password))
+  ((remove-hook 'erc-send-modify-hook 'erc-hide-ident-password)))
+(defun erc-hide-ident-password ()
+  "Hide the identification password sent to Nickserv.
+Search the buffer for any identification requests to Nickserv, and
+sets the display text property of the password to a dotted string."
+  (save-excursion
+    (with-current-buffer (current-buffer)
+      (goto-char (point-min))
+      (when (re-search-forward "/\\(msg\\|query\\) nickserv identify "
+                              nil t nil)
+       (let ((bounds (bounds-of-thing-at-point 'word)))
+         (put-text-property (car bounds) (cdr bounds) 'display
+                            (make-string
+                             (- (cdr bounds) (car bounds)) ?.)))))))
 ;;; erc-occur
 (defun erc-occur (string &optional proc)
   "Search for STRING in all buffers related to current server.
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index a84f9f0..bfbceae 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1810,7 +1810,8 @@ buffer rather than a server buffer.")
 (defcustom erc-modules '(netsplit fill button match track completion readonly
                                   networks ring autojoin noncommands 
-                                  move-to-prompt stamp menu list)
+                                  move-to-prompt stamp menu list
+                                 hide-nickserv-password)
   "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
Vibhav Pant

reply via email to

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