Browse Source

org-mobile: Use lexical binding

* lisp/org-agenda.el (org-agenda-keep-restricted-file-list): New
  variable, dynamically scoped.
(org-agenda): Variable is now necessarily bound.

* lisp/org-mobile.el (org-mobile-create-index-file): Silence
  byte-compiler.
Nicolas Goaziou 3 years ago
parent
commit
6b7944805f
2 changed files with 22 additions and 24 deletions
  1. 2 1
      lisp/org-agenda.el
  2. 20 23
      lisp/org-mobile.el

+ 2 - 1
lisp/org-agenda.el

@@ -2678,6 +2678,7 @@ to limit entries to in this type."
 				(const timeline))
 			(integer :tag "Max number of minutes")))))
 
+(defvar org-agenda-keep-restricted-file-list nil)
 (defvar org-keys nil)
 (defvar org-match nil)
 ;;;###autoload
@@ -2744,7 +2745,7 @@ Pressing `<' twice means to restrict to the current subtree or region
 	   entry key type org-match lprops ans)
       ;; Turn off restriction unless there is an overriding one,
       (unless org-agenda-overriding-restriction
-	(unless (org-bound-and-true-p org-agenda-keep-restricted-file-list)
+	(unless org-agenda-keep-restricted-file-list
 	  ;; There is a request to keep the file list in place
 	  (put 'org-agenda-files 'org-restrict nil))
 	(setq org-agenda-restrict nil)

+ 20 - 23
lisp/org-mobile.el

@@ -1,4 +1,4 @@
-;;; org-mobile.el --- Code for asymmetric sync with a mobile device
+;;; org-mobile.el --- Code for Asymmetric Sync With a Mobile Device -*- lexical-binding: t; -*-
 ;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
@@ -33,6 +33,8 @@
 
 (require 'org)
 (require 'org-agenda)
+(defvar org-agenda-keep-restricted-file-list)
+
 ;;; Code:
 
 (eval-when-compile (require 'cl))
@@ -425,7 +427,7 @@ agenda view showing the flagged items."
 	(def-tags org-tag-alist)
 	(target-file (expand-file-name org-mobile-index-file
 				       org-mobile-directory))
-	file link-name todo-kwds done-kwds tags entry kwds dwds twds)
+	todo-kwds done-kwds tags)
     (when (stringp (car def-todo))
       (setq def-todo (list (cons 'sequence def-todo))))
     (org-agenda-prepare-buffers (mapcar 'car files-alist))
@@ -435,21 +437,19 @@ agenda view showing the flagged items."
 		     (org-uniquify org-todo-keywords-for-agenda)))
     (setq tags (mapcar 'car (org-global-tags-completion-table
 			     (mapcar 'car files-alist))))
-    (with-temp-file
-	(if org-mobile-use-encryption
-	    org-mobile-encryption-tempfile
-	  target-file)
+    (with-temp-file (if org-mobile-use-encryption org-mobile-encryption-tempfile
+		      target-file)
       (insert "#+READONLY\n")
-      (while (setq entry (pop def-todo))
-	(setq kwds (mapcar (lambda (x) (if (string-match "(" x)
-					   (substring x 0 (match-beginning 0))
-					 x))
-			   (cdr entry)))
-	(insert "#+TODO: " (mapconcat 'identity kwds " ") "\n")
-	(setq dwds (or (member "|" kwds) (last kwds))
-	      twds (org-delete-all dwds kwds)
-	      todo-kwds (org-delete-all twds todo-kwds)
-	      done-kwds (org-delete-all dwds done-kwds)))
+      (dolist (entry def-todo)
+	(let* ((kwds (mapcar (lambda (x) (if (string-match "(" x)
+					(substring x 0 (match-beginning 0))
+				      x))
+			     (cdr entry)))
+	       (dwds (or (member "|" kwds) (last kwds)))
+	       (twds (org-delete-all dwds kwds)))
+	  (insert "#+TODO: " (mapconcat 'identity kwds " ") "\n")
+	  (setq todo-kwds (org-delete-all twds todo-kwds))
+	  (setq done-kwds (org-delete-all dwds done-kwds))))
       (when (or todo-kwds done-kwds)
 	(insert "#+TODO: " (mapconcat 'identity todo-kwds " ") " | "
 		(mapconcat 'identity done-kwds " ") "\n"))
@@ -462,11 +462,8 @@ agenda view showing the flagged items."
       (when (file-exists-p (expand-file-name
 			    org-mobile-directory "agendas.org"))
 	(insert "* [[file:agendas.org][Agenda Views]]\n"))
-      (while (setq entry (pop files-alist))
-	(setq file (car entry)
-	      link-name (cdr entry))
-	(insert (format "* [[file:%s][%s]]\n"
-			link-name link-name)))
+      (pcase-dolist (`(,file . ,link-name) files-alist)
+	(insert (format "* [[file:%s][%s]]\n" file link-name)))
       (push (cons org-mobile-index-file (md5 (buffer-string)))
 	    org-mobile-checksum-files))
     (when org-mobile-use-encryption
@@ -812,7 +809,7 @@ If BEG and END are given, only do this in that region."
 	(cnt-flag 0)
 	(cnt-error 0)
 	buf-list
-	id-pos org-mobile-error)
+	org-mobile-error)
 
     ;; Count the new captures
     (goto-char beg)
@@ -895,7 +892,7 @@ If BEG and END are given, only do this in that region."
 		    (unless (member data (list "delete" "archive" "archive-sibling" "addheading"))
 		      (if (member "FLAGGED" (org-get-tags))
 			  (add-to-list 'org-mobile-last-flagged-files
-				       (buffer-file-name (current-buffer)))))))
+				       (buffer-file-name))))))
 	      (error (setq org-mobile-error msg))))
 	  (when org-mobile-error
 	    (org-pop-to-buffer-same-window (marker-buffer marker))