emacs写wordpress的一个小补丁

使用emacs的插件weblogger来写blog的时候,最新的版本在我这边没办法使用分类,所有的都是未分类的,但可使用’< ''>‘等,在weblogger的仓库中,我在bug列表里中找到到关于这方面的问题,同时,gabrielsaldana提供了一个针对之前修改的版本。该版本支持分类,但在我这边,不支持使用’< ' '>‘等,因为我从未学过lisp语言,所以没有在最新版本上做补丁,而是退一步在gabrielsaldana的版本上进行了修改,这样可以支持html部分。下面是patch:

diff -u -r ../old/weblogger.el ./weblogger.el
--- ../old/weblogger.el	2009-01-29 15:48:41.000000000 +0800
+++ ./weblogger.el	2009-12-08 19:48:44.649587365 +0800
@@ -219,9 +219,10 @@

(defvar weblogger-entry-mode-hook nil
   "Hook to run after starting up weblogger mode.")
 
-(defvar weblogger-start-edit-entry-hook (lambda ()
-					  (message-goto-body)
-					  (replace-string "\r" "" nil (point) (point-max)))
+(defvar weblogger-start-edit-entry-hook
+  (lambda ()
+    (message-goto-body)
+    (replace-string "\r" "" nil (point) (point-max)))
   "Hook to run after loading an entry in buffer for editting.")
 
 (defvar weblogger-new-entry-hook '(weblogger-ping-weblogs)
@@ -1073,7 +1074,10 @@
 				  (with-temp-buffer
 				    (insert (cdr content))
 				    (goto-char (point-min))
-				    (replace-string (match-string 0 (cdr content)) "")
+ ;				    (replace-string (match-string 0 (cdr content)) "")
+                                    (while (and (not (string= "" (match-string 0 (cdr content))))
+                                                (search-forward (match-string 0 (cdr content)) nil t))
+                                      (replace-match "" nil t))
 				    (buffer-string)))
 			  (cons "title" title)))
 		      (when authorName
@@ -1161,7 +1165,7 @@
 	(has-mt-api t)
 	(has-blogger-api t))
     (condition-case nil
-	(progn (mapcar
+	(progn (mapc
 		(lambda (method)
 		  (and (assoc method weblogger-capabilities) 
 		       (setcdr (assoc method weblogger-capabilities) t)))
@@ -1258,4 +1262,5 @@
 ;;  	 'ispell-message "spell" message-mode-map)
 ;;  	tool-bar-map))))
 
-(provide 'weblogger)
\ 文件结尾缺少空行
+(provide 'weblogger)
+
diff -u -r ../old/xml-rpc.el ./xml-rpc.el
--- ../old/xml-rpc.el	2009-01-20 00:15:35.000000000 +0800
+++ ./xml-rpc.el	2009-12-08 19:36:01.510833897 +0800
@@ -175,7 +175,12 @@
   "*Hook run after loading xml-rpc."
   :type 'hook :group 'xml-rpc)
 
-(defcustom xml-rpc-allow-unicode-string t
+(defcustom xml-rpc-use-coding-system
+  (if (coding-system-p 'utf-8) 'utf-8 'iso-8859-1)
+  "The coding system to use."
+  :type 'symbol :group 'xml-rpc)
+
+(defcustom xml-rpc-allow-unicode-string (coding-system-p 'utf-8)
   "If non-nil, non-ASCII data is composed as 'value' instead of 'base64'.
 And this option overrides `xml-rpc-base64-encode-unicode' and
 `xml-rpc-base64-decode-unicode' if set as non-nil."
@@ -242,9 +247,11 @@
 	 (while (and vals result)
 	   (setq result (and
 			 (setq curval (car-safe vals))
-			 (or (and (listp curval) (symbolp (car curval)) (string= (car curval) :struct))
-			     (and (memq (safe-length curval) '(1 2))
-				  (stringp (car-safe curval))))))
+;			 (or (and (listp curval) (symbolp (car curval)) (string= (car curval) :struct))
+;			     (and (memq (safe-length curval) '(1 2))
+                         (consp curval)
+                         (stringp (car-safe curval))))
+;           ))
 	   (setq vals (cdr-safe vals)))
 	 result)))
 
@@ -356,9 +363,12 @@
 	      (and (eq 1 (length charset-list))
 		   (eq 'ascii (car charset-list)))
 	      (not xml-rpc-base64-encode-unicode))
-	  `((value nil (string nil ,(url-insert-entities-in-string value))))
-	`((value nil (base64 nil ,(base64-encode-string
-				   (encode-coding-string value 'utf-8))))))))
+	  `((value nil (string nil ,value)))
+; (url-insert-entities-in-string value))))
+	`((value nil (base64 nil ,(if xml-rpc-base64-encode-unicode
+                                      (base64-encode-string
+				   (encode-coding-string value xml-rpc-use-coding-system))
+                                    (base64-encode-string value))))))))
    ((xml-rpc-value-doublep value)
     `((value nil (double nil ,(number-to-string value)))))
    (t
@@ -528,8 +538,10 @@
 					; a string, so clean it.
 	 ((stringp elem)
 	  (let ((tmp (xml-rpc-clean-string elem)))
-	    (if (and tmp xml-rpc-allow-unicode-string)
-		(setq tmp (decode-coding-string tmp 'utf-8)))
+;	    (if (and tmp xml-rpc-allow-unicode-string)
+;		(setq tmp (decode-coding-string tmp 'utf-8)))
+            (when (and tmp xml-rpc-allow-unicode-string)
+              (setq tmp (decode-coding-string tmp xml-rpc-use-coding-system)))
 	    (if tmp
 		(setq result (append result (list tmp)))
 	      result)))

发布者

rix

如果连自己都不爱自己,哪还有谁来爱你

  • Pingback: vvoody’s woody house » Blog Archive » [Emacs]用Emacs写博客(WordPress)()

    • admin

      我觉得我的网站够慢的了,没想到你的比我的还慢,难道是我这边网络的问题?说不定很可能是这样的

    • admin

      不知道你的有什么改变?你的关于我的链接连的是一个不太好的patch

  • Hi! I got the pingback from your post. I’d really like to know/understand what you’re commenting here and integrate your patch to the version I have on my site. Can you email me so we can work something out?

  • I think that is an interesting point, it made me think a bit. Thanks for sparking my thinking cap. Sometimes I get so much in a rut that I just feel like a record.