From: morioka Date: Wed, 16 Sep 1998 02:30:52 +0000 (+0000) Subject: (base64-dl-encode-string): New alias. X-Git-Tag: flim-1_10_0-pre1~12 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1208c62444683b4c2c971f912e10b08beb590ecf;p=elisp%2Fflim.git (base64-dl-encode-string): New alias. (base64-dl-decode-string): New alias. (base64-dl-encode-region): Renamed from `base64-encode-region'; don't save-excursion and save-restriction. (base64-dl-decode-region): Renamed from `base64-decode-region'; don't save-excursion and save-restriction; convert all at once. (base64-encode-region): New alias. (base64-decode-region): New alias. --- diff --git a/mel-dl.el b/mel-dl.el index 0e79cca..e1df065 100644 --- a/mel-dl.el +++ b/mel-dl.el @@ -35,56 +35,37 @@ (dynamic-call "emacs_base64_init" base64-dl-handle) -(defalias 'base64-encode-string 'encode-base64-string) -(defalias 'base64-decode-string 'decode-base64-string) +(defalias 'base64-dl-encode-string 'encode-base64-string) +(defalias 'base64-dl-decode-string 'decode-base64-string) -(defun base64-encode-region (start end) +(defun base64-dl-encode-region (start end) "Encode current region by base64. START and END are buffer positions." (interactive "r") - (save-excursion - (save-restriction - (narrow-to-region start end) - (let ((str (buffer-substring start end))) - (delete-region start end) - (insert (encode-base64-string str)) - ) - (or (bolp) - (insert "\n") - ) - ))) + (let ((str (buffer-substring start end))) + (delete-region start end) + (insert (encode-base64-string str)) + ) + (or (bolp) + (insert "\n")) + ) -(defun base64-decode-region (start end) +(defun base64-dl-decode-region (start end) "Decode current region by base64. START and END are buffer positions." (interactive "r") - (save-excursion - (save-restriction - (narrow-to-region start end) - (goto-char (point-min)) - (while (looking-at ".*\n") - (condition-case err - (replace-match - (decode-base64-string - (buffer-substring (match-beginning 0) (1- (match-end 0)))) - t t) - (error - (prog1 - (message (nth 1 err)) - (replace-match ""))))) - (if (looking-at ".*$") - (condition-case err - (replace-match - (decode-base64-string - (buffer-substring (match-beginning 0) (match-end 0))) - t t) - (error - (prog1 - (message (nth 1 err)) - (replace-match ""))) - )) + (let ((str (buffer-substring start end))) + (delete-region start end) + (condition-case err + (insert (decode-base64-string str)) + (error (message (nth 1 err))) ))) +(defalias 'base64-encode-string 'encode-base64-string) +(defalias 'base64-decode-string 'decode-base64-string) +(defalias 'base64-encode-region 'base64-dl-encode-region) +(defalias 'base64-decode-region 'base64-dl-decode-region) + ;;; @ base64 encoder/decoder for file ;;;