Use `idec-online-download-limit/offset'

This commit is contained in:
Denis Zheleztsov 2017-10-16 17:52:01 +03:00
parent 2d676bd853
commit 223d83169b
2 changed files with 32 additions and 14 deletions

View File

@ -79,6 +79,18 @@ Not used if `idec-smart-fetching' is not nil."
:type 'string :type 'string
:group 'idec) :group 'idec)
(defcustom idec-online-download-limit idec-dowload-limit
"Download limit on online browsing;
Default to `idec-download-lmit'"
:type 'string
:group 'idec)
(defcustom idec-online-download-offset idec-dowload-offset
"Download limit on online browsing;
Default to `idec-download-offset'"
:type 'string
:group 'idec)
(defgroup idec-accounts nil (defgroup idec-accounts nil
"IDEC accounts settings." "IDEC accounts settings."
:group 'idec) :group 'idec)

34
idec.el
View File

@ -533,15 +533,22 @@ Return list with body content."
;; ECHOES FUNCTIONS ;; ECHOES FUNCTIONS
;; ;;;;;;;;;;;;;;;; ;; ;;;;;;;;;;;;;;;;
(defun make-echo-url (echoes) (defun make-echo-url (echoes &optional online)
"Make ECHOES url to retreive messages from `idec-primary-node'; "Make ECHOES url to retreive messages from `idec-primary-node';
with `idec-download-offset' and `idec-download-limit'." with `idec-download-offset' and `idec-download-limit';
If ONLINE is t uses `idec-online-download-limit' and `idec-online-download-offset'."
;; Check ECHOES is list ;; Check ECHOES is list
(if (listp echoes) (let (limit offset)
;; Required GNU Emacs >= 25.3 (if online
(message (concat idec-primary-node "u/e/" (and (setq limit idec-online-download-limit)
(s-join "/" echoes) "/" idec-download-offset ":" idec-download-limit)) (setq offset idec-online-download-offset))
(message (concat idec-primary-node "u/e/" echoes "/" idec-download-offset ":" idec-download-limit)))) (and (setq limit idec-download-limit)
(setq offset idec-download-offset)))
(if (listp echoes)
;; Required GNU Emacs >= 25.3
(message (concat idec-primary-node "u/e/"
(s-join "/" echoes) "/" offset ":" limit))
(message (concat idec-primary-node "u/e/" echoes "/" offset ":" limit)))))
(defun make-messages-url (messages) (defun make-messages-url (messages)
"Make MESSAGES url to retreive messages from `idec-primary-node'." "Make MESSAGES url to retreive messages from `idec-primary-node'."
@ -560,12 +567,11 @@ with `idec-download-offset' and `idec-download-limit'."
(nth 1 (split-string (nth 1 (split-string
(get-url-content (make-count-url echo)) ":"))) (get-url-content (make-count-url echo)) ":")))
(defun load-echo-messages (echo) (defun load-echo-messages (echo &optional online)
"Load messages from ECHO." "Load messages from ECHO with ONLINE selector."
(message (concat "DEBUG: " echo)) (when (not online)
(message (concat "URL: " (make-echo-url echo))) (message (concat "Update counter of " echo))
(message (concat "CONTENT: " (get-url-content (make-echo-url echo)))) (store-echo-counter echo))
;; (store-echo-counter echo)
(display-echo-messages (get-url-content (make-echo-url echo)))) (display-echo-messages (get-url-content (make-echo-url echo))))
(defun proccess-echo-message (msg echo) (defun proccess-echo-message (msg echo)
@ -586,7 +592,7 @@ with `idec-download-offset' and `idec-download-limit'."
(setq current-echo (nth 0 (split-string line ":"))) (setq current-echo (nth 0 (split-string line ":")))
;; Create clickable button ;; Create clickable button
(insert-text-button current-echo (insert-text-button current-echo
'action (lambda (x) (load-echo-messages (button-get x 'echo))) 'action (lambda (x) (load-echo-messages (button-get x 'echo) t))
'help-echo (concat "Go to echo " current-echo) 'help-echo (concat "Go to echo " current-echo)
'echo current-echo) 'echo current-echo)
(princ (format "\t\t||%s\t\t%s\n" (princ (format "\t\t||%s\t\t%s\n"