unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [ELPA] New package: SachaC-news
@ 2023-11-12 19:32 Christian
  2023-11-14  2:56 ` Richard Stallman
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Christian @ 2023-11-12 19:32 UTC (permalink / raw)
  To: emacs-devel

Hi!

I want to propose SachaC-news (or sachac-news.el if you like)
package to be included in ELPA. Its objective is to check for
Sacha Chua's news repository periodically, and to show the Org
file if there is a new commit with a new post in it. It has
some customizations too, such as folding specific sections
automatically, and desktop notifications via "notify-send". The
requirement is the git program to be installed on your system.
This information and its usage is at the README.org file at the
package repository:

          https://github.com/cnngimenez/sachac-news

The code has been checked with byte-compile-file, and
flycheck configured with checkdoc and flycheck-package [1].
They do not display any warnings up to commit d00e629, but tell
me if you find something to fix or any suggestions.

According to http://elpa.gnu.org/, and the README.org [2] file
linked there, it says to notify to this mail address as
first step. Also, it mentions other steps regarding pushing the
code and adding an entry on elpa-packages file. But, there is a
marker above indicating "OUTDATED" [3].

Please, could you tell me if these steps are needed?
If they are not, how should I proceed?

Cheers!
Christian Gimenez

[1] https://github.com/purcell/flycheck-package
[2] https://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/README
[3] The section states: "Text below this marker is OUTDATED and
still needs to be reviewed/rewritten!!"



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ELPA] New package: SachaC-news
  2023-11-12 19:32 [ELPA] New package: SachaC-news Christian
@ 2023-11-14  2:56 ` Richard Stallman
  2023-11-15 23:56   ` Björn Bidar
  2023-11-14  2:56 ` Richard Stallman
  2023-11-17  7:28 ` Philip Kaludercic
  2 siblings, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2023-11-14  2:56 UTC (permalink / raw)
  To: Christian; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I want to propose SachaC-news (or sachac-news.el if you like)
  > package to be included in ELPA. Its objective is to check for
  > Sacha Chua's news repository periodically, and to show the Org
  > file if there is a new commit with a new post in it.

What other formats does this repository store postings in?  If it has
-- or can generate -- plain text, that should be preferred.
There are users who like Org fornat, but it is not Emacs's preferred
way of showing information,


-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ELPA] New package: SachaC-news
  2023-11-12 19:32 [ELPA] New package: SachaC-news Christian
  2023-11-14  2:56 ` Richard Stallman
@ 2023-11-14  2:56 ` Richard Stallman
  2023-11-18 20:26   ` Christian
  2023-11-17  7:28 ` Philip Kaludercic
  2 siblings, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2023-11-14  2:56 UTC (permalink / raw)
  To: Christian; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I want to propose SachaC-news (or sachac-news.el if you like)
  > package to be included in ELPA.

Are you the developer of the SachaC-news program?
I would guess so, but I'd like to be sure rather than guess.

                                    Its objective is to check for
  > Sacha Chua's news repository periodically, and to show the Org
  > file if there is a new commit with a new post in it.

What other formats does this repository store postings in?  If it has
-- or can generate -- plain text, that should be preferred.
There are users who like Org fornat, but it is not Emacs's preferred
way of showing information.

  > The
  > requirement is the git program to be installed on your system.

Could you say what task it does using git?  Is Sacha's news repository
a git repository?  That might be ok, but where is it?  I hope not
github!  Where is that archive stored?  Can you please tell us its
URL?

We deprecate use of github, so if we are going to have Emacs use a
specific git repo for particular purposes, we should put it on a repo
site that we recommend.

The name SachaC-News suggests that Sacha Chua maintains that archive.
Is that correct?

What formats does it store articles in?  Is Org
format the only one?

Org format is NOT the Emacs standard or preferred format, and not
everyone uses it.  Therefore, if we add a command to display some
useful information, it should not use Org format.

The best format to use is plain text.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ELPA] New package: SachaC-news
  2023-11-14  2:56 ` Richard Stallman
@ 2023-11-15 23:56   ` Björn Bidar
  0 siblings, 0 replies; 12+ messages in thread
From: Björn Bidar @ 2023-11-15 23:56 UTC (permalink / raw)
  To: Richard Stallman; +Cc: Christian, emacs-devel

Richard Stallman <rms@gnu.org> writes:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > I want to propose SachaC-news (or sachac-news.el if you like)
>   > package to be included in ELPA. Its objective is to check for
>   > Sacha Chua's news repository periodically, and to show the Org
>   > file if there is a new commit with a new post in it.
>
> What other formats does this repository store postings in?  If it has
> -- or can generate -- plain text, that should be preferred.
> There are users who like Org fornat, but it is not Emacs's preferred
> way of showing information,

The base text file might be in org-mode but org-mode can export to plain
text e.g. ANSI or UTF-8. Despite that I consider org-mode text quite
easy to read even for those that don't understand org, especially inside
Emacs.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ELPA] New package: SachaC-news
  2023-11-12 19:32 [ELPA] New package: SachaC-news Christian
  2023-11-14  2:56 ` Richard Stallman
  2023-11-14  2:56 ` Richard Stallman
@ 2023-11-17  7:28 ` Philip Kaludercic
  2023-11-18 20:30   ` Christian
  2 siblings, 1 reply; 12+ messages in thread
From: Philip Kaludercic @ 2023-11-17  7:28 UTC (permalink / raw)
  To: Christian; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 959 bytes --]

Christian <cnngimenez@disroot.org> writes:

> Hi!
>
> I want to propose SachaC-news (or sachac-news.el if you like)
> package to be included in ELPA. Its objective is to check for
> Sacha Chua's news repository periodically, and to show the Org
> file if there is a new commit with a new post in it. It has
> some customizations too, such as folding specific sections
> automatically, and desktop notifications via "notify-send". The
> requirement is the git program to be installed on your system.
> This information and its usage is at the README.org file at the
> package repository:
>
>           https://github.com/cnngimenez/sachac-news
>
> The code has been checked with byte-compile-file, and
> flycheck configured with checkdoc and flycheck-package [1].

> They do not display any warnings up to commit d00e629, but tell
> me if you find something to fix or any suggestions.

I found a few things, here is a diff with some comments and suggestions:


[-- Attachment #2: Type: text/plain, Size: 17723 bytes --]

diff --git a/sachac-news.el b/sachac-news.el
index 8d67911..1f389b2 100644
--- a/sachac-news.el
+++ b/sachac-news.el
@@ -22,7 +22,6 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-
 ;;; Commentary:
 
 ;; Check periodically for new commits on Sacha Chua's news repository.
@@ -58,29 +57,29 @@
 
 ;;; Code:
 
-(provide 'sachac-news)
 (require 'org-element)
 (require 'org-list)
-(require 'cl-extra)
+(require 'cl-lib)
 
 (defgroup sachac-news nil
   "Sacha Chua's Emacs news customizations."
   :group 'applications)
 
-(defcustom sachac-news-git-command "git"
+(defcustom sachac-news-git-command
+  (eval-when-compile
+    (require 'vc-git)
+    vc-git-program)
   "Path or git command name.
 
 Valid values are \"/usr/bin/git\" or \"git\" if it is in the current PATH."
-  :type 'string
-  :group 'sachac-news) ;; defcustom
+  :type 'string) ;; defcustom
 
 (defcustom sachac-news-fold-category-regexp-list '()
   "A list of regexp strings of the matching categories that should be folded.
 
 The function `sachac-news-fold-categories' use this variable to find
 categories that the user wants to hide."
-  :type '(repeat regexp)
-  :group 'sachac-news) ;; defcustom
+  :type '(repeat regexp)) ;; defcustom
 
 (defcustom sachac-news-alarm-sound-file
   "/usr/share/sounds/freedesktop/stereo/bell.oga"
@@ -88,8 +87,7 @@ categories that the user wants to hide."
 If the value is nil or the file does not exists, the `ding' function is used.
 
 See `sachac-news-default-sound-alarm' function."
-  :type 'file
-  :group 'sachac-news) ;; defcustom
+  :type 'file) ;; defcustom
 
 (defcustom sachac-news-alarm-sound-programs
   '(("mpv" . "--really-quiet %s")
@@ -100,22 +98,20 @@ programs is founded on the system, the `ding' function will be used.  The
 first program founded is used.
 
 This variable is used by `sachac-news-default-sound-alarm' function."
-  :type '(alist :key-type string :value-type string)
-  :group 'sachac-news ) ;; defcustom
+  :type '(alist :key-type string :value-type string)) ;; defcustom
 
 (defcustom sachac-news-alarm-functions-hook
   '(sachac-news-default-notify-alarm
     sachac-news-default-sound-alarm)
   "The alarm functions.
 These functions are called when there are new news."
-  :type 'hook
-  :group 'sachac-news ) ;; defcustom
+  :type 'hook) ;; defcustom
 
 (defconst sachac-news-title-regexp
   "^\\*\\*[[:space:]]+[[:digit:]]+-[[:digit:]]+-[[:digit:]]+[[:space:]]+Emacs news"
-  "Regexp used to find news titles in the index.org file." ) ;; defconst
+  "Regexp used to find news titles in the index.org file.") ;; defconst
 
-(defvar sachac-news-timer-setted-time 0
+(defvar sachac-news-timer-setted-time 0	;perhaps mark these as internal: sachac-news--...
   "At what time the timer has been setted?
 See `sachac-news-set-timer'.")
 
@@ -148,66 +144,67 @@ Else, this variable contains nil.")
 
 If USE-INDEX-ORG is t, then load the index.org file.  Else, use the current
 buffer as if it is the index.org."
-
   (if use-index-org
       (with-temp-buffer
 	(insert-file-contents (sachac-news-git-index-org))
-	(sachac-news-take-last-new nil) )
+	(sachac-news-take-last-new nil))
     (progn
       (goto-char (point-min))
       (search-forward-regexp sachac-news-title-regexp)
       (let ((sachac-news-title (org-element-at-point)))
 	(buffer-substring-no-properties
 	 (org-element-property :begin sachac-news-title)
-	 (org-element-property :end sachac-news-title))))) )
+	 (org-element-property :end sachac-news-title))))))
 
-(defcustom sachac-news-data-directory (concat user-emacs-directory
-					     "sachac/")
+(defcustom sachac-news-data-directory
+  (locate-user-emacs-file "sachac")
   "Where is the data directory?"
-  :type 'directory
-  :group 'sachac-news) ;; defcustom
+  :type 'directory) ;; defcustom
 
-(defcustom sachac-news-data-file "data.el"
+(defcustom sachac-news-data-file "data.eld"
   "The configuration and data file.
 This is where the last updated date and other data is stored."
-  :type 'file
-  :group 'sachac-news) ;; defcustom
+  :type 'file) ;; defcustom
 
 (defcustom sachac-news-git-dirname "git"
   "The directory where the git repository should be cloned."
-  :type 'string
-  :group 'sachac-news)
+  :type 'string)
 
+;; She publishes the news every week around the beginning, why check
+;; every day?
 (defcustom sachac-news-update-hours-wait 24
   "The amount of hours when the git clone/pull must wait before be called.
 
 Default is 24 hours.  Only positive values should be used."
-  :type 'integer
-  :group 'sachac-news ) ;; defcustom
+  :type 'natnum
+  :group 'sachac-news) ;; defcustom
 
 (defun sachac-news-dir-git ()
   "Return the complete git path."
-  (concat sachac-news-data-directory "/" sachac-news-git-dirname) )
+  (expand-file-name  sachac-news-git-dirname sachac-news-data-directory))
 
 (defun sachac-news-dir-datafile ()
   "Return the complete data file path."
-  (concat sachac-news-data-directory "/" sachac-news-data-file) )
-
+  (expand-file-name sachac-news-data-file sachac-news-data-directory))
 
 (defun sachac-news-git-index-org ()
   "Return the index.org path on the git directory."
-  (concat (sachac-news-dir-git) "/emacs-news/index.org") )
+  (expand-file-name
+   "index.org"
+   (expand-file-name
+    "emacs-news"
+    (sachac-news-dir-git))))
 
 (defun sachac-news--show-last-new-internal ()
   "Show the last news.
 This is used after the update sentinel is executed.
 See `sachac-news-show-last-new'."
-  (let ((str (sachac-news-take-last-new t)))
+  (let ((str (sachac-news-take-last-new t))) ;unused!
     (with-current-buffer (get-buffer-create "*last-news*")
       (org-mode)
 
-      (delete-region (point-min) (point-max))
-      (insert str)
+      (erase-buffer)
+      (insert "foo")
       
       (goto-char (point-min))
 	
@@ -217,7 +214,7 @@ See `sachac-news-show-last-new'."
 	(sachac-news-update-last-saved-title)
 	(sachac-news-fold-categories))
 	
-      (display-buffer (current-buffer)))) )
+      (display-buffer (current-buffer)))))
 
 (defun sachac-news-show-last-new-if-new ()
   "Show the last new if there is a new title.
@@ -241,16 +238,12 @@ see `sachac-news-update-hours-wait' variable."
 			  #'sachac-news--show-last-new-internal
 			  #'sachac-news--show-last-new-internal))
 
-;;
-;; --------------------
-;; Last saved title
-;;
+;;; Last saved title
 
 (defun sachac-news-update-last-saved-title ()
   "Save the last title into the data file."
-
   (setq sachac-news-last-saved-title (sachac-news-get-last-title))
-  (sachac-news-save-data) )
+  (sachac-news-save-data))
 
 (defun sachac-news-get-last-title (&optional use-current-buffer)
   "Get the first title founded in the current buffer.
@@ -264,7 +257,7 @@ the last title.  Else, if t, use the current buffer, but remember to call
 	nil t)
     (with-temp-buffer
       (insert (sachac-news-take-last-new t))
-      (sachac-news-get-last-title t))) )
+      (sachac-news-get-last-title t))))
  
 (defun sachac-news-is-there-new-title-p (&optional use-current-buffer)
   "According to the last save, return t when a new post is found.
@@ -284,12 +277,9 @@ last news buffer.  Else, open the index.org and retrieve the last news."
 	     
     (or (null sachac-news-last-saved-title)
 	(not (string-equal last-title
-			   sachac-news-last-saved-title)))) )
+			   sachac-news-last-saved-title)))))
 
-;;
-;; --------------------
-;; Data or config. load/save
-;;
+;;; Data or config. load/save
 
 (defun sachac-news-load-data ()
   "Update variables which values are in the configuration file.
@@ -305,7 +295,7 @@ important variables."
 	(setq sachac-news-last-saved-title
 	      (alist-get 'last-saved-title expr))
 	;; Return the expression loaded
-	expr))) )
+	expr))))
 
 (defun sachac-news-save-data ()
   "Save some important variables into the data file.
@@ -313,20 +303,17 @@ These variables can be loaded again with `sachac-news-load-data'."
   (with-temp-buffer
     (let ((data (list (cons 'last-update sachac-news-last-update)
 		      (cons 'last-saved-title sachac-news-last-saved-title))))
-    (insert (prin1-to-string data))
-    (write-file (sachac-news-dir-datafile))
-    data)) )
+      (prin1 data (current-buffer))
+      (write-region nil nil (sachac-news-dir-datafile) nil 'silent)
+      data)))
 
 (defun sachac-news-load-data-if-needed ()
   "If the data has not been loaded yet, load it."
   (unless sachac-news-data-loaded
     (sachac-news-load-data)
-    (setq sachac-news-data-loaded t)) )
+    (setq sachac-news-data-loaded t)))
 
-;;
-;; --------------------
-;; Git clone/update
-;;
+;;; Git clone/update
 
 (defun sachac-news-update-last-update ()
   "Update the `sachac-news-last-update' date with the current date."
@@ -335,6 +322,7 @@ These variables can be loaded again with `sachac-news-load-data'."
 
 (defun sachac-news-update-time-str ()
   "Return a string with the last time and the amount of time left."
+  ;; Perhaps format this in a temporary buffer, then return the buffer string?
   (format "Waiting time: %s hours
 -- Update --
 Last time updated: %s
@@ -361,19 +349,19 @@ Time left for automatic forced update: %s %s"
 					     (* sachac-news-update-hours-wait 60 60)))
 	    "No timer setted")
 	  (number-to-string (/ (sachac-news-get-update-time-left) 60))
-	  "minutes") )
+	  "minutes"))
 
 (defun sachac-news-get-update-wait-seconds ()
   "Get the `sachac-news-update-hours-wait' in seconds."
-  (* sachac-news-update-hours-wait 60 60) )
+  (* sachac-news-update-hours-wait 60 60))
 
 (defun sachac-news-show-update-time ()
   "Display the time left for the next update."
   (interactive)
   (sachac-news-load-data-if-needed)
   (if sachac-news-last-update
-      (message (sachac-news-update-time-str))
-    (message "Git has not been called before.")) )
+      (message "%s" (sachac-news-update-time-str))
+    (message "Git has not been called before.")))
 
 (defun sachac-news-get-update-time-left ()
   "Return the seconds left for the next scheduled update.
@@ -384,7 +372,7 @@ been setted)."
   (if sachac-news-timer-setted-time
       (- (+ sachac-news-timer-setted-time (sachac-news-get-update-wait-seconds))
 	 (time-convert (current-time) 'integer))
-    0) )
+    0))
 
 (defun sachac-news-get-update-enable-time-left ()
   "Return the seconds left for the next enabled update.
@@ -398,7 +386,7 @@ loaded)."
   (if sachac-news-last-update
       (- (+ sachac-news-last-update (sachac-news-get-update-wait-seconds))
 	 (time-convert (current-time) 'integer))
-    0) )
+    0))
 
 (defun sachac-news-get-update-time-elapsed ()
   "Return the seconds elapsed since the last update.
@@ -408,19 +396,19 @@ Return the numbre of seconds after the maximum wait + 1 if
   (if sachac-news-last-update
       (- (time-convert (current-time) 'integer)
 	 sachac-news-last-update)
-    (+ (sachac-news-get-update-wait-seconds) 1)) )
+    (+ (sachac-news-get-update-wait-seconds) 1)))
 
 (defun sachac-news-is-time-for-update-p ()
   "Check if a day has passed since the last update."
   (if sachac-news-last-update
       (>= (sachac-news-get-update-time-elapsed)
-	 (sachac-news-get-update-wait-seconds) )
-    t) )
+	 (sachac-news-get-update-wait-seconds))
+    t))
 
 (defun sachac-news-create-dirs ()
   "Create the needed directories to save data and the repository."
   (make-directory sachac-news-data-directory t)
-  (make-directory (sachac-news-dir-git) t) )
+  (make-directory (sachac-news-dir-git) t))
 
 (defun sachac-news--git-sentinel (_process event)
   "Git sentinel.
@@ -454,19 +442,19 @@ FUNC-CALL-AFTER is a function called after the git process endend successfully."
     (when func-call-after
       (add-hook 'sachac-news--git-hook func-call-after))
     (setq sachac-news--git-process
-	  (if (file-exists-p (sachac-news-git-index-org))
-	      (start-process-shell-command "sachac-news-git-pull"
+	  (let ((default-directory (expand-file-name "emacs-news" (sachac-news-dir-git))))
+	    ;; I am not sure what the point is there, but I suspect
+	    ;; there should be a better way to do this using timers
+	    ;; and vc-git.
+	    (if (file-exists-p (sachac-news-git-index-org))
+		(start-process-shell-command "sachac-news-git-pull"
+					     "*sachac-news-git*"
+					     (concat "sleep 60 ; " git-program " pull"))
+	      (start-process-shell-command "sachac-news-git-clone"
 					   "*sachac-news-git*"
-					   (concat
-					    "cd " (sachac-news-dir-git) "/emacs-news ; sleep 60 ; "
-					    git-program
-					    " pull"))
-	    (start-process-shell-command "sachac-news-git-clone"
-					 "*sachac-news-git*"
-					 (concat
-					"cd " (sachac-news-dir-git) "; sleep 60 ; "
-					git-program " clone https://github.com/sachac/emacs-news.git"))))
-    (set-process-sentinel sachac-news--git-process #'sachac-news--git-sentinel)) )
+					   (concat "sleep 60 ; " git-program " clone \
+https://github.com/sachac/emacs-news.git")))))
+    (set-process-sentinel sachac-news--git-process #'sachac-news--git-sentinel)))
 
 
 (defun sachac-news-update-git (&optional force-update
@@ -501,11 +489,11 @@ pull/clone."
 	    (when callback-if-no-update
 	      (funcall callback-if-no-update))))
       ;; Git program not founded
-      (message "%s %s\n%s\n%s"
-	       "The Git program has not been founded!"
-	       "SachaC-news cannot download news without it!"
-	       "Please install it in our system or customize the variable:"
-	       "M-x customize-option sachac-news-git-command"))) )
+      (message (substitute-command-keys
+		"The Git program has not been founded! \
+SachaC-news cannot download news without it!
+Please install it in our system or customize the variable: )
+\\[customize-option] sachac-news-git-command")))))
 
 (defun sachac-news-open-index-file ()
   "Open the index.org file from the local repository.
@@ -519,15 +507,10 @@ how the update is done."
   (sachac-news-update-git)
   (if (file-exists-p (sachac-news-git-index-org))
       (find-file (sachac-news-git-index-org))
-    (message "%s\n%s"
-	     "Index file not found! Did something wrong happen?"
-	     "See `sachac-news-update-git'.")) )
+    (message "Index file not found! Did something wrong happen?
+See `sachac-news-update-git'.")))
 
-
-;;
-;; --------------------
-;; Folding categories
-;;
+;;; Folding categories
 
 (defun sachac-news-find-all-categories (category-regexps &optional org-element)
   "Match paragraph with the CATEGORY-REGEXPS regexp.
@@ -554,7 +537,7 @@ Returns a list of org-element of type \\'item found in the index.org."
 			  (string-match-p category element))
 			category-regexps))
 
-	    parent)))) )
+	    parent)))))
 
 
 (defun sachac-news-fold-all-items (item-list)
@@ -582,12 +565,9 @@ This function works on any Org file, even at the Emacs news' index.org."
   (let ((category-list (if category-regexp-list category-regexp-list
 			 sachac-news-fold-category-regexp-list)))
     (sachac-news-fold-all-items
-     (sachac-news-find-all-categories category-list))) )
+     (sachac-news-find-all-categories category-list))))
 
-;;
-;; --------------------
-;; Alarm
-;;
+;;; Alarm
 
 (defun sachac-news-default-notify-alarm ()
   "The default alarm.
@@ -596,7 +576,7 @@ Use the notify-send to send the alarm."
     (when program
       (shell-command (concat program
 			     " --app-name=\"Emacs: SachaC-news\""
-			     " \"Check the News!\"")))) )
+			     " \"Check the News!\"")))))
 
 (defun sachac-news-default-sound-alarm ()
   "The default sound alarm.
@@ -619,17 +599,14 @@ as fallback."
 	       (car program-data)
 	       (split-string
 		(format (cadr program-data) sachac-news-alarm-sound-file)))
-      (ding t))) )
+      (ding t))))
 
 (defun sachac-news-run-alarm-if-needed ()
   "Run the alarm hook functions if there is a new post ."
   (when (sachac-news-is-there-new-title-p)
-    (run-hooks 'sachac-news-alarm-functions-hook)) )
+    (run-hooks 'sachac-news-alarm-functions-hook)))
 
-;;
-;; --------------------
-;; Timer
-;;
+;;; Timer
 
 (defun sachac-news-timer-function ()
   "The function used by the timer."
@@ -638,7 +615,7 @@ as fallback."
   (sachac-news-update-git t #'sachac-news-show-last-new-if-new)
   (sachac-news-run-alarm-if-needed)
 
-  (sachac-news-activate-timer) )
+  (sachac-news-activate-timer))
 
 
 (defun sachac-news-activate-timer ()
@@ -650,9 +627,9 @@ Set the timer for executing on `sachac-news-update-hours-wait' hours."
   (setq sachac-news-timer-setted-time (time-convert (current-time) 'integer))
   (setq sachac-news-timer
 	(run-at-time
-	 (concat (number-to-string sachac-news-update-hours-wait) "hours")
-		     nil
-		     #'sachac-news-timer-function)) )
+	 (format "%d hours" sachac-news-update-hours-wait)
+	 nil
+	 #'sachac-news-timer-function)))
 
 (defun sachac-news-deactivate-timer ()
   "Stop and cancel the timer."
@@ -660,7 +637,7 @@ Set the timer for executing on `sachac-news-update-hours-wait' hours."
   (when (timerp sachac-news-timer)
     (cancel-timer sachac-news-timer)
     (setq sachac-news-timer nil))
-  (setq sachac-news-timer-setted-time nil) )
+  (setq sachac-news-timer-setted-time nil))
 
 (defun sachac-news-timer-status ()
   "Is the timer setted or not?
@@ -668,8 +645,13 @@ Report the user about the timer status."
   (interactive)
   (if (timerp sachac-news-timer)
       (message "Timer is setted and running.")
-    (message "Timer is deactivated")) )
+    (message "Timer is deactivated")))
+
+;; Don't activate side effects while loading your package!  Instruct
+;; the users to add this to their init.el, so that one knows what is
+;; going on.
 
-(sachac-news-activate-timer)
+;; (sachac-news-activate-timer)
 
+(provide 'sachac-news)
 ;;; sachac-news.el ends here

[-- Attachment #3: Type: text/plain, Size: 774 bytes --]


> According to http://elpa.gnu.org/, and the README.org [2] file
> linked there, it says to notify to this mail address as
> first step. Also, it mentions other steps regarding pushing the
> code and adding an entry on elpa-packages file. But, there is a
> marker above indicating "OUTDATED" [3].

That should be addressed ^^

> Please, could you tell me if these steps are needed?
> If they are not, how should I proceed?

As soon as we sort out the above comments, I can take care of adding the
package for you.

> Cheers!
> Christian Gimenez
>
> [1] https://github.com/purcell/flycheck-package
> [2] https://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/README
> [3] The section states: "Text below this marker is OUTDATED and
> still needs to be reviewed/rewritten!!"

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [ELPA] New package: SachaC-news
  2023-11-14  2:56 ` Richard Stallman
@ 2023-11-18 20:26   ` Christian
  2023-11-21 16:07     ` Sacha Chua
  0 siblings, 1 reply; 12+ messages in thread
From: Christian @ 2023-11-18 20:26 UTC (permalink / raw)
  To: rms; +Cc: Christian, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 5194 bytes --]

Hi!

On Mon, 13 Nov 2023 23:56:15 -0300,
Richard Stallman wrote:
>
> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > I want to propose SachaC-news (or sachac-news.el if you like)
>   > package to be included in ELPA.
>
> Are you the developer of the SachaC-news program?
> I would guess so, but I'd like to be sure rather than guess.

Yes, I am the developer... Well, now, Philip Kaluderci is too a
developer of SachaC-news :)

>
>                                     Its objective is to check for
>   > Sacha Chua's news repository periodically, and to show the Org
>   > file if there is a new commit with a new post in it.
>
> What other formats does this repository store postings in?  If it has
> -- or can generate -- plain text, that should be preferred.
> There are users who like Org fornat, but it is not Emacs's preferred
> way of showing information.

Sacha Chua creates her blog posts using this file written in
Org-mode. This mode is installed by default on Emacs 29 [1] and
can export to other formats: LaTeX, HTML, plain text, TeXInfo
and info (by installing ox-texinfo), etc.

Mmm... I suppose... I can add a customization to show an
exported buffer instead the Org-mode buffer. For example, if
sachac-news-show-plain-text is set to t, it  will do the
overall process, but add an extra step to export the Org file
into plain text... or even generalize this idea to use any
export dispatch function... I believe it can be
implemented... what do you think?

>
>   > The
>   > requirement is the git program to be installed on your system.
>
> Could you say what task it does using git?  Is Sacha's news repository
> a git repository?  That might be ok, but where is it?  I hope not
> github!  Where is that archive stored?  Can you please tell us its
> URL?

Sure, it uses "git clone URL" to clone the repository if it
does not exists; or it updates the current local repository by
executing "git pull" [2].

Recently, I have just added a customization variable to set the
URL to Sacha's Emacs News repository (see [3]). By default, its
value is [4] which is a clone of the original. This repository
will be automatically updated once a day, if there is a new
blog post. However, you can change it to any other repository
URL with an index.org file if you like.

>
> We deprecate use of github, so if we are going to have Emacs use a
> specific git repo for particular purposes, we should put it on a repo
> site that we recommend.

Oh! I found the article "GNU Ethical Repository Criteria
Evaluations" [5] which eases me to search for a new repository
service to move the project (thanks for writing it!). According
to the table in it, I decided to move sachac-news repository to
sr.ht, which is grade B ("Good enough to recommend").

I have an account on savannah.gnu.org. If it is needed, I can
request a new repository there. But it will require some time
to be approved.

>
> The name SachaC-News suggests that Sacha Chua maintains that archive.
> Is that correct?

Sacha Chua maintains her emacs-news blog posts [6], and creates
them by using the index.org file in that archive (or so it
seems as far as I can understand the code in it, I have not
asked her yet!).

>
> What formats does it store articles in?  Is Org
> format the only one?

Her repository has only the index.org file. But, it can be
exported to other formats too.

>
> Org format is NOT the Emacs standard or preferred format, and not
> everyone uses it.  Therefore, if we add a command to display some
> useful information, it should not use Org format.
>
> The best format to use is plain text.

Maybe, the name "Org" is not correct? I mean Org-mode [7] (I
call it "Org" casually, sorry for that)... I thought it is
considered as a plain text format. I love it and use it
for... well... almost everything. If I am wrong in any way,
please tell me.

>
> --
> Dr Richard Stallman (https://stallman.org)
> Chief GNUisance of the GNU Project (https://gnu.org)
> Founder, Free Software Foundation (https://fsf.org)
> Internet Hall-of-Famer (https://internethalloffame.org)
>
>

Cheers!
Christian.

[1] This is the Org-mode at the latest commit in Emacs 29
repository:
https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/org?h=emacs-29&id=da946ca6924b5ba1a1c785284406cf894aef12b5

[2] This line implements the git clone and git update:
https://git.sr.ht/~cngimenez/sachac-news/tree/6798169e06f12543346753602406476e7af288f1/item/sachac-news.el#L460

[3] sachac-news-sacha-repository-url at this line:
https://git.sr.ht/~cngimenez/sachac-news/tree/6798169e06f12543346753602406476e7af288f1/item/sachac-news.el#L114

[4] https://git.sr.ht/~cngimenez/sachac-emacs-news

[5] https://www.gnu.org/software/repo-criteria-evaluation.html

[6] https://sachachua.com/blog/category/emacs-news/

[7] https://orgmode.org/

--

- Mastodon: @cnngimenez@mastodon.social

 ,= ,-_-. =.  Utilice GPG:
((_/)o o(\_)) * https://emailselfdefense.fsf.org/
 `-'(. .)`-'  * Usando la terminal GNU/Linux:
     \_/        $ gpg2 --search-keys 77A56F0DA5DD9E05

[-- Attachment #2: OpenPGP Digital Signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ELPA] New package: SachaC-news
  2023-11-17  7:28 ` Philip Kaludercic
@ 2023-11-18 20:30   ` Christian
  2023-11-18 21:10     ` Philip Kaludercic
  0 siblings, 1 reply; 12+ messages in thread
From: Christian @ 2023-11-18 20:30 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Christian, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 20911 bytes --]


Thanks Philip!

I applied the diff to this commit:

https://git.sr.ht/~cngimenez/sachac-news/commit/8263dbc7982f543f673172c4a60d4bb68a48c6f6

Cheers!
Christian.

On Fri, 17 Nov 2023 04:28:35 -0300, Kaludercic wrote:
>
> [1  <text/plain (7bit)>]
> Christian <cnngimenez@disroot.org> writes:
>
> > Hi!
> >
> > I want to propose SachaC-news (or sachac-news.el if you like)
> > package to be included in ELPA. Its objective is to check for
> > Sacha Chua's news repository periodically, and to show the Org
> > file if there is a new commit with a new post in it. It has
> > some customizations too, such as folding specific sections
> > automatically, and desktop notifications via "notify-send". The
> > requirement is the git program to be installed on your system.
> > This information and its usage is at the README.org file at the
> > package repository:
> >
> >           https://github.com/cnngimenez/sachac-news
> >
> > The code has been checked with byte-compile-file, and
> > flycheck configured with checkdoc and flycheck-package [1].
>
> > They do not display any warnings up to commit d00e629, but tell
> > me if you find something to fix or any suggestions.
>
> I found a few things, here is a diff with some comments and suggestions:
>
> [2  <text/plain (7bit)>]
> diff --git a/sachac-news.el b/sachac-news.el
> index 8d67911..1f389b2 100644
> --- a/sachac-news.el
> +++ b/sachac-news.el
> @@ -22,7 +22,6 @@
>  ;; You should have received a copy of the GNU General Public License
>  ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
>
> -
>  ;;; Commentary:
>
>  ;; Check periodically for new commits on Sacha Chua's news repository.
> @@ -58,29 +57,29 @@
>
>  ;;; Code:
>
> -(provide 'sachac-news)
>  (require 'org-element)
>  (require 'org-list)
> -(require 'cl-extra)
> +(require 'cl-lib)
>
>  (defgroup sachac-news nil
>    "Sacha Chua's Emacs news customizations."
>    :group 'applications)
>
> -(defcustom sachac-news-git-command "git"
> +(defcustom sachac-news-git-command
> +  (eval-when-compile
> +    (require 'vc-git)
> +    vc-git-program)
>    "Path or git command name.
>
>  Valid values are \"/usr/bin/git\" or \"git\" if it is in the current PATH."
> -  :type 'string
> -  :group 'sachac-news) ;; defcustom
> +  :type 'string) ;; defcustom
>
>  (defcustom sachac-news-fold-category-regexp-list '()
>    "A list of regexp strings of the matching categories that should be folded.
>
>  The function `sachac-news-fold-categories' use this variable to find
>  categories that the user wants to hide."
> -  :type '(repeat regexp)
> -  :group 'sachac-news) ;; defcustom
> +  :type '(repeat regexp)) ;; defcustom
>
>  (defcustom sachac-news-alarm-sound-file
>    "/usr/share/sounds/freedesktop/stereo/bell.oga"
> @@ -88,8 +87,7 @@ categories that the user wants to hide."
>  If the value is nil or the file does not exists, the `ding' function is used.
>
>  See `sachac-news-default-sound-alarm' function."
> -  :type 'file
> -  :group 'sachac-news) ;; defcustom
> +  :type 'file) ;; defcustom
>
>  (defcustom sachac-news-alarm-sound-programs
>    '(("mpv" . "--really-quiet %s")
> @@ -100,22 +98,20 @@ programs is founded on the system, the `ding' function will be used.  The
>  first program founded is used.
>
>  This variable is used by `sachac-news-default-sound-alarm' function."
> -  :type '(alist :key-type string :value-type string)
> -  :group 'sachac-news ) ;; defcustom
> +  :type '(alist :key-type string :value-type string)) ;; defcustom
>
>  (defcustom sachac-news-alarm-functions-hook
>    '(sachac-news-default-notify-alarm
>      sachac-news-default-sound-alarm)
>    "The alarm functions.
>  These functions are called when there are new news."
> -  :type 'hook
> -  :group 'sachac-news ) ;; defcustom
> +  :type 'hook) ;; defcustom
>
>  (defconst sachac-news-title-regexp
>    "^\\*\\*[[:space:]]+[[:digit:]]+-[[:digit:]]+-[[:digit:]]+[[:space:]]+Emacs news"
> -  "Regexp used to find news titles in the index.org file." ) ;; defconst
> +  "Regexp used to find news titles in the index.org file.") ;; defconst
>
> -(defvar sachac-news-timer-setted-time 0
> +(defvar sachac-news-timer-setted-time 0	;perhaps mark these as internal: sachac-news--...
>    "At what time the timer has been setted?
>  See `sachac-news-set-timer'.")
>
> @@ -148,66 +144,67 @@ Else, this variable contains nil.")
>
>  If USE-INDEX-ORG is t, then load the index.org file.  Else, use the current
>  buffer as if it is the index.org."
> -
>    (if use-index-org
>        (with-temp-buffer
>  	(insert-file-contents (sachac-news-git-index-org))
> -	(sachac-news-take-last-new nil) )
> +	(sachac-news-take-last-new nil))
>      (progn
>        (goto-char (point-min))
>        (search-forward-regexp sachac-news-title-regexp)
>        (let ((sachac-news-title (org-element-at-point)))
>  	(buffer-substring-no-properties
>  	 (org-element-property :begin sachac-news-title)
> -	 (org-element-property :end sachac-news-title))))) )
> +	 (org-element-property :end sachac-news-title))))))
>
> -(defcustom sachac-news-data-directory (concat user-emacs-directory
> -					     "sachac/")
> +(defcustom sachac-news-data-directory
> +  (locate-user-emacs-file "sachac")
>    "Where is the data directory?"
> -  :type 'directory
> -  :group 'sachac-news) ;; defcustom
> +  :type 'directory) ;; defcustom
>
> -(defcustom sachac-news-data-file "data.el"
> +(defcustom sachac-news-data-file "data.eld"
>    "The configuration and data file.
>  This is where the last updated date and other data is stored."
> -  :type 'file
> -  :group 'sachac-news) ;; defcustom
> +  :type 'file) ;; defcustom
>
>  (defcustom sachac-news-git-dirname "git"
>    "The directory where the git repository should be cloned."
> -  :type 'string
> -  :group 'sachac-news)
> +  :type 'string)
>
> +;; She publishes the news every week around the beginning, why check
> +;; every day?
>  (defcustom sachac-news-update-hours-wait 24
>    "The amount of hours when the git clone/pull must wait before be called.
>
>  Default is 24 hours.  Only positive values should be used."
> -  :type 'integer
> -  :group 'sachac-news ) ;; defcustom
> +  :type 'natnum
> +  :group 'sachac-news) ;; defcustom
>
>  (defun sachac-news-dir-git ()
>    "Return the complete git path."
> -  (concat sachac-news-data-directory "/" sachac-news-git-dirname) )
> +  (expand-file-name  sachac-news-git-dirname sachac-news-data-directory))
>
>  (defun sachac-news-dir-datafile ()
>    "Return the complete data file path."
> -  (concat sachac-news-data-directory "/" sachac-news-data-file) )
> -
> +  (expand-file-name sachac-news-data-file sachac-news-data-directory))
>
>  (defun sachac-news-git-index-org ()
>    "Return the index.org path on the git directory."
> -  (concat (sachac-news-dir-git) "/emacs-news/index.org") )
> +  (expand-file-name
> +   "index.org"
> +   (expand-file-name
> +    "emacs-news"
> +    (sachac-news-dir-git))))
>
>  (defun sachac-news--show-last-new-internal ()
>    "Show the last news.
>  This is used after the update sentinel is executed.
>  See `sachac-news-show-last-new'."
> -  (let ((str (sachac-news-take-last-new t)))
> +  (let ((str (sachac-news-take-last-new t))) ;unused!
>      (with-current-buffer (get-buffer-create "*last-news*")
>        (org-mode)
>
> -      (delete-region (point-min) (point-max))
> -      (insert str)
> +      (erase-buffer)
> +      (insert "foo")
>
>        (goto-char (point-min))
>
> @@ -217,7 +214,7 @@ See `sachac-news-show-last-new'."
>  	(sachac-news-update-last-saved-title)
>  	(sachac-news-fold-categories))
>
> -      (display-buffer (current-buffer)))) )
> +      (display-buffer (current-buffer)))))
>
>  (defun sachac-news-show-last-new-if-new ()
>    "Show the last new if there is a new title.
> @@ -241,16 +238,12 @@ see `sachac-news-update-hours-wait' variable."
>  			  #'sachac-news--show-last-new-internal
>  			  #'sachac-news--show-last-new-internal))
>
> -;;
> -;; --------------------
> -;; Last saved title
> -;;
> +;;; Last saved title
>
>  (defun sachac-news-update-last-saved-title ()
>    "Save the last title into the data file."
> -
>    (setq sachac-news-last-saved-title (sachac-news-get-last-title))
> -  (sachac-news-save-data) )
> +  (sachac-news-save-data))
>
>  (defun sachac-news-get-last-title (&optional use-current-buffer)
>    "Get the first title founded in the current buffer.
> @@ -264,7 +257,7 @@ the last title.  Else, if t, use the current buffer, but remember to call
>  	nil t)
>      (with-temp-buffer
>        (insert (sachac-news-take-last-new t))
> -      (sachac-news-get-last-title t))) )
> +      (sachac-news-get-last-title t))))
>
>  (defun sachac-news-is-there-new-title-p (&optional use-current-buffer)
>    "According to the last save, return t when a new post is found.
> @@ -284,12 +277,9 @@ last news buffer.  Else, open the index.org and retrieve the last news."
>
>      (or (null sachac-news-last-saved-title)
>  	(not (string-equal last-title
> -			   sachac-news-last-saved-title)))) )
> +			   sachac-news-last-saved-title)))))
>
> -;;
> -;; --------------------
> -;; Data or config. load/save
> -;;
> +;;; Data or config. load/save
>
>  (defun sachac-news-load-data ()
>    "Update variables which values are in the configuration file.
> @@ -305,7 +295,7 @@ important variables."
>  	(setq sachac-news-last-saved-title
>  	      (alist-get 'last-saved-title expr))
>  	;; Return the expression loaded
> -	expr))) )
> +	expr))))
>
>  (defun sachac-news-save-data ()
>    "Save some important variables into the data file.
> @@ -313,20 +303,17 @@ These variables can be loaded again with `sachac-news-load-data'."
>    (with-temp-buffer
>      (let ((data (list (cons 'last-update sachac-news-last-update)
>  		      (cons 'last-saved-title sachac-news-last-saved-title))))
> -    (insert (prin1-to-string data))
> -    (write-file (sachac-news-dir-datafile))
> -    data)) )
> +      (prin1 data (current-buffer))
> +      (write-region nil nil (sachac-news-dir-datafile) nil 'silent)
> +      data)))
>
>  (defun sachac-news-load-data-if-needed ()
>    "If the data has not been loaded yet, load it."
>    (unless sachac-news-data-loaded
>      (sachac-news-load-data)
> -    (setq sachac-news-data-loaded t)) )
> +    (setq sachac-news-data-loaded t)))
>
> -;;
> -;; --------------------
> -;; Git clone/update
> -;;
> +;;; Git clone/update
>
>  (defun sachac-news-update-last-update ()
>    "Update the `sachac-news-last-update' date with the current date."
> @@ -335,6 +322,7 @@ These variables can be loaded again with `sachac-news-load-data'."
>
>  (defun sachac-news-update-time-str ()
>    "Return a string with the last time and the amount of time left."
> +  ;; Perhaps format this in a temporary buffer, then return the buffer string?
>    (format "Waiting time: %s hours
>  -- Update --
>  Last time updated: %s
> @@ -361,19 +349,19 @@ Time left for automatic forced update: %s %s"
>  					     (* sachac-news-update-hours-wait 60 60)))
>  	    "No timer setted")
>  	  (number-to-string (/ (sachac-news-get-update-time-left) 60))
> -	  "minutes") )
> +	  "minutes"))
>
>  (defun sachac-news-get-update-wait-seconds ()
>    "Get the `sachac-news-update-hours-wait' in seconds."
> -  (* sachac-news-update-hours-wait 60 60) )
> +  (* sachac-news-update-hours-wait 60 60))
>
>  (defun sachac-news-show-update-time ()
>    "Display the time left for the next update."
>    (interactive)
>    (sachac-news-load-data-if-needed)
>    (if sachac-news-last-update
> -      (message (sachac-news-update-time-str))
> -    (message "Git has not been called before.")) )
> +      (message "%s" (sachac-news-update-time-str))
> +    (message "Git has not been called before.")))
>
>  (defun sachac-news-get-update-time-left ()
>    "Return the seconds left for the next scheduled update.
> @@ -384,7 +372,7 @@ been setted)."
>    (if sachac-news-timer-setted-time
>        (- (+ sachac-news-timer-setted-time (sachac-news-get-update-wait-seconds))
>  	 (time-convert (current-time) 'integer))
> -    0) )
> +    0))
>
>  (defun sachac-news-get-update-enable-time-left ()
>    "Return the seconds left for the next enabled update.
> @@ -398,7 +386,7 @@ loaded)."
>    (if sachac-news-last-update
>        (- (+ sachac-news-last-update (sachac-news-get-update-wait-seconds))
>  	 (time-convert (current-time) 'integer))
> -    0) )
> +    0))
>
>  (defun sachac-news-get-update-time-elapsed ()
>    "Return the seconds elapsed since the last update.
> @@ -408,19 +396,19 @@ Return the numbre of seconds after the maximum wait + 1 if
>    (if sachac-news-last-update
>        (- (time-convert (current-time) 'integer)
>  	 sachac-news-last-update)
> -    (+ (sachac-news-get-update-wait-seconds) 1)) )
> +    (+ (sachac-news-get-update-wait-seconds) 1)))
>
>  (defun sachac-news-is-time-for-update-p ()
>    "Check if a day has passed since the last update."
>    (if sachac-news-last-update
>        (>= (sachac-news-get-update-time-elapsed)
> -	 (sachac-news-get-update-wait-seconds) )
> -    t) )
> +	 (sachac-news-get-update-wait-seconds))
> +    t))
>
>  (defun sachac-news-create-dirs ()
>    "Create the needed directories to save data and the repository."
>    (make-directory sachac-news-data-directory t)
> -  (make-directory (sachac-news-dir-git) t) )
> +  (make-directory (sachac-news-dir-git) t))
>
>  (defun sachac-news--git-sentinel (_process event)
>    "Git sentinel.
> @@ -454,19 +442,19 @@ FUNC-CALL-AFTER is a function called after the git process endend successfully."
>      (when func-call-after
>        (add-hook 'sachac-news--git-hook func-call-after))
>      (setq sachac-news--git-process
> -	  (if (file-exists-p (sachac-news-git-index-org))
> -	      (start-process-shell-command "sachac-news-git-pull"
> +	  (let ((default-directory (expand-file-name "emacs-news" (sachac-news-dir-git))))
> +	    ;; I am not sure what the point is there, but I suspect
> +	    ;; there should be a better way to do this using timers
> +	    ;; and vc-git.
> +	    (if (file-exists-p (sachac-news-git-index-org))
> +		(start-process-shell-command "sachac-news-git-pull"
> +					     "*sachac-news-git*"
> +					     (concat "sleep 60 ; " git-program " pull"))
> +	      (start-process-shell-command "sachac-news-git-clone"
>  					   "*sachac-news-git*"
> -					   (concat
> -					    "cd " (sachac-news-dir-git) "/emacs-news ; sleep 60 ; "
> -					    git-program
> -					    " pull"))
> -	    (start-process-shell-command "sachac-news-git-clone"
> -					 "*sachac-news-git*"
> -					 (concat
> -					"cd " (sachac-news-dir-git) "; sleep 60 ; "
> -					git-program " clone https://github.com/sachac/emacs-news.git"))))
> -    (set-process-sentinel sachac-news--git-process #'sachac-news--git-sentinel)) )
> +					   (concat "sleep 60 ; " git-program " clone \
> +https://github.com/sachac/emacs-news.git")))))
> +    (set-process-sentinel sachac-news--git-process #'sachac-news--git-sentinel)))
>
>
>  (defun sachac-news-update-git (&optional force-update
> @@ -501,11 +489,11 @@ pull/clone."
>  	    (when callback-if-no-update
>  	      (funcall callback-if-no-update))))
>        ;; Git program not founded
> -      (message "%s %s\n%s\n%s"
> -	       "The Git program has not been founded!"
> -	       "SachaC-news cannot download news without it!"
> -	       "Please install it in our system or customize the variable:"
> -	       "M-x customize-option sachac-news-git-command"))) )
> +      (message (substitute-command-keys
> +		"The Git program has not been founded! \
> +SachaC-news cannot download news without it!
> +Please install it in our system or customize the variable: )
> +\\[customize-option] sachac-news-git-command")))))
>
>  (defun sachac-news-open-index-file ()
>    "Open the index.org file from the local repository.
> @@ -519,15 +507,10 @@ how the update is done."
>    (sachac-news-update-git)
>    (if (file-exists-p (sachac-news-git-index-org))
>        (find-file (sachac-news-git-index-org))
> -    (message "%s\n%s"
> -	     "Index file not found! Did something wrong happen?"
> -	     "See `sachac-news-update-git'.")) )
> +    (message "Index file not found! Did something wrong happen?
> +See `sachac-news-update-git'.")))
>
> -
> -;;
> -;; --------------------
> -;; Folding categories
> -;;
> +;;; Folding categories
>
>  (defun sachac-news-find-all-categories (category-regexps &optional org-element)
>    "Match paragraph with the CATEGORY-REGEXPS regexp.
> @@ -554,7 +537,7 @@ Returns a list of org-element of type \\'item found in the index.org."
>  			  (string-match-p category element))
>  			category-regexps))
>
> -	    parent)))) )
> +	    parent)))))
>
>
>  (defun sachac-news-fold-all-items (item-list)
> @@ -582,12 +565,9 @@ This function works on any Org file, even at the Emacs news' index.org."
>    (let ((category-list (if category-regexp-list category-regexp-list
>  			 sachac-news-fold-category-regexp-list)))
>      (sachac-news-fold-all-items
> -     (sachac-news-find-all-categories category-list))) )
> +     (sachac-news-find-all-categories category-list))))
>
> -;;
> -;; --------------------
> -;; Alarm
> -;;
> +;;; Alarm
>
>  (defun sachac-news-default-notify-alarm ()
>    "The default alarm.
> @@ -596,7 +576,7 @@ Use the notify-send to send the alarm."
>      (when program
>        (shell-command (concat program
>  			     " --app-name=\"Emacs: SachaC-news\""
> -			     " \"Check the News!\"")))) )
> +			     " \"Check the News!\"")))))
>
>  (defun sachac-news-default-sound-alarm ()
>    "The default sound alarm.
> @@ -619,17 +599,14 @@ as fallback."
>  	       (car program-data)
>  	       (split-string
>  		(format (cadr program-data) sachac-news-alarm-sound-file)))
> -      (ding t))) )
> +      (ding t))))
>
>  (defun sachac-news-run-alarm-if-needed ()
>    "Run the alarm hook functions if there is a new post ."
>    (when (sachac-news-is-there-new-title-p)
> -    (run-hooks 'sachac-news-alarm-functions-hook)) )
> +    (run-hooks 'sachac-news-alarm-functions-hook)))
>
> -;;
> -;; --------------------
> -;; Timer
> -;;
> +;;; Timer
>
>  (defun sachac-news-timer-function ()
>    "The function used by the timer."
> @@ -638,7 +615,7 @@ as fallback."
>    (sachac-news-update-git t #'sachac-news-show-last-new-if-new)
>    (sachac-news-run-alarm-if-needed)
>
> -  (sachac-news-activate-timer) )
> +  (sachac-news-activate-timer))
>
>
>  (defun sachac-news-activate-timer ()
> @@ -650,9 +627,9 @@ Set the timer for executing on `sachac-news-update-hours-wait' hours."
>    (setq sachac-news-timer-setted-time (time-convert (current-time) 'integer))
>    (setq sachac-news-timer
>  	(run-at-time
> -	 (concat (number-to-string sachac-news-update-hours-wait) "hours")
> -		     nil
> -		     #'sachac-news-timer-function)) )
> +	 (format "%d hours" sachac-news-update-hours-wait)
> +	 nil
> +	 #'sachac-news-timer-function)))
>
>  (defun sachac-news-deactivate-timer ()
>    "Stop and cancel the timer."
> @@ -660,7 +637,7 @@ Set the timer for executing on `sachac-news-update-hours-wait' hours."
>    (when (timerp sachac-news-timer)
>      (cancel-timer sachac-news-timer)
>      (setq sachac-news-timer nil))
> -  (setq sachac-news-timer-setted-time nil) )
> +  (setq sachac-news-timer-setted-time nil))
>
>  (defun sachac-news-timer-status ()
>    "Is the timer setted or not?
> @@ -668,8 +645,13 @@ Report the user about the timer status."
>    (interactive)
>    (if (timerp sachac-news-timer)
>        (message "Timer is setted and running.")
> -    (message "Timer is deactivated")) )
> +    (message "Timer is deactivated")))
> +
> +;; Don't activate side effects while loading your package!  Instruct
> +;; the users to add this to their init.el, so that one knows what is
> +;; going on.
>
> -(sachac-news-activate-timer)
> +;; (sachac-news-activate-timer)
>
> +(provide 'sachac-news)
>  ;;; sachac-news.el ends here
> [3  <text/plain (7bit)>]
>
> > According to http://elpa.gnu.org/, and the README.org [2] file
> > linked there, it says to notify to this mail address as
> > first step. Also, it mentions other steps regarding pushing the
> > code and adding an entry on elpa-packages file. But, there is a
> > marker above indicating "OUTDATED" [3].
>
> That should be addressed ^^
>
> > Please, could you tell me if these steps are needed?
> > If they are not, how should I proceed?
>
> As soon as we sort out the above comments, I can take care of adding the
> package for you.
>
> > Cheers!
> > Christian Gimenez
> >
> > [1] https://github.com/purcell/flycheck-package
> > [2] https://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/README
> > [3] The section states: "Text below this marker is OUTDATED and
> > still needs to be reviewed/rewritten!!"

--

- Mastodon: @cnngimenez@mastodon.social

 ,= ,-_-. =.  Utilice GPG:
((_/)o o(\_)) * https://emailselfdefense.fsf.org/
 `-'(. .)`-'  * Usando la terminal GNU/Linux:
     \_/        $ gpg2 --search-keys 77A56F0DA5DD9E05

[-- Attachment #2: OpenPGP Digital Signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ELPA] New package: SachaC-news
  2023-11-18 20:30   ` Christian
@ 2023-11-18 21:10     ` Philip Kaludercic
  2023-11-25 22:07       ` Christian
  0 siblings, 1 reply; 12+ messages in thread
From: Philip Kaludercic @ 2023-11-18 21:10 UTC (permalink / raw)
  To: Christian; +Cc: emacs-devel

Christian <cnngimenez@disroot.org> writes:

> Thanks Philip!
>
> I applied the diff to this commit:
>
> https://git.sr.ht/~cngimenez/sachac-news/commit/8263dbc7982f543f673172c4a60d4bb68a48c6f6

It appears you applied my comments as well?  I should have made it
clear, that my message just intended to propose some changes,
demonstrate possible alternatives and raise some questions for us to
discuss.

> Cheers!
> Christian.
>
> On Fri, 17 Nov 2023 04:28:35 -0300, Kaludercic wrote:
>>
>> [1  <text/plain (7bit)>]
>> Christian <cnngimenez@disroot.org> writes:
>>
>> > Hi!
>> >
>> > I want to propose SachaC-news (or sachac-news.el if you like)
>> > package to be included in ELPA. Its objective is to check for
>> > Sacha Chua's news repository periodically, and to show the Org
>> > file if there is a new commit with a new post in it. It has
>> > some customizations too, such as folding specific sections
>> > automatically, and desktop notifications via "notify-send". The
>> > requirement is the git program to be installed on your system.
>> > This information and its usage is at the README.org file at the
>> > package repository:
>> >
>> >           https://github.com/cnngimenez/sachac-news
>> >
>> > The code has been checked with byte-compile-file, and
>> > flycheck configured with checkdoc and flycheck-package [1].
>>
>> > They do not display any warnings up to commit d00e629, but tell
>> > me if you find something to fix or any suggestions.
>>
>> I found a few things, here is a diff with some comments and suggestions:
>>
>> [2  <text/plain (7bit)>]
>> diff --git a/sachac-news.el b/sachac-news.el
>> index 8d67911..1f389b2 100644
>> --- a/sachac-news.el
>> +++ b/sachac-news.el
>> @@ -22,7 +22,6 @@
>>  ;; You should have received a copy of the GNU General Public License
>>  ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
>>
>> -
>>  ;;; Commentary:
>>
>>  ;; Check periodically for new commits on Sacha Chua's news repository.
>> @@ -58,29 +57,29 @@
>>
>>  ;;; Code:
>>
>> -(provide 'sachac-news)
>>  (require 'org-element)
>>  (require 'org-list)
>> -(require 'cl-extra)
>> +(require 'cl-lib)
>>
>>  (defgroup sachac-news nil
>>    "Sacha Chua's Emacs news customizations."
>>    :group 'applications)
>>
>> -(defcustom sachac-news-git-command "git"
>> +(defcustom sachac-news-git-command
>> +  (eval-when-compile
>> +    (require 'vc-git)
>> +    vc-git-program)
>>    "Path or git command name.
>>
>>  Valid values are \"/usr/bin/git\" or \"git\" if it is in the current PATH."
>> -  :type 'string
>> -  :group 'sachac-news) ;; defcustom
>> +  :type 'string) ;; defcustom
>>
>>  (defcustom sachac-news-fold-category-regexp-list '()
>>    "A list of regexp strings of the matching categories that should be folded.
>>
>>  The function `sachac-news-fold-categories' use this variable to find
>>  categories that the user wants to hide."
>> -  :type '(repeat regexp)
>> -  :group 'sachac-news) ;; defcustom
>> +  :type '(repeat regexp)) ;; defcustom
>>
>>  (defcustom sachac-news-alarm-sound-file
>>    "/usr/share/sounds/freedesktop/stereo/bell.oga"
>> @@ -88,8 +87,7 @@ categories that the user wants to hide."
>>  If the value is nil or the file does not exists, the `ding' function is used.
>>
>>  See `sachac-news-default-sound-alarm' function."
>> -  :type 'file
>> -  :group 'sachac-news) ;; defcustom
>> +  :type 'file) ;; defcustom
>>
>>  (defcustom sachac-news-alarm-sound-programs
>>    '(("mpv" . "--really-quiet %s")
>> @@ -100,22 +98,20 @@ programs is founded on the system, the `ding' function will be used.  The
>>  first program founded is used.
>>
>>  This variable is used by `sachac-news-default-sound-alarm' function."
>> -  :type '(alist :key-type string :value-type string)
>> -  :group 'sachac-news ) ;; defcustom
>> +  :type '(alist :key-type string :value-type string)) ;; defcustom
>>
>>  (defcustom sachac-news-alarm-functions-hook
>>    '(sachac-news-default-notify-alarm
>>      sachac-news-default-sound-alarm)
>>    "The alarm functions.
>>  These functions are called when there are new news."
>> -  :type 'hook
>> -  :group 'sachac-news ) ;; defcustom
>> +  :type 'hook) ;; defcustom
>>
>>  (defconst sachac-news-title-regexp
>>    "^\\*\\*[[:space:]]+[[:digit:]]+-[[:digit:]]+-[[:digit:]]+[[:space:]]+Emacs news"
>> -  "Regexp used to find news titles in the index.org file." ) ;; defconst
>> +  "Regexp used to find news titles in the index.org file.") ;; defconst
>>
>> -(defvar sachac-news-timer-setted-time 0
>> +(defvar sachac-news-timer-setted-time 0	;perhaps mark these as internal: sachac-news--...
>>    "At what time the timer has been setted?
>>  See `sachac-news-set-timer'.")
>>
>> @@ -148,66 +144,67 @@ Else, this variable contains nil.")
>>
>>  If USE-INDEX-ORG is t, then load the index.org file.  Else, use the current
>>  buffer as if it is the index.org."
>> -
>>    (if use-index-org
>>        (with-temp-buffer
>>  	(insert-file-contents (sachac-news-git-index-org))
>> -	(sachac-news-take-last-new nil) )
>> +	(sachac-news-take-last-new nil))
>>      (progn
>>        (goto-char (point-min))
>>        (search-forward-regexp sachac-news-title-regexp)
>>        (let ((sachac-news-title (org-element-at-point)))
>>  	(buffer-substring-no-properties
>>  	 (org-element-property :begin sachac-news-title)
>> -	 (org-element-property :end sachac-news-title))))) )
>> +	 (org-element-property :end sachac-news-title))))))
>>
>> -(defcustom sachac-news-data-directory (concat user-emacs-directory
>> -					     "sachac/")
>> +(defcustom sachac-news-data-directory
>> +  (locate-user-emacs-file "sachac")
>>    "Where is the data directory?"
>> -  :type 'directory
>> -  :group 'sachac-news) ;; defcustom
>> +  :type 'directory) ;; defcustom
>>
>> -(defcustom sachac-news-data-file "data.el"
>> +(defcustom sachac-news-data-file "data.eld"
>>    "The configuration and data file.
>>  This is where the last updated date and other data is stored."
>> -  :type 'file
>> -  :group 'sachac-news) ;; defcustom
>> +  :type 'file) ;; defcustom
>>
>>  (defcustom sachac-news-git-dirname "git"
>>    "The directory where the git repository should be cloned."
>> -  :type 'string
>> -  :group 'sachac-news)
>> +  :type 'string)
>>
>> +;; She publishes the news every week around the beginning, why check
>> +;; every day?
>>  (defcustom sachac-news-update-hours-wait 24
>>    "The amount of hours when the git clone/pull must wait before be called.
>>
>>  Default is 24 hours.  Only positive values should be used."
>> -  :type 'integer
>> -  :group 'sachac-news ) ;; defcustom
>> +  :type 'natnum
>> +  :group 'sachac-news) ;; defcustom
>>
>>  (defun sachac-news-dir-git ()
>>    "Return the complete git path."
>> -  (concat sachac-news-data-directory "/" sachac-news-git-dirname) )
>> +  (expand-file-name  sachac-news-git-dirname sachac-news-data-directory))
>>
>>  (defun sachac-news-dir-datafile ()
>>    "Return the complete data file path."
>> -  (concat sachac-news-data-directory "/" sachac-news-data-file) )
>> -
>> +  (expand-file-name sachac-news-data-file sachac-news-data-directory))
>>
>>  (defun sachac-news-git-index-org ()
>>    "Return the index.org path on the git directory."
>> -  (concat (sachac-news-dir-git) "/emacs-news/index.org") )
>> +  (expand-file-name
>> +   "index.org"
>> +   (expand-file-name
>> +    "emacs-news"
>> +    (sachac-news-dir-git))))
>>
>>  (defun sachac-news--show-last-new-internal ()
>>    "Show the last news.
>>  This is used after the update sentinel is executed.
>>  See `sachac-news-show-last-new'."
>> -  (let ((str (sachac-news-take-last-new t)))
>> +  (let ((str (sachac-news-take-last-new t))) ;unused!
>>      (with-current-buffer (get-buffer-create "*last-news*")
>>        (org-mode)
>>
>> -      (delete-region (point-min) (point-max))
>> -      (insert str)
>> +      (erase-buffer)
>> +      (insert "foo")
>>
>>        (goto-char (point-min))
>>
>> @@ -217,7 +214,7 @@ See `sachac-news-show-last-new'."
>>  	(sachac-news-update-last-saved-title)
>>  	(sachac-news-fold-categories))
>>
>> -      (display-buffer (current-buffer)))) )
>> +      (display-buffer (current-buffer)))))
>>
>>  (defun sachac-news-show-last-new-if-new ()
>>    "Show the last new if there is a new title.
>> @@ -241,16 +238,12 @@ see `sachac-news-update-hours-wait' variable."
>>  			  #'sachac-news--show-last-new-internal
>>  			  #'sachac-news--show-last-new-internal))
>>
>> -;;
>> -;; --------------------
>> -;; Last saved title
>> -;;
>> +;;; Last saved title
>>
>>  (defun sachac-news-update-last-saved-title ()
>>    "Save the last title into the data file."
>> -
>>    (setq sachac-news-last-saved-title (sachac-news-get-last-title))
>> -  (sachac-news-save-data) )
>> +  (sachac-news-save-data))
>>
>>  (defun sachac-news-get-last-title (&optional use-current-buffer)
>>    "Get the first title founded in the current buffer.
>> @@ -264,7 +257,7 @@ the last title.  Else, if t, use the current buffer, but remember to call
>>  	nil t)
>>      (with-temp-buffer
>>        (insert (sachac-news-take-last-new t))
>> -      (sachac-news-get-last-title t))) )
>> +      (sachac-news-get-last-title t))))
>>
>>  (defun sachac-news-is-there-new-title-p (&optional use-current-buffer)
>>    "According to the last save, return t when a new post is found.
>> @@ -284,12 +277,9 @@ last news buffer.  Else, open the index.org and retrieve the last news."
>>
>>      (or (null sachac-news-last-saved-title)
>>  	(not (string-equal last-title
>> -			   sachac-news-last-saved-title)))) )
>> +			   sachac-news-last-saved-title)))))
>>
>> -;;
>> -;; --------------------
>> -;; Data or config. load/save
>> -;;
>> +;;; Data or config. load/save
>>
>>  (defun sachac-news-load-data ()
>>    "Update variables which values are in the configuration file.
>> @@ -305,7 +295,7 @@ important variables."
>>  	(setq sachac-news-last-saved-title
>>  	      (alist-get 'last-saved-title expr))
>>  	;; Return the expression loaded
>> -	expr))) )
>> +	expr))))
>>
>>  (defun sachac-news-save-data ()
>>    "Save some important variables into the data file.
>> @@ -313,20 +303,17 @@ These variables can be loaded again with `sachac-news-load-data'."
>>    (with-temp-buffer
>>      (let ((data (list (cons 'last-update sachac-news-last-update)
>>  		      (cons 'last-saved-title sachac-news-last-saved-title))))
>> -    (insert (prin1-to-string data))
>> -    (write-file (sachac-news-dir-datafile))
>> -    data)) )
>> +      (prin1 data (current-buffer))
>> +      (write-region nil nil (sachac-news-dir-datafile) nil 'silent)
>> +      data)))
>>
>>  (defun sachac-news-load-data-if-needed ()
>>    "If the data has not been loaded yet, load it."
>>    (unless sachac-news-data-loaded
>>      (sachac-news-load-data)
>> -    (setq sachac-news-data-loaded t)) )
>> +    (setq sachac-news-data-loaded t)))
>>
>> -;;
>> -;; --------------------
>> -;; Git clone/update
>> -;;
>> +;;; Git clone/update
>>
>>  (defun sachac-news-update-last-update ()
>>    "Update the `sachac-news-last-update' date with the current date."
>> @@ -335,6 +322,7 @@ These variables can be loaded again with `sachac-news-load-data'."
>>
>>  (defun sachac-news-update-time-str ()
>>    "Return a string with the last time and the amount of time left."
>> +  ;; Perhaps format this in a temporary buffer, then return the buffer string?
>>    (format "Waiting time: %s hours
>>  -- Update --
>>  Last time updated: %s
>> @@ -361,19 +349,19 @@ Time left for automatic forced update: %s %s"
>>  					     (* sachac-news-update-hours-wait 60 60)))
>>  	    "No timer setted")
>>  	  (number-to-string (/ (sachac-news-get-update-time-left) 60))
>> -	  "minutes") )
>> +	  "minutes"))
>>
>>  (defun sachac-news-get-update-wait-seconds ()
>>    "Get the `sachac-news-update-hours-wait' in seconds."
>> -  (* sachac-news-update-hours-wait 60 60) )
>> +  (* sachac-news-update-hours-wait 60 60))
>>
>>  (defun sachac-news-show-update-time ()
>>    "Display the time left for the next update."
>>    (interactive)
>>    (sachac-news-load-data-if-needed)
>>    (if sachac-news-last-update
>> -      (message (sachac-news-update-time-str))
>> -    (message "Git has not been called before.")) )
>> +      (message "%s" (sachac-news-update-time-str))
>> +    (message "Git has not been called before.")))
>>
>>  (defun sachac-news-get-update-time-left ()
>>    "Return the seconds left for the next scheduled update.
>> @@ -384,7 +372,7 @@ been setted)."
>>    (if sachac-news-timer-setted-time
>>        (- (+ sachac-news-timer-setted-time (sachac-news-get-update-wait-seconds))
>>  	 (time-convert (current-time) 'integer))
>> -    0) )
>> +    0))
>>
>>  (defun sachac-news-get-update-enable-time-left ()
>>    "Return the seconds left for the next enabled update.
>> @@ -398,7 +386,7 @@ loaded)."
>>    (if sachac-news-last-update
>>        (- (+ sachac-news-last-update (sachac-news-get-update-wait-seconds))
>>  	 (time-convert (current-time) 'integer))
>> -    0) )
>> +    0))
>>
>>  (defun sachac-news-get-update-time-elapsed ()
>>    "Return the seconds elapsed since the last update.
>> @@ -408,19 +396,19 @@ Return the numbre of seconds after the maximum wait + 1 if
>>    (if sachac-news-last-update
>>        (- (time-convert (current-time) 'integer)
>>  	 sachac-news-last-update)
>> -    (+ (sachac-news-get-update-wait-seconds) 1)) )
>> +    (+ (sachac-news-get-update-wait-seconds) 1)))
>>
>>  (defun sachac-news-is-time-for-update-p ()
>>    "Check if a day has passed since the last update."
>>    (if sachac-news-last-update
>>        (>= (sachac-news-get-update-time-elapsed)
>> -	 (sachac-news-get-update-wait-seconds) )
>> -    t) )
>> +	 (sachac-news-get-update-wait-seconds))
>> +    t))
>>
>>  (defun sachac-news-create-dirs ()
>>    "Create the needed directories to save data and the repository."
>>    (make-directory sachac-news-data-directory t)
>> -  (make-directory (sachac-news-dir-git) t) )
>> +  (make-directory (sachac-news-dir-git) t))
>>
>>  (defun sachac-news--git-sentinel (_process event)
>>    "Git sentinel.
>> @@ -454,19 +442,19 @@ FUNC-CALL-AFTER is a function called after the git process endend successfully."
>>      (when func-call-after
>>        (add-hook 'sachac-news--git-hook func-call-after))
>>      (setq sachac-news--git-process
>> -	  (if (file-exists-p (sachac-news-git-index-org))
>> -	      (start-process-shell-command "sachac-news-git-pull"
>> +	  (let ((default-directory (expand-file-name "emacs-news" (sachac-news-dir-git))))
>> +	    ;; I am not sure what the point is there, but I suspect
>> +	    ;; there should be a better way to do this using timers
>> +	    ;; and vc-git.
>> +	    (if (file-exists-p (sachac-news-git-index-org))
>> +		(start-process-shell-command "sachac-news-git-pull"
>> +					     "*sachac-news-git*"
>> +					     (concat "sleep 60 ; " git-program " pull"))
>> +	      (start-process-shell-command "sachac-news-git-clone"
>>  					   "*sachac-news-git*"
>> -					   (concat
>> -					    "cd " (sachac-news-dir-git) "/emacs-news ; sleep 60 ; "
>> -					    git-program
>> -					    " pull"))
>> -	    (start-process-shell-command "sachac-news-git-clone"
>> -					 "*sachac-news-git*"
>> -					 (concat
>> -					"cd " (sachac-news-dir-git) "; sleep 60 ; "
>> -					git-program " clone https://github.com/sachac/emacs-news.git"))))
>> -    (set-process-sentinel sachac-news--git-process #'sachac-news--git-sentinel)) )
>> +					   (concat "sleep 60 ; " git-program " clone \
>> +https://github.com/sachac/emacs-news.git")))))
>> +    (set-process-sentinel sachac-news--git-process #'sachac-news--git-sentinel)))
>>
>>
>>  (defun sachac-news-update-git (&optional force-update
>> @@ -501,11 +489,11 @@ pull/clone."
>>  	    (when callback-if-no-update
>>  	      (funcall callback-if-no-update))))
>>        ;; Git program not founded
>> -      (message "%s %s\n%s\n%s"
>> -	       "The Git program has not been founded!"
>> -	       "SachaC-news cannot download news without it!"
>> -	       "Please install it in our system or customize the variable:"
>> -	       "M-x customize-option sachac-news-git-command"))) )
>> +      (message (substitute-command-keys
>> +		"The Git program has not been founded! \
>> +SachaC-news cannot download news without it!
>> +Please install it in our system or customize the variable: )
>> +\\[customize-option] sachac-news-git-command")))))
>>
>>  (defun sachac-news-open-index-file ()
>>    "Open the index.org file from the local repository.
>> @@ -519,15 +507,10 @@ how the update is done."
>>    (sachac-news-update-git)
>>    (if (file-exists-p (sachac-news-git-index-org))
>>        (find-file (sachac-news-git-index-org))
>> -    (message "%s\n%s"
>> -	     "Index file not found! Did something wrong happen?"
>> -	     "See `sachac-news-update-git'.")) )
>> +    (message "Index file not found! Did something wrong happen?
>> +See `sachac-news-update-git'.")))
>>
>> -
>> -;;
>> -;; --------------------
>> -;; Folding categories
>> -;;
>> +;;; Folding categories
>>
>>  (defun sachac-news-find-all-categories (category-regexps &optional org-element)
>>    "Match paragraph with the CATEGORY-REGEXPS regexp.
>> @@ -554,7 +537,7 @@ Returns a list of org-element of type \\'item found in the index.org."
>>  			  (string-match-p category element))
>>  			category-regexps))
>>
>> -	    parent)))) )
>> +	    parent)))))
>>
>>
>>  (defun sachac-news-fold-all-items (item-list)
>> @@ -582,12 +565,9 @@ This function works on any Org file, even at the Emacs news' index.org."
>>    (let ((category-list (if category-regexp-list category-regexp-list
>>  			 sachac-news-fold-category-regexp-list)))
>>      (sachac-news-fold-all-items
>> -     (sachac-news-find-all-categories category-list))) )
>> +     (sachac-news-find-all-categories category-list))))
>>
>> -;;
>> -;; --------------------
>> -;; Alarm
>> -;;
>> +;;; Alarm
>>
>>  (defun sachac-news-default-notify-alarm ()
>>    "The default alarm.
>> @@ -596,7 +576,7 @@ Use the notify-send to send the alarm."
>>      (when program
>>        (shell-command (concat program
>>  			     " --app-name=\"Emacs: SachaC-news\""
>> -			     " \"Check the News!\"")))) )
>> +			     " \"Check the News!\"")))))
>>
>>  (defun sachac-news-default-sound-alarm ()
>>    "The default sound alarm.
>> @@ -619,17 +599,14 @@ as fallback."
>>  	       (car program-data)
>>  	       (split-string
>>  		(format (cadr program-data) sachac-news-alarm-sound-file)))
>> -      (ding t))) )
>> +      (ding t))))
>>
>>  (defun sachac-news-run-alarm-if-needed ()
>>    "Run the alarm hook functions if there is a new post ."
>>    (when (sachac-news-is-there-new-title-p)
>> -    (run-hooks 'sachac-news-alarm-functions-hook)) )
>> +    (run-hooks 'sachac-news-alarm-functions-hook)))
>>
>> -;;
>> -;; --------------------
>> -;; Timer
>> -;;
>> +;;; Timer
>>
>>  (defun sachac-news-timer-function ()
>>    "The function used by the timer."
>> @@ -638,7 +615,7 @@ as fallback."
>>    (sachac-news-update-git t #'sachac-news-show-last-new-if-new)
>>    (sachac-news-run-alarm-if-needed)
>>
>> -  (sachac-news-activate-timer) )
>> +  (sachac-news-activate-timer))
>>
>>
>>  (defun sachac-news-activate-timer ()
>> @@ -650,9 +627,9 @@ Set the timer for executing on `sachac-news-update-hours-wait' hours."
>>    (setq sachac-news-timer-setted-time (time-convert (current-time) 'integer))
>>    (setq sachac-news-timer
>>  	(run-at-time
>> -	 (concat (number-to-string sachac-news-update-hours-wait) "hours")
>> -		     nil
>> -		     #'sachac-news-timer-function)) )
>> +	 (format "%d hours" sachac-news-update-hours-wait)
>> +	 nil
>> +	 #'sachac-news-timer-function)))
>>
>>  (defun sachac-news-deactivate-timer ()
>>    "Stop and cancel the timer."
>> @@ -660,7 +637,7 @@ Set the timer for executing on `sachac-news-update-hours-wait' hours."
>>    (when (timerp sachac-news-timer)
>>      (cancel-timer sachac-news-timer)
>>      (setq sachac-news-timer nil))
>> -  (setq sachac-news-timer-setted-time nil) )
>> +  (setq sachac-news-timer-setted-time nil))
>>
>>  (defun sachac-news-timer-status ()
>>    "Is the timer setted or not?
>> @@ -668,8 +645,13 @@ Report the user about the timer status."
>>    (interactive)
>>    (if (timerp sachac-news-timer)
>>        (message "Timer is setted and running.")
>> -    (message "Timer is deactivated")) )
>> +    (message "Timer is deactivated")))
>> +
>> +;; Don't activate side effects while loading your package!  Instruct
>> +;; the users to add this to their init.el, so that one knows what is
>> +;; going on.
>>
>> -(sachac-news-activate-timer)
>> +;; (sachac-news-activate-timer)
>>
>> +(provide 'sachac-news)
>>  ;;; sachac-news.el ends here
>> [3  <text/plain (7bit)>]
>>
>> > According to http://elpa.gnu.org/, and the README.org [2] file
>> > linked there, it says to notify to this mail address as
>> > first step. Also, it mentions other steps regarding pushing the
>> > code and adding an entry on elpa-packages file. But, there is a
>> > marker above indicating "OUTDATED" [3].
>>
>> That should be addressed ^^
>>
>> > Please, could you tell me if these steps are needed?
>> > If they are not, how should I proceed?
>>
>> As soon as we sort out the above comments, I can take care of adding the
>> package for you.
>>
>> > Cheers!
>> > Christian Gimenez
>> >
>> > [1] https://github.com/purcell/flycheck-package
>> > [2] https://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/README
>> > [3] The section states: "Text below this marker is OUTDATED and
>> > still needs to be reviewed/rewritten!!"
>
> --
>
> - Mastodon: @cnngimenez@mastodon.social
>
>  ,= ,-_-. =.  Utilice GPG:
> ((_/)o o(\_)) * https://emailselfdefense.fsf.org/
>  `-'(. .)`-'  * Usando la terminal GNU/Linux:
>      \_/        $ gpg2 --search-keys 77A56F0DA5DD9E05
>

-- 
Philip Kaludercic



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ELPA] New package: SachaC-news
  2023-11-18 20:26   ` Christian
@ 2023-11-21 16:07     ` Sacha Chua
  2023-11-25 22:40       ` Christian
  0 siblings, 1 reply; 12+ messages in thread
From: Sacha Chua @ 2023-11-21 16:07 UTC (permalink / raw)
  To: Christian; +Cc: rms, emacs-devel

Christian <cnngimenez@disroot.org> writes:

Hello, Christian, all!

Christian: Neat idea, thanks for making it! =)

>> What other formats does this repository store postings in?  If it has
>> -- or can generate -- plain text, that should be preferred.
>> There are users who like Org fornat, but it is not Emacs's preferred
>> way of showing information.
> Sacha Chua creates her blog posts using this file written in
> Org-mode. This mode is installed by default on Emacs 29 [1] and
> can export to other formats: LaTeX, HTML, plain text, TeXInfo
> and info (by installing ox-texinfo), etc.

I could take another couple of minutes during the export process and
export them as text and HTML as well. Here are both in my fork of your
Sourcehut: https://git.sr.ht/~sachac/sachac-emacs-news . The Org version
seems easier to parse, though.

> Mmm... I suppose... I can add a customization to show an
> exported buffer instead the Org-mode buffer. For example, if
> sachac-news-show-plain-text is set to t, it  will do the
> overall process, but add an extra step to export the Org file
> into plain text... or even generalize this idea to use any
> export dispatch function... I believe it can be
> implemented... what do you think?

Yeah, it's probably better to do it on-the-fly, so people can get
different versions of whatever they like. Making the backend selectable
sounds like a possibly useful thing, in case maybe someone wants to use
one of the Emacs News categories as a starting point for, say, their
Markdown-based blog post...

> Recently, I have just added a customization variable to set the
> URL to Sacha's Emacs News repository (see [3]). By default, its
> value is [4] which is a clone of the original. This repository
> will be automatically updated once a day, if there is a new
> blog post. However, you can change it to any other repository
> URL with an index.org file if you like.

Sure, we could use your repo (or my fork of your repo) if you like. Or
if you add me as a collaborator on your repo, I can add it to the list
of repos to push to... <laugh>

> I have an account on savannah.gnu.org. If it is needed, I can
> request a new repository there. But it will require some time
> to be approved.

I wasn't sure if Emacs News is eligible for Savannah hosting, since I
link to lots of YouTube videos and the occasional commercial workshop
being advertised by people. (Goodness knows emacs-devel has seen lots of
discussions about MELPA, even...) Happy to set up another repo there if
people feel it's all right. Decentralized source control for the win!

> Sacha Chua maintains her emacs-news blog posts [6], and creates them
> by using the index.org file in that archive (or so it seems as far as
> I can understand the code in it, I have not asked her yet!).

Yup, that's pretty much it.

>> Org format is NOT the Emacs standard or preferred format, and not
>> everyone uses it.  Therefore, if we add a command to display some
>> useful information, it should not use Org format.
>> The best format to use is plain text.
> Maybe, the name "Org" is not correct? I mean Org-mode [7] (I call it
> "Org" casually, sorry for that)... I thought it is considered as a
> plain text format. I love it and use it for... well... almost
> everything. If I am wrong in any way, please tell me.

I use Org because that makes it easy to export to different formats with
hyperlinks. I like the conciseness of working with the titles for the
most part while easily being able to access the URLs as needed. I also
like having custom package links that open up package descriptions on my
computer and export to regular HTML or ASCII links when I'm publishing.
It's easy to rearrange bulleted lists, too. If people open the Org
files, they can mostly follow the hyperlinks without loading any custom
configuration. I'm going to keep Org as my source data format instead
of using something like Hyperbole and/or Markdown.

If we want the source data available in different formats, I can add
that to my publishing process and keep that in the repo. It takes me a
few minutes to export the whole file, so it's not a big deal.

I'm guessing when people want to see the data, they'll usually want to
see hyperlinked titles instead of titles + URLs (as in the ASCII export)
while still being able to access the URLs if needed. I think taking
advantage of Org's existing functionality makes sense here. Of course,
the package can display things in different formats for people who
prefer those.

For people's convenience, I post HTML/Org/TXT to the emacs-tangents
mailing list, so the information is available there in multiple formats.

Fetching the index.org without git could work if you grab the whole file
using the raw URL, like
https://git.sr.ht/~sachac/sachac-emacs-news/blob/master/index.org ? It's
3.8MB (sorry server operators). I keep everything in one file to make it
easier to check for duplicates.

Would it help if I wrote the last post as a separate file, as in
https://git.sr.ht/~sachac/sachac-emacs-news/tree/master/item/most-recent.org
(or .txt or .html)?

Sacha



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ELPA] New package: SachaC-news
  2023-11-18 21:10     ` Philip Kaludercic
@ 2023-11-25 22:07       ` Christian
  2023-11-25 22:50         ` Philip Kaludercic
  0 siblings, 1 reply; 12+ messages in thread
From: Christian @ 2023-11-25 22:07 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Christian, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 8297 bytes --]

Hi Philip!

Sorry, I misunderstood your idea. What would you like to
discuss specifically?

I will try to pinpoint some things you suggested that is nice
to talk about. The diff has many modifications, and I find it
difficult to see the exact places you want to discuss. In
fact, most of them are changes that I think are better in the
way you wrote.

Below are extracts from the diff and my comments. Tell me if
this method is a good idea to talk about them.

Thanks!
Cheers!

1)
> (defcustom sachac-news-alarm-functions-hook
>    '(sachac-news-default-notify-alarm
>      sachac-news-default-sound-alarm)
>    "The alarm functions.
>  These functions are called when there are new news."
> -  :type 'hook
> -  :group 'sachac-news ) ;; defcustom
> +  :type 'hook) ;; defcustom

I think it is correct to remove the :group. I tend to specify
it in case I create more than one customization group, but in
this case, only one is defined.

2)
> +(defvar sachac-news-timer-setted-time 0	;perhaps mark these as internal: sachac-news--...
>    "At what time the timer has been setted?
>  See `sachac-news-set-timer'.")

Yep, this variable should be internal. It is used to store the
timestamp when the timer has been activated. And later, the
variable is used to calculate how much time has been passed
since the activation.

Some of the rest of the variables, I believe they should be
internal too.

3)
>  (defun sachac-news-dir-git ()
>    "Return the complete git path."
> -  (concat sachac-news-data-directory "/" sachac-news-git-dirname) )
> +  (expand-file-name  sachac-news-git-dirname sachac-news-data-directory))

>  (defun sachac-news-dir-datafile ()
>    "Return the complete data file path."
> -  (concat sachac-news-data-directory "/" sachac-news-data-file) )
> -
> +  (expand-file-name sachac-news-data-file sachac-news-data-directory))

>  (defun sachac-news-git-index-org ()
>    "Return the index.org path on the git directory."
> -  (concat (sachac-news-dir-git) "/emacs-news/index.org") )
> +  (expand-file-name
> +   "index.org"
> +   (expand-file-name
> +    "emacs-news"
> +    (sachac-news-dir-git))))

I prefer using the expand-file-name, they are more
portable. Did not know that this function exists.

4)
>  (defun sachac-news--show-last-new-internal ()
>    "Show the last news.
>  This is used after the update sentinel is executed.
>  See `sachac-news-show-last-new'."
> -  (let ((str (sachac-news-take-last-new t)))
> +  (let ((str (sachac-news-take-last-new t))) ;unused!
>      (with-current-buffer (get-buffer-create "*last-news*")
>        (org-mode)

> -      (delete-region (point-min) (point-max))
> -      (insert str)
> +      (erase-buffer)
> +      (insert "foo")

The str variable was used to insert the last new string. The
portion of the Org-mode text with the last title.

But now I changed this function to support diferent formats (txt,
html, org, etc.). This code changed in the current version.

5)
> @@ -313,20 +303,17 @@ These variables can be loaded again with `sachac-news-load-data'."
>    (with-temp-buffer
>      (let ((data (list (cons 'last-update sachac-news-last-update)
>  		      (cons 'last-saved-title sachac-news-last-saved-title))))
> -    (insert (prin1-to-string data))
> -    (write-file (sachac-news-dir-datafile))
> -    data)) )
> +      (prin1 data (current-buffer))
> +      (write-region nil nil (sachac-news-dir-datafile) nil 'silent)
> +      data)))

>  (defun sachac-news-load-data-if-needed ()
>    "If the data has not been loaded yet, load it."

Mmm... to my eyes it seems that it does the same but it may be
something I do not know... or maybe I am missing something?
Can I ask you why did you change it? Is the new code a
more convenient or accepted way to do what is intended?
I wonder if perhaps is a parameter or something I do not know
what it does...
Maybe is efficiency: the data is directly printed to the buffer
without transforming into a string?

6)
> @@ -335,6 +322,7 @@ These variables can be loaded again with `sachac-news-load-data'."

>  (defun sachac-news-update-time-str ()
>    "Return a string with the last time and the amount of time left."
> +  ;; Perhaps format this in a temporary buffer, then return the buffer string?
>    (format "Waiting time: %s hours
>  -- Update --
>  Last time updated: %s
Yes, that could be a good idea... However, it should not be a
large string, because it will be displayed on the
minibuffer. Mmm... maybe it is already large...

What do you think? should the string be formatted in a
temporary buffer?

This string is shown when using M-x
sachac-news-show-update-time when an update has been executed
before.

7)
> @@ -454,19 +442,19 @@ FUNC-CALL-AFTER is a function called after the git process endend successfully."
>      (when func-call-after
>        (add-hook 'sachac-news--git-hook func-call-after))
>      (setq sachac-news--git-process
> -	  (if (file-exists-p (sachac-news-git-index-org))
> -	      (start-process-shell-command "sachac-news-git-pull"
> +	  (let ((default-directory (expand-file-name "emacs-news" (sachac-news-dir-git))))
> +	    ;; I am not sure what the point is there, but I suspect
> +	    ;; there should be a better way to do this using timers
> +	    ;; and vc-git.
> +	    (if (file-exists-p (sachac-news-git-index-org))
> +		(start-process-shell-command "sachac-news-git-pull"
> +					     "*sachac-news-git*"
> +					     (concat "sleep 60 ; " git-program " pull"))
> +	      (start-process-shell-command "sachac-news-git-clone"
>  					   "*sachac-news-git*"
> -					   (concat
> -					    "cd " (sachac-news-dir-git) "/emacs-news ; sleep 60 ; "
> -					    git-program
> -					    " pull"))
> -	    (start-process-shell-command "sachac-news-git-clone"
> -					 "*sachac-news-git*"
> -					 (concat
> -					"cd " (sachac-news-dir-git) "; sleep 60 ; "
> -					git-program " clone https://github.com/sachac/emacs-news.git"))))
> -    (set-process-sentinel sachac-news--git-process #'sachac-news--git-sentinel)) )
> +					   (concat "sleep 60 ; " git-program " clone \
> +https://github.com/sachac/emacs-news.git")))))
> +    (set-process-sentinel sachac-news--git-process #'sachac-news--git-sentinel)))

This refers to the sachac-news--git-update internal function.

The sachac-news.el is already using timers, in fact, it must be
a timer the one that at some point calls this function. Also,
there are interactive commands that can trigger a new
git-update. I think it may be more complex to create another
timer inside one to just do the git clone/pull.

Using vc-git it's a good idea! I didn't thought about that!

8)
> @@ -668,8 +645,13 @@ Report the user about the timer status."
>    (interactive)
>    (if (timerp sachac-news-timer)
>        (message "Timer is setted and running.")
> -    (message "Timer is deactivated")) )
> +    (message "Timer is deactivated")))
> +
> +;; Don't activate side effects while loading your package!  Instruct
> +;; the users to add this to their init.el, so that one knows what is
> +;; going on.

> -(sachac-news-activate-timer)
> +;; (sachac-news-activate-timer)

> +(provide 'sachac-news)
>  ;;; sachac-news.el ends here


Oh! That's true! I wanted to activate the timer
automatically. But it is better to add a comment on the
README.org about this. Thanks!

On Sat, 18 Nov 2023 18:10:24 -0300,
Philip Kaludercic wrote:
>
> Christian <cnngimenez@disroot.org> writes:
>
> > Thanks Philip!
> >
> > I applied the diff to this commit:
> >
> > https://git.sr.ht/~cngimenez/sachac-news/commit/8263dbc7982f543f673172c4a60d4bb68a48c6f6
>
> It appears you applied my comments as well?  I should have made it
> clear, that my message just intended to propose some changes,
> demonstrate possible alternatives and raise some questions for us to
> discuss.
>
> > Cheers!
> > Christian.
> >
> > --
> >
> > - Mastodon: @cnngimenez@mastodon.social
> >
> >  ,= ,-_-. =.  Utilice GPG:
> > ((_/)o o(\_)) * https://emailselfdefense.fsf.org/
> >  `-'(. .)`-'  * Usando la terminal GNU/Linux:
> >      \_/        $ gpg2 --search-keys 77A56F0DA5DD9E05
> >
>
> --
> Philip Kaludercic



--

- Mastodon: @cnngimenez@mastodon.social

 ,= ,-_-. =.  Utilice GPG:
((_/)o o(\_)) * https://emailselfdefense.fsf.org/
 `-'(. .)`-'  * Usando la terminal GNU/Linux:
     \_/        $ gpg2 --search-keys 77A56F0DA5DD9E05

[-- Attachment #2: OpenPGP Digital Signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ELPA] New package: SachaC-news
  2023-11-21 16:07     ` Sacha Chua
@ 2023-11-25 22:40       ` Christian
  0 siblings, 0 replies; 12+ messages in thread
From: Christian @ 2023-11-25 22:40 UTC (permalink / raw)
  To: Sacha Chua; +Cc: Christian, rms, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 7137 bytes --]

Hi Sacha and all!

I know that EmacsConf is so near, and you are working a lot for
it... sorry for bringing more work to you!


On Tue, 21 Nov 2023 13:07:19 -0300,
Sacha Chua wrote:
>
> Christian <cnngimenez@disroot.org> writes:
>
> Hello, Christian, all!
>
> Christian: Neat idea, thanks for making it! =)

Well, I read Emacs News frequently, and used many things from
your posts... Thanks for making it! :)

>
> >> What other formats does this repository store postings in?  If it has
> >> -- or can generate -- plain text, that should be preferred.
> >> There are users who like Org fornat, but it is not Emacs's preferred
> >> way of showing information.
> > Sacha Chua creates her blog posts using this file written in
> > Org-mode. This mode is installed by default on Emacs 29 [1] and
> > can export to other formats: LaTeX, HTML, plain text, TeXInfo
> > and info (by installing ox-texinfo), etc.
>
> I could take another couple of minutes during the export process and
> export them as text and HTML as well. Here are both in my fork of your
> Sourcehut: https://git.sr.ht/~sachac/sachac-emacs-news . The Org version
> seems easier to parse, though.

I added a new customization variable
"sachac-news-use-git-file" [1] to select which file to
open. For example, if you want plain text, you can change its
value to "most-recent.txt". By default, it uses
"most-recent.org".

>
> > Mmm... I suppose... I can add a customization to show an
> > exported buffer instead the Org-mode buffer. For example, if
> > sachac-news-show-plain-text is set to t, it  will do the
> > overall process, but add an extra step to export the Org file
> > into plain text... or even generalize this idea to use any
> > export dispatch function... I believe it can be
> > implemented... what do you think?
>
> Yeah, it's probably better to do it on-the-fly, so people can get
> different versions of whatever they like. Making the backend selectable
> sounds like a possibly useful thing, in case maybe someone wants to use
> one of the Emacs News categories as a starting point for, say, their
> Markdown-based blog post...

Done! if you set "sachac-news-after-download-function" [2] to,
for example, org-md-export-to-markdown, it will generate a
markdown file and display it.

It was a little tricky to implement, it uses the file specified
on "sachac-news-use-git-file" as the base to export. Maybe,
someone want to use another tool or elisp function...

>
> > Recently, I have just added a customization variable to set the
> > URL to Sacha's Emacs News repository (see [3]). By default, its
> > value is [4] which is a clone of the original. This repository
> > will be automatically updated once a day, if there is a new
> > blog post. However, you can change it to any other repository
> > URL with an index.org file if you like.
>
> Sure, we could use your repo (or my fork of your repo) if you like. Or
> if you add me as a collaborator on your repo, I can add it to the list
> of repos to push to... <laugh>

Good idea! I have just added your account to my fork, so you
can collaborate too, and then pull or push to... XD XD

Well, I changed the default URL to yours:
      https://git.sr.ht/~sachac/sachac-emacs-news
I think is better that way. Just in case, I really added you as
collaborator with Read+Write access to both repos.

>
> > I have an account on savannah.gnu.org. If it is needed, I can
> > request a new repository there. But it will require some time
> > to be approved.
>
> I wasn't sure if Emacs News is eligible for Savannah hosting, since I
> link to lots of YouTube videos and the occasional commercial workshop
> being advertised by people. (Goodness knows emacs-devel has seen lots of
> discussions about MELPA, even...) Happy to set up another repo there if
> people feel it's all right. Decentralized source control for the win!
>
> > Sacha Chua maintains her emacs-news blog posts [6], and creates them
> > by using the index.org file in that archive (or so it seems as far as
> > I can understand the code in it, I have not asked her yet!).
>
> Yup, that's pretty much it.
>
> >> Org format is NOT the Emacs standard or preferred format, and not
> >> everyone uses it.  Therefore, if we add a command to display some
> >> useful information, it should not use Org format.
> >> The best format to use is plain text.
> > Maybe, the name "Org" is not correct? I mean Org-mode [7] (I call it
> > "Org" casually, sorry for that)... I thought it is considered as a
> > plain text format. I love it and use it for... well... almost
> > everything. If I am wrong in any way, please tell me.
>
> I use Org because that makes it easy to export to different formats with
> hyperlinks. I like the conciseness of working with the titles for the
> most part while easily being able to access the URLs as needed. I also
> like having custom package links that open up package descriptions on my
> computer and export to regular HTML or ASCII links when I'm publishing.
> It's easy to rearrange bulleted lists, too. If people open the Org
> files, they can mostly follow the hyperlinks without loading any custom
> configuration. I'm going to keep Org as my source data format instead
> of using something like Hyperbole and/or Markdown.
>
> If we want the source data available in different formats, I can add
> that to my publishing process and keep that in the repo. It takes me a
> few minutes to export the whole file, so it's not a big deal.
>
> I'm guessing when people want to see the data, they'll usually want to
> see hyperlinked titles instead of titles + URLs (as in the ASCII export)
> while still being able to access the URLs if needed. I think taking
> advantage of Org's existing functionality makes sense here. Of course,
> the package can display things in different formats for people who
> prefer those.
>
> For people's convenience, I post HTML/Org/TXT to the emacs-tangents
> mailing list, so the information is available there in multiple formats.
>
> Fetching the index.org without git could work if you grab the whole file
> using the raw URL, like
> https://git.sr.ht/~sachac/sachac-emacs-news/blob/master/index.org ? It's
> 3.8MB (sorry server operators). I keep everything in one file to make it
> easier to check for duplicates.
>
> Would it help if I wrote the last post as a separate file, as in
> https://git.sr.ht/~sachac/sachac-emacs-news/tree/master/item/most-recent.org
> (or .txt or .html)?

I see in the repo that you have already done it! Awesome!
Thanks a lot! Now sachac-news uses most-recent.org by default!

>
> Sacha

[1] The sachac-news-use-git-file variable is defined here:
https://git.sr.ht/~cngimenez/sachac-news/tree/ba3ba95ba8fe74df000161e0933ac89cad583cf3/item/sachac-news.el#L120

[2] The sachac-news-after-download-function is defined here:
https://git.sr.ht/~cngimenez/sachac-news/tree/ba3ba95ba8fe74df000161e0933ac89cad583cf3/item/sachac-news.el#L133

--

- Mastodon: @cnngimenez@mastodon.social

 ,= ,-_-. =.  Utilice GPG:
((_/)o o(\_)) * https://emailselfdefense.fsf.org/
 `-'(. .)`-'  * Usando la terminal GNU/Linux:
     \_/        $ gpg2 --search-keys 77A56F0DA5DD9E05

[-- Attachment #2: OpenPGP Digital Signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ELPA] New package: SachaC-news
  2023-11-25 22:07       ` Christian
@ 2023-11-25 22:50         ` Philip Kaludercic
  0 siblings, 0 replies; 12+ messages in thread
From: Philip Kaludercic @ 2023-11-25 22:50 UTC (permalink / raw)
  To: Christian; +Cc: emacs-devel

Christian <cnngimenez@disroot.org> writes:

> Hi Philip!
>
> Sorry, I misunderstood your idea. What would you like to
> discuss specifically?
>
> I will try to pinpoint some things you suggested that is nice
> to talk about. The diff has many modifications, and I find it
> difficult to see the exact places you want to discuss. In
> fact, most of them are changes that I think are better in the
> way you wrote.
>
> Below are extracts from the diff and my comments. Tell me if
> this method is a good idea to talk about them.

It is entirely fine; I'll just be responding to the parts of the message
where I have something constructive to add.

> 4)
>>  (defun sachac-news--show-last-new-internal ()
>>    "Show the last news.
>>  This is used after the update sentinel is executed.
>>  See `sachac-news-show-last-new'."
>> -  (let ((str (sachac-news-take-last-new t)))
>> +  (let ((str (sachac-news-take-last-new t))) ;unused!
>>      (with-current-buffer (get-buffer-create "*last-news*")
>>        (org-mode)
>
>> -      (delete-region (point-min) (point-max))
>> -      (insert str)
>> +      (erase-buffer)
>> +      (insert "foo")
>
> The str variable was used to insert the last new string. The
> portion of the Org-mode text with the last title.

No, that was my bad, I must have replaced the variable with a constant
while testing and forgot to change it back.

> But now I changed this function to support diferent formats (txt,
> html, org, etc.). This code changed in the current version.

Would it be worth checking out the code again?

> 5)
>> @@ -313,20 +303,17 @@ These variables can be loaded again with `sachac-news-load-data'."
>>    (with-temp-buffer
>>      (let ((data (list (cons 'last-update sachac-news-last-update)
>>  		      (cons 'last-saved-title sachac-news-last-saved-title))))
>> -    (insert (prin1-to-string data))
>> -    (write-file (sachac-news-dir-datafile))
>> -    data)) )
>> +      (prin1 data (current-buffer))
>> +      (write-region nil nil (sachac-news-dir-datafile) nil 'silent)
>> +      data)))
>
>>  (defun sachac-news-load-data-if-needed ()
>>    "If the data has not been loaded yet, load it."
>
> Mmm... to my eyes it seems that it does the same but it may be
> something I do not know... or maybe I am missing something?
> Can I ask you why did you change it? Is the new code a
> more convenient or accepted way to do what is intended?
>
> I wonder if perhaps is a parameter or something I do not know
> what it does...
> Maybe is efficiency: the data is directly printed to the buffer
> without transforming into a string?

Yes; The point of these two changes is to avoid generating a string,
that is immediately discarded (less GC), and to avoid generating a
message when writing the buffer contents to disk.

> 6)
>> @@ -335,6 +322,7 @@ These variables can be loaded again with `sachac-news-load-data'."
>
>>  (defun sachac-news-update-time-str ()
>>    "Return a string with the last time and the amount of time left."
>> +  ;; Perhaps format this in a temporary buffer, then return the buffer string?
>>    (format "Waiting time: %s hours
>>  -- Update --
>>  Last time updated: %s
> Yes, that could be a good idea... However, it should not be a
> large string, because it will be displayed on the
> minibuffer. Mmm... maybe it is already large...
>
> What do you think? should the string be formatted in a
> temporary buffer?

It just seemed like it would be more readable, than having a multi-line
format-string.

> This string is shown when using M-x
> sachac-news-show-update-time when an update has been executed
> before.

Perhaps `display-message-or-buffer' could be of interest?

-- 
Philip Kaludercic
 



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-11-25 22:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-12 19:32 [ELPA] New package: SachaC-news Christian
2023-11-14  2:56 ` Richard Stallman
2023-11-15 23:56   ` Björn Bidar
2023-11-14  2:56 ` Richard Stallman
2023-11-18 20:26   ` Christian
2023-11-21 16:07     ` Sacha Chua
2023-11-25 22:40       ` Christian
2023-11-17  7:28 ` Philip Kaludercic
2023-11-18 20:30   ` Christian
2023-11-18 21:10     ` Philip Kaludercic
2023-11-25 22:07       ` Christian
2023-11-25 22:50         ` Philip Kaludercic

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).