소스 검색

contrib/org-eww: Use lexical binding + 𝜀

* contrib/lisp/org-eww.el: Copyright year update.  Simplified program
 logic.  Replaced `replace-regexp' (following the advice of
 `elint-file'.)
Marco Wahl 9 년 전
부모
커밋
88a2f285f0
1개의 변경된 파일9개의 추가작업 그리고 9개의 파일을 삭제
  1. 9 9
      contrib/lisp/org-eww.el

+ 9 - 9
contrib/lisp/org-eww.el

@@ -1,6 +1,6 @@
-;;; org-eww.el --- Store url and kill from Eww mode for Org
+;;; org-eww.el --- Store url and kill from Eww mode for Org  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2014, 2015 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2016 Free Software Foundation, Inc.
 
 ;; Author: Marco Wahl <marcowahlsoft>a<gmailcom>
 ;; Keywords: link, eww
@@ -72,11 +72,10 @@ move.  Return point."
    (or (next-single-property-change (point) 'shr-url)
        (point))))
 
-(defun org-eww-no-next-link-p ()
-  "Whether there is no next link after the cursor.
-Return t if there is no next link; otherwise, return nil."
+(defun org-eww-has-further-url-property-change-p ()
+  "Return t if there is a next url property change else nil."
   (save-excursion
-    (and (eq (point) (org-eww-goto-next-url-property-change)) t)))
+    (not (eq (point) (org-eww-goto-next-url-property-change)))))
 
 (defun org-eww-url-below-point ()
   "Return the url below point if there is an url; otherwise, return nil."
@@ -107,7 +106,7 @@ the structure of the org file."
     (save-excursion
       (goto-char transform-start)
       (while (and (not out-bound)                 ; still inside region to copy
-                  (not (org-eww-no-next-link-p))) ; there is a next link
+                  (org-eww-has-further-url-property-change-p)) ; there is a next link
         ;; store current point before jump next anchor
         (setq temp-position (point))
         ;; move to next anchor when current point is not at anchor
@@ -118,7 +117,7 @@ the structure of the org file."
 	(if (<= (point) transform-end)  ; if point is inside transform bound
 	    (progn
 	      ;; get content between two links.
-	      (if (> (point) temp-position)
+	      (if (< temp-position (point))
 		  (setq return-content (concat return-content
 					       (buffer-substring
 						temp-position (point)))))
@@ -146,7 +145,8 @@ the structure of the org file."
        (with-temp-buffer
 	 (insert return-content)
 	 (goto-char 0)
-	 (replace-regexp "^\*" ",*")
+	 (while (re-search-forward "^\*" nil t)
+	   (replace-match ",*"))
 	 (buffer-string)))
       (message "Transforming links...done, use C-y to insert text into Org-mode file"))))