]> jturnerusa.dev Git - wgetpaste.el/commitdiff
add ansi ctrl code filtering with ansi-color-filter-region
authorJohn Turner <jturner.usa@gmail.com>
Sat, 9 Mar 2024 20:15:21 +0000 (15:15 -0500)
committerJohn Turner <jturner.usa@gmail.com>
Sat, 9 Mar 2024 20:41:43 +0000 (15:41 -0500)
wgetpaste.el

index 3aafcb6bc576d78c204183e42aa395c525f3ca6b..8136fcc7200915cea92d8c5731d0f89b792aa1e7 100644 (file)
@@ -17,6 +17,8 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
+(require 'ansi-color)
+
 (defgroup wgetpaste nil
   "Wgetpaste interface for emacs")
 
@@ -82,6 +84,9 @@
 
 ;; hooks
 
+(defun wgetpaste-ansifilter ()
+  (ansi-color-filter-region (point-min) (point-max)))
+
 (defun wgetpaste-clear-stdout-buffer ()
   (with-current-buffer (get-buffer-create wgetpaste-stdout-buffer)
     (erase-buffer)))
 
 (when wgetpaste-install-hooks
   (add-hook 'wgetpaste-before-upload-hook 'wgetpaste-clear-stdout-buffer)
+  (add-hook 'wgetpaste-before-upload-hook 'wgetpaste-ansifilter)
   (add-hook 'wgetpaste-after-upload-hook 'wgetpaste-save-url-to-clipboard)
   (add-hook 'wgetpaste-upload-failure-hook 'wgetpaste-failed))