all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [NonGNU ELPA] New package: Denote-Refs
@ 2022-12-19 16:31 Akib Azmain Turja
  2022-12-19 16:58 ` Philip Kaludercic
  0 siblings, 1 reply; 18+ messages in thread
From: Akib Azmain Turja @ 2022-12-19 16:31 UTC (permalink / raw)
  To: Emacs Developer List


[-- Attachment #1.1: Type: text/plain, Size: 133 bytes --]


Denote-Refs shows links and backlinks inline in a Denote note buffer,
just below the front matter of the note.

Here is the patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: Denote-Refs --]
[-- Type: text/x-patch, Size: 749 bytes --]

From f4145634df9eb45df7d526871c55326bfafb3785 Mon Sep 17 00:00:00 2001
From: Akib Azmain Turja <akib@disroot.org>
Date: Mon, 19 Dec 2022 22:22:46 +0600
Subject: [PATCH] * elpa-packages (denote-refs): New package.

---
 elpa-packages | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/elpa-packages b/elpa-packages
index 9dde563..1d26a5a 100644
--- a/elpa-packages
+++ b/elpa-packages
@@ -108,6 +108,8 @@
   :ignored-files ("LICENSE" "test" "Cask" "Makefile")
   :news "CHANGELOG.md")
 
+ (denote-refs           :url "https://codeberg.org/akib/emacs-denote-refs")
+
  (devhelp               :url "https://codeberg.org/akib/emacs-devhelp")
 
  (diff-ansi		:url "https://codeberg.org/ideasman42/emacs-diff-ansi"
-- 
2.37.1


[-- Attachment #1.3: Type: text/plain, Size: 198 bytes --]



-- 
Akib Azmain Turja, GPG key: 70018CE5819F17A3BBA666AFE74F0EFA922AE7F5
Fediverse: akib@hostux.social
Codeberg: akib
emailselfdefense.fsf.org | "Nothing can be secure without encryption."

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-19 16:31 [NonGNU ELPA] New package: Denote-Refs Akib Azmain Turja
@ 2022-12-19 16:58 ` Philip Kaludercic
  2022-12-19 18:00   ` Akib Azmain Turja
  0 siblings, 1 reply; 18+ messages in thread
From: Philip Kaludercic @ 2022-12-19 16:58 UTC (permalink / raw)
  To: Akib Azmain Turja; +Cc: Emacs Developer List

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

Akib Azmain Turja <akib@disroot.org> writes:

> Denote-Refs shows links and backlinks inline in a Denote note buffer,
> just below the front matter of the note.
>
> Here is the patch:
>
> From f4145634df9eb45df7d526871c55326bfafb3785 Mon Sep 17 00:00:00 2001
> From: Akib Azmain Turja <akib@disroot.org>
> Date: Mon, 19 Dec 2022 22:22:46 +0600
> Subject: [PATCH] * elpa-packages (denote-refs): New package.
>
> ---
>  elpa-packages | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/elpa-packages b/elpa-packages
> index 9dde563..1d26a5a 100644
> --- a/elpa-packages
> +++ b/elpa-packages
> @@ -108,6 +108,8 @@
>    :ignored-files ("LICENSE" "test" "Cask" "Makefile")
>    :news "CHANGELOG.md")
>  
> + (denote-refs           :url "https://codeberg.org/akib/emacs-denote-refs")
> +
>   (devhelp               :url "https://codeberg.org/akib/emacs-devhelp")
>  
>   (diff-ansi		:url "https://codeberg.org/ideasman42/emacs-diff-ansi"
> -- 
> 2.37.1

Here are a few comments:


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

diff -u /tmp/denote-refs.el.1 /tmp/denote-refs.el
--- /tmp/denote-refs.el.1	2022-12-19 19:38:55.000000000 +0100
+++ /tmp/denote-refs.el	2022-12-19 17:57:48.712068577 +0100
@@ -5,8 +5,8 @@
 ;; Author: Akib Azmain Turja <akib@disroot.org>
 ;; Created: 2022-12-18
 ;; Version: 0.1
-;; Package-Requires: ((emacs "28.1"))
-;; Keywords: hypermedia outlines files
+;; Package-Requires: ((emacs "28.1") (denote "1.2.0"))
+;; Keywords: hypermedia, outlines, files
 ;; URL: https://codeberg.org/akib/emacs-denote-refs
 
 ;; This file is not part of GNU Emacs.
@@ -36,12 +36,11 @@
 (require 'denote)
 (require 'subr-x)
 
-(defgroup denote-refs nil
+(defgroup denote-refs '()
   "Show links and backlinks in Denote notes."
   :group 'denote
-  :group 'hypermedia
-  :group 'outlines
-  :group 'files
+  ;; You don't need to add multiple groups, we only need it to appear
+  ;; once in the customize hierarchy
   :link '(url-link "https://codeberg.org/akib/emacs-denote-refs")
   :prefix "denote-refs-")
 
@@ -62,7 +61,8 @@
 
 Available sections are `links' and `backlinks', which shows the list
 of linked file and the list of backlinks respectively."
-  :type '(set (const :tag "Links" links)
+  :type '(set :greedy t
+	      (const :tag "Links" links)
               (const :tag "Backlinks" backlinks)))
 
 (defvar denote-refs--links 'not-ready
@@ -83,65 +83,67 @@
 (defun denote-refs--render (section)
   "Render SECTION."
   (let ((refs (pcase section
-                ('links denote-refs--links)
-                ('backlinks denote-refs--backlinks))))
-    (pcase major-mode
-      ;; There's no comment syntax in `text-mode', so just follow
-      ;; `org-mode'.
-      ((or 'org-mode 'text-mode)
-       ;; Insert references count.
-       (insert (if (eq refs 'not-ready)
-                   (format "# ... %s\n" (if (eq section 'links)
-                                            "links"
-                                          "backlinks"))
-                 (format "# %i %s%s\n" (length refs)
-                         (if (eq section 'links)
-                             "link"
-                           "backlink")
-                         (pcase (length refs)
-                           (0 "")
-                           (1 ":")
-                           (_ "s:")))))
-       ;; Insert reference list.
-       (when (listp refs)
-         (dolist (ref refs)
-           (insert "#   ")
-           (insert-button (car ref)
-                          'help-echo (cdr ref)
-                          'face 'denote-faces-link
-                          'action (lambda (_)
-                                    (funcall denote-link-button-action
-                                             (cdr ref))))
-           (insert ?\n))))
-      ('markdown-mode
-       ;; Insert references count.
-       (insert (if (eq refs 'not-ready)
-                   (format "<!-- ... %s -->\n" (if (eq section 'links)
-                                                   "links"
-                                                 "backlinks"))
-                 (format "<!-- %i %s%s\n" (length refs)
-                         (if (eq section 'links)
-                             "link"
-                           "backlink")
-                         (pcase (length refs)
-                           (0 " -->")
-                           (1 ":")
-                           (_ "s:")))))
-       ;; Insert reference list.
-       (when (listp refs)
-         (while refs
-           (let ((ref (pop refs)))
-             (insert "  ")
-             (insert-button
-              (car ref)
-              'help-echo (cdr ref)
-              'face 'denote-faces-link
-              'action (lambda (_)
-                        (funcall denote-link-button-action
-                                 (cdr ref))))
-             (unless refs
-               (insert " -->"))
-             (insert ?\n))))))))
+		('links denote-refs--links)
+		('backlinks denote-refs--backlinks))))
+    (cond
+     ;; There's no comment syntax in `text-mode', so just follow
+     ;; `org-mode'.
+     ((derived-mode-p 'org-mode 'text-mode)
+      ;; Insert references count.
+      (insert (if (eq refs 'not-ready)
+		  (format "# ... %s\n" (if (eq section 'links)
+					   "links"
+					 "backlinks"))
+		(format "# %i %s%s\n" (length refs)
+			(if (eq section 'links)
+			    "link"
+			  "backlink")
+			(pcase (length refs)
+			  (0 "")
+			  (1 ":")
+			  (_ "s:")))))
+      ;; Insert reference list.
+      (when (listp refs)
+	(dolist (ref refs)
+	  (insert "#   ")
+	  (insert-button (car ref)
+			 'help-echo (cdr ref)
+			 'face 'denote-faces-link
+			 'action (lambda (_)
+				   (funcall denote-link-button-action
+					    (cdr ref))))
+	  ;; Could (newline) work here?
+	  (insert ?\n))))
+     ((derived-mode-p 'markdown-mode)
+      ;; Insert references count.
+      (insert (if (eq refs 'not-ready)
+		  (format "<!-- ... %s -->\n" (if (eq section 'links)
+						  "links"
+						"backlinks"))
+		(format "<!-- %i %s%s\n" (length refs)
+			(if (eq section 'links)
+			    "link"
+			  "backlink")
+			(pcase (length refs)
+			  (0 " -->")
+			  (1 ":")
+			  (_ "s:")))))
+      ;; Insert reference list.
+      (when (listp refs)
+	(while refs
+	  (let ((ref (pop refs)))
+	    (insert "  ")
+	    (insert-button
+	     (car ref)
+	     'help-echo (cdr ref)
+	     'face 'denote-faces-link
+	     ;; This way we avoid creating a closure that ignores an
+	     ;; argument.
+	     'action #'denote-link-button-action
+	     'button-data (cdr ref))
+	    (unless refs
+	      (insert " -->"))
+	    (insert ?\n))))))))
 
 (defun denote-refs--goto-end-of-front-matter ()
   "Go to the end of front matter of the note."
@@ -159,15 +161,14 @@
     (save-excursion
       (denote-refs--goto-end-of-front-matter)
       (when (get-text-property (point) 'denote-refs--sections)
-        (let ((end (or (next-single-property-change
-                        (point) 'denote-refs--sections)
-                       (point-max))))
-          (when (< end (point-max))
-            (setq end (1+ end)))
-          (let ((mod-flag (buffer-modified-p))
-                (inhibit-read-only t))
-            (delete-region (point) end)
-            (restore-buffer-modified-p mod-flag)))))))
+	(let ((end (or (next-single-property-change
+			(point) 'denote-refs--sections)
+		       (point-max)))
+	      (inhibit-read-only t))
+	  (when (< end (point-max))
+	    (setq end (1+ end)))
+	  (with-silent-modifications
+	    (delete-region (point) end)))))))
 
 (defun denote-refs--show ()
   "Show references."
@@ -177,19 +178,18 @@
     (denote-refs--remove)
     (save-excursion
       (denote-refs--goto-end-of-front-matter)
-      (let ((begin (point))
-            (mod-flag (buffer-modified-p))
-            (inhibit-read-only t))
-        (dolist (section denote-refs-sections)
-          (pcase-exhaustive section
-            ('links
-             (denote-refs--render 'links))
-            ('backlinks
-             (denote-refs--render 'backlinks))))
-        (put-text-property begin (point) 'read-only t)
-        (put-text-property begin (point) 'denote-refs--sections t)
-        (insert ?\n)
-        (restore-buffer-modified-p mod-flag)))))
+      (with-silent-modifications
+	(let ((begin (point))
+	      (inhibit-read-only t))
+	  (dolist (section denote-refs-sections)
+	    (pcase-exhaustive section
+	      ('links
+	       (denote-refs--render 'links))
+	      ('backlinks
+	       (denote-refs--render 'backlinks))))
+	  (put-text-property begin (point) 'read-only t)
+	  (put-text-property begin (point) 'denote-refs--sections t)
+	  (insert ?\n))))))
 
 (defun denote-refs--make-path-relative (path)
   "Return a cons of relative and absolute version of PATH.
@@ -203,22 +203,22 @@
     (pcase-exhaustive section
       ('links
        (setq denote-refs--links
-             (when (and (buffer-file-name)
-                        (file-exists-p (buffer-file-name)))
-               (mapcar #'denote-refs--make-path-relative
-                       (denote-link--expand-identifiers
-                        (denote--link-in-context-regexp
-                         (denote-filetype-heuristics
-                          (buffer-file-name))))))))
+	     (and (buffer-file-name)
+		  (file-exists-p (buffer-file-name))
+		  (mapcar #'denote-refs--make-path-relative
+			  (denote-link--expand-identifiers
+			   (denote--link-in-context-regexp
+			    (denote-filetype-heuristics
+			     (buffer-file-name))))))))
       ('backlinks
        (setq denote-refs--backlinks
-             (when (and (buffer-file-name)
-                        (file-exists-p (buffer-file-name)))
-               (mapcar #'denote-refs--make-path-relative
-                       (delete (buffer-file-name)
-                               (denote--retrieve-files-in-xrefs
-                                (denote-retrieve-filename-identifier
-                                 (buffer-file-name)))))))))))
+	     (and (buffer-file-name)
+		  (file-exists-p (buffer-file-name))
+		  (mapcar #'denote-refs--make-path-relative
+			  (delete (buffer-file-name)
+				  (denote--retrieve-files-in-xrefs
+				   (denote-retrieve-filename-identifier
+				    (buffer-file-name)))))))))))
 
 (defun denote-refs-update ()
   "Update Denote references shown."

Diff finished.  Mon Dec 19 17:57:57 2022

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

* Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-19 16:58 ` Philip Kaludercic
@ 2022-12-19 18:00   ` Akib Azmain Turja
  2022-12-19 19:19     ` Philip Kaludercic
  0 siblings, 1 reply; 18+ messages in thread
From: Akib Azmain Turja @ 2022-12-19 18:00 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Emacs Developer List

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

Philip Kaludercic <philipk@posteo.net> writes:

> Akib Azmain Turja <akib@disroot.org> writes:
>
>> Denote-Refs shows links and backlinks inline in a Denote note buffer,
>> just below the front matter of the note.
>>
>> Here is the patch:
>>
>> From f4145634df9eb45df7d526871c55326bfafb3785 Mon Sep 17 00:00:00 2001
>> From: Akib Azmain Turja <akib@disroot.org>
>> Date: Mon, 19 Dec 2022 22:22:46 +0600
>> Subject: [PATCH] * elpa-packages (denote-refs): New package.
>>
>> ---
>>  elpa-packages | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/elpa-packages b/elpa-packages
>> index 9dde563..1d26a5a 100644
>> --- a/elpa-packages
>> +++ b/elpa-packages
>> @@ -108,6 +108,8 @@
>>    :ignored-files ("LICENSE" "test" "Cask" "Makefile")
>>    :news "CHANGELOG.md")
>>
>> + (denote-refs           :url "https://codeberg.org/akib/emacs-denote-refs")
>> +
>>   (devhelp               :url "https://codeberg.org/akib/emacs-devhelp")
>>
>>   (diff-ansi		:url "https://codeberg.org/ideasman42/emacs-diff-ansi"
>> --
>> 2.37.1
>
> Here are a few comments:
>
> diff -u /tmp/denote-refs.el.1 /tmp/denote-refs.el
> --- /tmp/denote-refs.el.1	2022-12-19 19:38:55.000000000 +0100
> +++ /tmp/denote-refs.el	2022-12-19 17:57:48.712068577 +0100

Wow, nanosecond precision.  :O

> @@ -5,8 +5,8 @@
>  ;; Author: Akib Azmain Turja <akib@disroot.org>
>  ;; Created: 2022-12-18
>  ;; Version: 0.1
> -;; Package-Requires: ((emacs "28.1"))
> -;; Keywords: hypermedia outlines files
> +;; Package-Requires: ((emacs "28.1") (denote "1.2.0"))
> +;; Keywords: hypermedia, outlines, files
>  ;; URL: https://codeberg.org/akib/emacs-denote-refs

Whoops, I forgot that.  :(
Done.

>
>  ;; This file is not part of GNU Emacs.
> @@ -36,12 +36,11 @@
>  (require 'denote)
>  (require 'subr-x)
>
> -(defgroup denote-refs nil
> +(defgroup denote-refs '()

Why?

>    "Show links and backlinks in Denote notes."
>    :group 'denote
> -  :group 'hypermedia
> -  :group 'outlines
> -  :group 'files
> +  ;; You don't need to add multiple groups, we only need it to appear
> +  ;; once in the customize hierarchy
>    :link '(url-link "https://codeberg.org/akib/emacs-denote-refs")
>    :prefix "denote-refs-")
>

Done.

> @@ -62,7 +61,8 @@
>
>  Available sections are `links' and `backlinks', which shows the list
>  of linked file and the list of backlinks respectively."
> -  :type '(set (const :tag "Links" links)
> +  :type '(set :greedy t
> +	      (const :tag "Links" links)
>                (const :tag "Backlinks" backlinks)))

What does ':greedy t' mean?

And anyway, I'm going to change that with 'repeat', since
'(links backlinks)', '(backlinks links)' and '(links backlinks links)'
all have meanings now.

New type: '(repeat (choice (const :tag "Links" links)
                           (const :tag "Backlinks" backlinks)))

Again the space-tab problem.  Added .dir-locals.el.

>
>  (defvar denote-refs--links 'not-ready
> @@ -83,65 +83,67 @@
>  (defun denote-refs--render (section)
>    "Render SECTION."
>    (let ((refs (pcase section
> -                ('links denote-refs--links)
> -                ('backlinks denote-refs--backlinks))))
> -    (pcase major-mode
> -      ;; There's no comment syntax in `text-mode', so just follow
> -      ;; `org-mode'.
> -      ((or 'org-mode 'text-mode)
> -       ;; Insert references count.
> -       (insert (if (eq refs 'not-ready)
> -                   (format "# ... %s\n" (if (eq section 'links)
> -                                            "links"
> -                                          "backlinks"))
> -                 (format "# %i %s%s\n" (length refs)
> -                         (if (eq section 'links)
> -                             "link"
> -                           "backlink")
> -                         (pcase (length refs)
> -                           (0 "")
> -                           (1 ":")
> -                           (_ "s:")))))
> -       ;; Insert reference list.
> -       (when (listp refs)
> -         (dolist (ref refs)
> -           (insert "#   ")
> -           (insert-button (car ref)
> -                          'help-echo (cdr ref)
> -                          'face 'denote-faces-link
> -                          'action (lambda (_)
> -                                    (funcall denote-link-button-action
> -                                             (cdr ref))))
> -           (insert ?\n))))
> -      ('markdown-mode
> -       ;; Insert references count.
> -       (insert (if (eq refs 'not-ready)
> -                   (format "<!-- ... %s -->\n" (if (eq section 'links)
> -                                                   "links"
> -                                                 "backlinks"))
> -                 (format "<!-- %i %s%s\n" (length refs)
> -                         (if (eq section 'links)
> -                             "link"
> -                           "backlink")
> -                         (pcase (length refs)
> -                           (0 " -->")
> -                           (1 ":")
> -                           (_ "s:")))))
> -       ;; Insert reference list.
> -       (when (listp refs)
> -         (while refs
> -           (let ((ref (pop refs)))
> -             (insert "  ")
> -             (insert-button
> -              (car ref)
> -              'help-echo (cdr ref)
> -              'face 'denote-faces-link
> -              'action (lambda (_)
> -                        (funcall denote-link-button-action
> -                                 (cdr ref))))
> -             (unless refs
> -               (insert " -->"))
> -             (insert ?\n))))))))
> +		('links denote-refs--links)
> +		('backlinks denote-refs--backlinks))))
> +    (cond
> +     ;; There's no comment syntax in `text-mode', so just follow
> +     ;; `org-mode'.
> +     ((derived-mode-p 'org-mode 'text-mode)
> +      ;; Insert references count.
> +      (insert (if (eq refs 'not-ready)
> +		  (format "# ... %s\n" (if (eq section 'links)
> +					   "links"
> +					 "backlinks"))
> +		(format "# %i %s%s\n" (length refs)
> +			(if (eq section 'links)
> +			    "link"
> +			  "backlink")
> +			(pcase (length refs)
> +			  (0 "")
> +			  (1 ":")
> +			  (_ "s:")))))
> +      ;; Insert reference list.
> +      (when (listp refs)
> +	(dolist (ref refs)
> +	  (insert "#   ")
> +	  (insert-button (car ref)
> +			 'help-echo (cdr ref)
> +			 'face 'denote-faces-link
> +			 'action (lambda (_)
> +				   (funcall denote-link-button-action
> +					    (cdr ref))))
> +	  ;; Could (newline) work here?
> +	  (insert ?\n))))
> +     ((derived-mode-p 'markdown-mode)
> +      ;; Insert references count.
> +      (insert (if (eq refs 'not-ready)
> +		  (format "<!-- ... %s -->\n" (if (eq section 'links)
> +						  "links"
> +						"backlinks"))
> +		(format "<!-- %i %s%s\n" (length refs)
> +			(if (eq section 'links)
> +			    "link"
> +			  "backlink")
> +			(pcase (length refs)
> +			  (0 " -->")
> +			  (1 ":")
> +			  (_ "s:")))))
> +      ;; Insert reference list.
> +      (when (listp refs)
> +	(while refs
> +	  (let ((ref (pop refs)))
> +	    (insert "  ")
> +	    (insert-button
> +	     (car ref)
> +	     'help-echo (cdr ref)
> +	     'face 'denote-faces-link
> +	     ;; This way we avoid creating a closure that ignores an
> +	     ;; argument.
> +	     'action #'denote-link-button-action
> +	     'button-data (cdr ref))
> +	    (unless refs
> +	      (insert " -->"))
> +	    (insert ?\n))))))))

+1.  Done.

>
>  (defun denote-refs--goto-end-of-front-matter ()
>    "Go to the end of front matter of the note."
> @@ -159,15 +161,14 @@
>      (save-excursion
>        (denote-refs--goto-end-of-front-matter)
>        (when (get-text-property (point) 'denote-refs--sections)
> -        (let ((end (or (next-single-property-change
> -                        (point) 'denote-refs--sections)
> -                       (point-max))))
> -          (when (< end (point-max))
> -            (setq end (1+ end)))
> -          (let ((mod-flag (buffer-modified-p))
> -                (inhibit-read-only t))
> -            (delete-region (point) end)
> -            (restore-buffer-modified-p mod-flag)))))))
> +	(let ((end (or (next-single-property-change
> +			(point) 'denote-refs--sections)
> +		       (point-max)))
> +	      (inhibit-read-only t))
> +	  (when (< end (point-max))
> +	    (setq end (1+ end)))
> +	  (with-silent-modifications
> +	    (delete-region (point) end)))))))
>
>  (defun denote-refs--show ()
>    "Show references."
> @@ -177,19 +178,18 @@
>      (denote-refs--remove)
>      (save-excursion
>        (denote-refs--goto-end-of-front-matter)
> -      (let ((begin (point))
> -            (mod-flag (buffer-modified-p))
> -            (inhibit-read-only t))
> -        (dolist (section denote-refs-sections)
> -          (pcase-exhaustive section
> -            ('links
> -             (denote-refs--render 'links))
> -            ('backlinks
> -             (denote-refs--render 'backlinks))))
> -        (put-text-property begin (point) 'read-only t)
> -        (put-text-property begin (point) 'denote-refs--sections t)
> -        (insert ?\n)
> -        (restore-buffer-modified-p mod-flag)))))
> +      (with-silent-modifications
> +	(let ((begin (point))
> +	      (inhibit-read-only t))
> +	  (dolist (section denote-refs-sections)
> +	    (pcase-exhaustive section
> +	      ('links
> +	       (denote-refs--render 'links))
> +	      ('backlinks
> +	       (denote-refs--render 'backlinks))))
> +	  (put-text-property begin (point) 'read-only t)
> +	  (put-text-property begin (point) 'denote-refs--sections t)
> +	  (insert ?\n))))))

+1.  Done.  Also got rid of the undo problem.  :)

>
>  (defun denote-refs--make-path-relative (path)
>    "Return a cons of relative and absolute version of PATH.
> @@ -203,22 +203,22 @@
>      (pcase-exhaustive section
>        ('links
>         (setq denote-refs--links
> -             (when (and (buffer-file-name)
> -                        (file-exists-p (buffer-file-name)))
> -               (mapcar #'denote-refs--make-path-relative
> -                       (denote-link--expand-identifiers
> -                        (denote--link-in-context-regexp
> -                         (denote-filetype-heuristics
> -                          (buffer-file-name))))))))
> +	     (and (buffer-file-name)
> +		  (file-exists-p (buffer-file-name))
> +		  (mapcar #'denote-refs--make-path-relative
> +			  (denote-link--expand-identifiers
> +			   (denote--link-in-context-regexp
> +			    (denote-filetype-heuristics
> +			     (buffer-file-name))))))))
>        ('backlinks
>         (setq denote-refs--backlinks
> -             (when (and (buffer-file-name)
> -                        (file-exists-p (buffer-file-name)))
> -               (mapcar #'denote-refs--make-path-relative
> -                       (delete (buffer-file-name)
> -                               (denote--retrieve-files-in-xrefs
> -                                (denote-retrieve-filename-identifier
> -                                 (buffer-file-name)))))))))))
> +	     (and (buffer-file-name)
> +		  (file-exists-p (buffer-file-name))
> +		  (mapcar #'denote-refs--make-path-relative
> +			  (delete (buffer-file-name)
> +				  (denote--retrieve-files-in-xrefs
> +				   (denote-retrieve-filename-identifier
> +				    (buffer-file-name)))))))))))
>

OK.  Done.

>  (defun denote-refs-update ()
>    "Update Denote references shown."
>
> Diff finished.  Mon Dec 19 17:57:57 2022

Thanks for the information.  I guess you live somewhere at UTC+1, based
on the email timestamp and diff timestamp.

>

FYI, you missed the missing ;;;###autoload.  I just added it.

--
Akib Azmain Turja, GPG key: 70018CE5819F17A3BBA666AFE74F0EFA922AE7F5
Fediverse: akib@hostux.social
Codeberg: akib
emailselfdefense.fsf.org | "Nothing can be secure without encryption."

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-19 18:00   ` Akib Azmain Turja
@ 2022-12-19 19:19     ` Philip Kaludercic
  2022-12-19 20:20       ` [External] : " Drew Adams
  2022-12-20 15:09       ` Akib Azmain Turja
  0 siblings, 2 replies; 18+ messages in thread
From: Philip Kaludercic @ 2022-12-19 19:19 UTC (permalink / raw)
  To: Akib Azmain Turja; +Cc: Emacs Developer List

Akib Azmain Turja <akib@disroot.org> writes:

> Philip Kaludercic <philipk@posteo.net> writes:
>
>> Akib Azmain Turja <akib@disroot.org> writes:
>>
>>> Denote-Refs shows links and backlinks inline in a Denote note buffer,
>>> just below the front matter of the note.
>>>
>>> Here is the patch:
>>>
>>> From f4145634df9eb45df7d526871c55326bfafb3785 Mon Sep 17 00:00:00 2001
>>> From: Akib Azmain Turja <akib@disroot.org>
>>> Date: Mon, 19 Dec 2022 22:22:46 +0600
>>> Subject: [PATCH] * elpa-packages (denote-refs): New package.
>>>
>>> ---
>>>  elpa-packages | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/elpa-packages b/elpa-packages
>>> index 9dde563..1d26a5a 100644
>>> --- a/elpa-packages
>>> +++ b/elpa-packages
>>> @@ -108,6 +108,8 @@
>>>    :ignored-files ("LICENSE" "test" "Cask" "Makefile")
>>>    :news "CHANGELOG.md")
>>>
>>> + (denote-refs           :url "https://codeberg.org/akib/emacs-denote-refs")
>>> +
>>>   (devhelp               :url "https://codeberg.org/akib/emacs-devhelp")
>>>
>>>   (diff-ansi		:url "https://codeberg.org/ideasman42/emacs-diff-ansi"
>>> --
>>> 2.37.1
>>
>> Here are a few comments:
>>
>> diff -u /tmp/denote-refs.el.1 /tmp/denote-refs.el
>> --- /tmp/denote-refs.el.1	2022-12-19 19:38:55.000000000 +0100
>> +++ /tmp/denote-refs.el	2022-12-19 17:57:48.712068577 +0100
>
> Wow, nanosecond precision.  :O

I made the mistake of downloading the file via wget, so I had to
download it once more (.1) to create the diff.

>>
>>  ;; This file is not part of GNU Emacs.
>> @@ -36,12 +36,11 @@
>>  (require 'denote)
>>  (require 'subr-x)
>>
>> -(defgroup denote-refs nil
>> +(defgroup denote-refs '()
>
> Why?

It is just a personal preference of mine, since the argument MEMBER is
an alist.  I think that '() makes it more explicit that this is a list,
as opposed to nil which might also be taken to be a truth value.  I
guess () would do as well...

>> @@ -62,7 +61,8 @@
>>
>>  Available sections are `links' and `backlinks', which shows the list
>>  of linked file and the list of backlinks respectively."
>> -  :type '(set (const :tag "Links" links)
>> +  :type '(set :greedy t
>> +	      (const :tag "Links" links)
>>                (const :tag "Backlinks" backlinks)))
>
> What does ':greedy t' mean?

It ensures that the type matches even if the order is changed (which
arguably should always be the case for a set).

> And anyway, I'm going to change that with 'repeat', since
> '(links backlinks)', '(backlinks links)' and '(links backlinks links)'
> all have meanings now.
>
> New type: '(repeat (choice (const :tag "Links" links)
>                            (const :tag "Backlinks" backlinks)))

In that case this is preferable.

> Again the space-tab problem.  Added .dir-locals.el.

1+

>>  (defun denote-refs-update ()
>>    "Update Denote references shown."
>>
>> Diff finished.  Mon Dec 19 17:57:57 2022
>
> Thanks for the information.  I guess you live somewhere at UTC+1, based
> on the email timestamp and diff timestamp.

Right, Germany :)

>>
>
> FYI, you missed the missing ;;;###autoload.  I just added it.

Sorry about that ^^

I'll go ahead and add this to NonGNU ELPA.



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

* RE: [External] : Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-19 19:19     ` Philip Kaludercic
@ 2022-12-19 20:20       ` Drew Adams
  2022-12-19 21:08         ` Philip Kaludercic
  2022-12-20 15:09       ` Akib Azmain Turja
  1 sibling, 1 reply; 18+ messages in thread
From: Drew Adams @ 2022-12-19 20:20 UTC (permalink / raw)
  To: Philip Kaludercic, Akib Azmain Turja; +Cc: Emacs Developer List

> >> -(defgroup denote-refs nil
> >> +(defgroup denote-refs '()
> > Why?
> 
> It is just a personal preference of mine, since the argument MEMBER is
> an alist.  I think that '() makes it more explicit that this is a list,
> as opposed to nil which might also be taken to be a truth value.  I
> guess () would do as well...

Yes, () would do as well - in fact better, since it
doesn't suggest any possibility that '() represents
something different from ().

You don't quote nil or t, do you?  Or 42 or "foo" or
:bar.  Why quote () then?

As the manual says:

  As far as the Lisp reader is concerned, '()' and 'nil'
  are identical: they stand for the same object, the
  symbol 'nil'.  The different ways of writing the symbol
  are intended entirely for human readers.  After the
  Lisp reader has read either '()' or 'nil', there is no
  way to determine which representation was actually
  written by the programmer.

  In this manual, we write '()' when we wish to emphasize
  that it means the empty list, and we write 'nil' when
  we wish to emphasize that it means the truth value FALSE.
  That is a good convention to use in Lisp programs also.

And yes, it's a good convention -- +1 for that.



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

* Re: [External] : Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-19 20:20       ` [External] : " Drew Adams
@ 2022-12-19 21:08         ` Philip Kaludercic
  2022-12-19 21:51           ` Drew Adams
  0 siblings, 1 reply; 18+ messages in thread
From: Philip Kaludercic @ 2022-12-19 21:08 UTC (permalink / raw)
  To: Drew Adams; +Cc: Akib Azmain Turja, Emacs Developer List

Drew Adams <drew.adams@oracle.com> writes:

>> >> -(defgroup denote-refs nil
>> >> +(defgroup denote-refs '()
>> > Why?
>> 
>> It is just a personal preference of mine, since the argument MEMBER is
>> an alist.  I think that '() makes it more explicit that this is a list,
>> as opposed to nil which might also be taken to be a truth value.  I
>> guess () would do as well...
>
> Yes, () would do as well - in fact better, since it
> doesn't suggest any possibility that '() represents
> something different from ().
>
> You don't quote nil or t, do you?  Or 42 or "foo" or
> :bar.  Why quote () then?

In this case it doesn't matter, because () is self-evaluating, but (foo)
isn't, so to me it seems more consistent to treat () as a list where I
want to make it explicit that I am inhibiting evaluation.

> As the manual says:
>
>   As far as the Lisp reader is concerned, '()' and 'nil'
>   are identical: they stand for the same object, the
>   symbol 'nil'.  The different ways of writing the symbol
>   are intended entirely for human readers.  After the
>   Lisp reader has read either '()' or 'nil', there is no
>   way to determine which representation was actually
>   written by the programmer.
>
>   In this manual, we write '()' when we wish to emphasize
>   that it means the empty list, and we write 'nil' when
>   we wish to emphasize that it means the truth value FALSE.
>   That is a good convention to use in Lisp programs also.
>
> And yes, it's a good convention -- +1 for that.



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

* RE: [External] : Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-19 21:08         ` Philip Kaludercic
@ 2022-12-19 21:51           ` Drew Adams
  2022-12-20 16:48             ` Philip Kaludercic
  0 siblings, 1 reply; 18+ messages in thread
From: Drew Adams @ 2022-12-19 21:51 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Akib Azmain Turja, Emacs Developer List

> > Yes, () would do as well - in fact better, since it
> > doesn't suggest any possibility that '() represents
> > something different from ().
> >
> > You don't quote nil or t, do you?  Or 42 or "foo" or
> > :bar.  Why quote () then?
> 
> In this case it doesn't matter, because () is self-evaluating, but (foo)
> isn't, so to me it seems more consistent to treat () as a list where I
> want to make it explicit that I am inhibiting evaluation.

Why do you want to make it explicit that you're
inhibiting evaluation?

As you say, in the case of () "it doesn't matter".
But that's the only case we're (I'm) talking about.

Apparently it does matter to you.  It matters to
make it clear that you're inhibiting evaluation.
Why?  What are you trying to say to a (human)
reader by doing that?

Not a rhetorical question; I really wonder what
your thinking is about this.  You're not the first
to do this on purpose, but I've never understood
why someone would (in Elisp).

It's not a big deal, admittedly.  But to me doing
that could suggest to a human reader that there's
some difference between evaluating '() and ().

To me, including in terms of communicating with a
human, this case is no different from t/nil/42/:foo.
Why "inhibit evaluation" of something that evaluates
to itself, and why draw attention to the fact that
you're doing that?  What's the human message there?

I mean, if the point of using () instead of nil
is to pass a certain connation to a human reader,
then we're (both) trying to give some importance
to that human message - saying a bit more than
just that the value is nil.  In that context (of
admittedly minor importance), avoiding suggesting
something untrue is relevant.



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

* Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-19 19:19     ` Philip Kaludercic
  2022-12-19 20:20       ` [External] : " Drew Adams
@ 2022-12-20 15:09       ` Akib Azmain Turja
  2022-12-20 16:55         ` Philip Kaludercic
  1 sibling, 1 reply; 18+ messages in thread
From: Akib Azmain Turja @ 2022-12-20 15:09 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Emacs Developer List

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

Philip Kaludercic <philipk@posteo.net> writes:

[...]

> I'll go ahead and add this to NonGNU ELPA.

Thanks!  Got the mail!

Anyway, do you think it is a good idea to write some text temporarily in
a buffer?  My experience suggests no, but if I use overlays then I can't
select and press RET on the links, and I can't scroll if the list is too
long.  WDYT?

-- 
Akib Azmain Turja, GPG key: 70018CE5819F17A3BBA666AFE74F0EFA922AE7F5
Fediverse: akib@hostux.social
Codeberg: akib
emailselfdefense.fsf.org | "Nothing can be secure without encryption."

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [External] : Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-19 21:51           ` Drew Adams
@ 2022-12-20 16:48             ` Philip Kaludercic
  2022-12-20 17:39               ` Drew Adams
  0 siblings, 1 reply; 18+ messages in thread
From: Philip Kaludercic @ 2022-12-20 16:48 UTC (permalink / raw)
  To: Drew Adams; +Cc: Akib Azmain Turja, Emacs Developer List

Drew Adams <drew.adams@oracle.com> writes:

>> > Yes, () would do as well - in fact better, since it
>> > doesn't suggest any possibility that '() represents
>> > something different from ().
>> >
>> > You don't quote nil or t, do you?  Or 42 or "foo" or
>> > :bar.  Why quote () then?
>> 
>> In this case it doesn't matter, because () is self-evaluating, but (foo)
>> isn't, so to me it seems more consistent to treat () as a list where I
>> want to make it explicit that I am inhibiting evaluation.
>
> Why do you want to make it explicit that you're
> inhibiting evaluation?
>
> As you say, in the case of () "it doesn't matter".
> But that's the only case we're (I'm) talking about.
>
> Apparently it does matter to you.  It matters to
> make it clear that you're inhibiting evaluation.
> Why?  What are you trying to say to a (human)
> reader by doing that?
>
> Not a rhetorical question; I really wonder what
> your thinking is about this.  You're not the first
> to do this on purpose, but I've never understood
> why someone would (in Elisp).

While I understand why () doesn't need to be quoted -- in the sense that
the reader sees no difference between the empty list literal and the
empty list notation -- I just don't like the inconsistency between the
requirement to quote a non-empty list if I want to inhibit evaluation,
while this is not the case for an empty list.

        '(1 2 3)

has to be quoted,

        '(1 2)

has to be quoted,

        '(1)

has to be quoted, but

        '()

suddenly doesn't?  If it weren't necessary, I'd consider the `eq`ality
of '(), () and nil this an implementation detail.

> It's not a big deal, admittedly.  But to me doing
> that could suggest to a human reader that there's
> some difference between evaluating '() and ().
>
> To me, including in terms of communicating with a
> human, this case is no different from t/nil/42/:foo.
> Why "inhibit evaluation" of something that evaluates
> to itself, and why draw attention to the fact that
> you're doing that?  What's the human message there?
>
> I mean, if the point of using () instead of nil
> is to pass a certain connation to a human reader,
> then we're (both) trying to give some importance
> to that human message - saying a bit more than
> just that the value is nil.  In that context (of
> admittedly minor importance), avoiding suggesting
> something untrue is relevant.

Another point is that in the case of deftheme, the () might look like a
empty parameter list, sort of like how (defun foo () ...) might look
like.  By explicitly quoting the list, we "clarify" that this is not the
same kind of thing.



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

* Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-20 15:09       ` Akib Azmain Turja
@ 2022-12-20 16:55         ` Philip Kaludercic
  2022-12-20 20:17           ` Akib Azmain Turja
  0 siblings, 1 reply; 18+ messages in thread
From: Philip Kaludercic @ 2022-12-20 16:55 UTC (permalink / raw)
  To: Akib Azmain Turja; +Cc: Emacs Developer List

Akib Azmain Turja <akib@disroot.org> writes:

> Philip Kaludercic <philipk@posteo.net> writes:
>
> [...]
>
>> I'll go ahead and add this to NonGNU ELPA.
>
> Thanks!  Got the mail!
>
> Anyway, do you think it is a good idea to write some text temporarily in
> a buffer?  My experience suggests no, but if I use overlays then I can't
> select and press RET on the links, and I can't scroll if the list is too
> long.  WDYT?

I am afraid I am not certain what you are talking about.  Can you point
me to the concrete use-case?



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

* RE: [External] : Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-20 16:48             ` Philip Kaludercic
@ 2022-12-20 17:39               ` Drew Adams
  2022-12-21  0:05                 ` Philip Kaludercic
  0 siblings, 1 reply; 18+ messages in thread
From: Drew Adams @ 2022-12-20 17:39 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Akib Azmain Turja, Emacs Developer List

> While I understand why () doesn't need to be quoted -- in the sense that
> the reader sees no difference between the empty list literal and the
> empty list notation -- I just don't like the inconsistency between the
> requirement to quote a non-empty list if I want to inhibit evaluation,
> while this is not the case for an empty list.
> 
> '(1 2 3) has to be quoted,
> '(1 2) has to be quoted,
> '(1) has to be quoted, but
> '() suddenly doesn't?
>
> If it weren't necessary, I'd consider the `eq`ality
> of '(), () and nil this an implementation detail.

(list 1) and '(1) are (construct) conses.
() isn't a cons.  

Not just an implementation detail - different
critters - as different as nullary constructor
`zero' and unary constructor `successor'.

> Another point is that in the case of deftheme, the () might look like a
> empty parameter list, sort of like how (defun foo () ...) might look
> like.  By explicitly quoting the list, we "clarify" that this is not the
> same kind of thing.

Can't speak to this; dunno what () you mean.

But `deftheme' is a macro.  Any understanding
of any of its parts has to come from the doc
string (or code).  A part (including ()) of a
macro call could mean anything, depending on
the macro definition.

Anyway, I appreciate your communicating the
reasons behind your preference.  There's no
right or wrong when it comes to des goûts et
des couleurs.  Thx.



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

* Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-20 16:55         ` Philip Kaludercic
@ 2022-12-20 20:17           ` Akib Azmain Turja
  2022-12-20 22:02             ` Stefan Monnier
  0 siblings, 1 reply; 18+ messages in thread
From: Akib Azmain Turja @ 2022-12-20 20:17 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Emacs Developer List

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

Philip Kaludercic <philipk@posteo.net> writes:

> Akib Azmain Turja <akib@disroot.org> writes:
>
>> Philip Kaludercic <philipk@posteo.net> writes:
>>
>> [...]
>>
>>> I'll go ahead and add this to NonGNU ELPA.
>>
>> Thanks!  Got the mail!
>>
>> Anyway, do you think it is a good idea to write some text temporarily in
>> a buffer?  My experience suggests no, but if I use overlays then I can't
>> select and press RET on the links, and I can't scroll if the list is too
>> long.  WDYT?
>
> I am afraid I am not certain what you are talking about.  Can you point
> me to the concrete use-case?

Here is a simplified representation:

Original file:

--8<---------------cut here---------------start------------->8---
#+title: Foo
#+identifier: 12121212T121212

--8<---------------cut here---------------end--------------->8---

After 'denote-refs-mode' enabled:

--8<---------------cut here---------------start------------->8---
#+title: Foo
#+identifier: 12121212T121212

# 1 link
#   12121212T111111--bar__baz.org
# 1 backlink
#   12121212T131313--frob__nil.org

--8<---------------cut here---------------end--------------->8---

While saving (I don't know what happens while auto-saving :( ),
reverted:

--8<---------------cut here---------------start------------->8---
#+title: Foo
#+identifier: 12121212T121212

--8<---------------cut here---------------end--------------->8---

After saving, again:

--8<---------------cut here---------------start------------->8---
#+title: Foo
#+identifier: 12121212T121212

# 1 link
#   12121212T111111--bar__baz.org
# 1 backlink
#   12121212T131313--frob__nil.org

--8<---------------cut here---------------end--------------->8---

Inside 'xref--collect-matches', reverted, otherwise xref doesn't match
correctly, since the file and buffer lines don't really match.  After
'xref--collect-matches', again the text.

I'll need more workaround than the number of feature it provides.  So,

Do you think it is a good idea to write some text temporarily in a
buffer like this?  My experience suggests no, but if I use overlays then
I can't select a link (not really impossible, but complicated) and press
RET on the links, and I can't scroll if the list is too long.

-- 
Akib Azmain Turja, GPG key: 70018CE5819F17A3BBA666AFE74F0EFA922AE7F5
Fediverse: akib@hostux.social
Codeberg: akib
emailselfdefense.fsf.org | "Nothing can be secure without encryption."

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-20 20:17           ` Akib Azmain Turja
@ 2022-12-20 22:02             ` Stefan Monnier
  2022-12-21 16:03               ` Akib Azmain Turja
  0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2022-12-20 22:02 UTC (permalink / raw)
  To: Akib Azmain Turja; +Cc: Philip Kaludercic, Emacs Developer List

>>> Anyway, do you think it is a good idea to write some text temporarily in
>>> a buffer?

It's useful to clarify your question by mentioning that you're talking
about a file buffer :-)

It's usually not recommended to make the buffer's content different from
the file's content, because it makes things more complicated and comes
with various caveat and rough edges.

But we do that on various occasions nevertheless.

Packages that come to mind are `hexl-mode`, `archive-mode` and
`tar-mode`, for example.  Rmail to some extent as well, I'm sure there
are many more.

>>> My experience suggests no, but if I use overlays then I can't select
>>> and press RET on the links, and I can't scroll if the list is too
>>> long.  WDYT?

Indeed.  In `nhexl-mode` I try to make overlays work a bit like "plain
text" works in `hexl-mode`, but it takes work and the result is
still limited.

> While saving, reverted:

Which mechanism did you use for that?

> (I don't know what happens while auto-saving :( )

If you haven't done anything for that, autosaving will save the
buffer's content as is.

A good way to make the save work correctly both for `save-buffer` and
for auto-save is to use `write-region-annotate-functions`.
That hook doesn't directly let you remove text, but it can `set-buffer`
to a new buffer in which case that other buffer's content will be
written instead.

> Inside 'xref--collect-matches', reverted, otherwise xref doesn't match
> correctly, since the file and buffer lines don't really match.  After
> 'xref--collect-matches', again the text.

Exactly: it comes with a lot of caveats :-(

Another approach is to use *another* buffer than the file buffer.
This is less transparent to the user but tends to come with fewer
dark corners.


        Stefan




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

* Re: [External] : Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-20 17:39               ` Drew Adams
@ 2022-12-21  0:05                 ` Philip Kaludercic
  2022-12-21  5:22                   ` Drew Adams
  0 siblings, 1 reply; 18+ messages in thread
From: Philip Kaludercic @ 2022-12-21  0:05 UTC (permalink / raw)
  To: Drew Adams; +Cc: Akib Azmain Turja, Emacs Developer List

Drew Adams <drew.adams@oracle.com> writes:

>> While I understand why () doesn't need to be quoted -- in the sense that
>> the reader sees no difference between the empty list literal and the
>> empty list notation -- I just don't like the inconsistency between the
>> requirement to quote a non-empty list if I want to inhibit evaluation,
>> while this is not the case for an empty list.
>> 
>> '(1 2 3) has to be quoted,
>> '(1 2) has to be quoted,
>> '(1) has to be quoted, but
>> '() suddenly doesn't?
>>
>> If it weren't necessary, I'd consider the `eq`ality
>> of '(), () and nil this an implementation detail.
>
> (list 1) and '(1) are (construct) conses.
> () isn't a cons.  
>
> Not just an implementation detail - different
> critters - as different as nullary constructor
> `zero' and unary constructor `successor'.



>> Another point is that in the case of deftheme, the () might look like a
>> empty parameter list, sort of like how (defun foo () ...) might look
>> like.  By explicitly quoting the list, we "clarify" that this is not the
>> same kind of thing.
>
> Can't speak to this; dunno what () you mean.

This one:

     (defun foo (bar) baz)
                ^

or in the case of a nullary function:

     (defun foo () baz)
                ^

> But `deftheme' is a macro.  Any understanding
> of any of its parts has to come from the doc
> string (or code).  A part (including ()) of a
> macro call could mean anything, depending on
> the macro definition.

I'll be honest, I have never used the MEMBERS parameter of `defgroup' (I
assume you meant that), but it appears it is passed without quotation:

  (macroexpand-1 '(defgroup foo bar "This is a group"))
  => (custom-declare-group 'foo bar "This is a group")

That means that this list is not just a part of the "syntax structure",
as it is with `defun', but an actual value.

> Anyway, I appreciate your communicating the
> reasons behind your preference.  There's no
> right or wrong when it comes to des goûts et
> des couleurs.  Thx.

Sure, that is why I just suggested that Akib think about it, but if it
is his style to prefer nil over () or '(), then that is fine as well.



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

* RE: [External] : Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-21  0:05                 ` Philip Kaludercic
@ 2022-12-21  5:22                   ` Drew Adams
  2022-12-21  9:07                     ` Philip Kaludercic
  0 siblings, 1 reply; 18+ messages in thread
From: Drew Adams @ 2022-12-21  5:22 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Akib Azmain Turja, Emacs Developer List

> >> Another point is that in the case of deftheme, the () might look like a
> >> empty parameter list, sort of like how (defun foo () ...) might look
> >> like.  By explicitly quoting the list, we "clarify" that this is not the
> >> same kind of thing.
> >
> > Can't speak to this; dunno what () you mean.
> 
> This one: (defun foo (bar) baz)
>                      ^
> or in the case of a nullary function:
>      (defun foo () baz)
>                 ^

I guess we're miscommunicating?

I understood that.  I meant that I don't know
what () you meant for `deftheme'.  That's all.

But again, `defun' and `deftheme' are macros.
By default macros don't evaluate their args.
What they do with their args is up to them.
(And `defun' doesn't evaluate the (bar) or ().)

> > But `deftheme' is a macro.  Any understanding
> > of any of its parts has to come from the doc
> > string (or code).  A part (including ()) of a
> > macro call could mean anything, depending on
> > the macro definition.
> 
> I'll be honest, I have never used the MEMBERS parameter of `defgroup' (I
> assume you meant that), 

No idea what you're talking about, sorry.
I was talking about `deftheme' being a macro.
I didn't mention `defgroup' or MEMBERS.

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

* Re: [External] : Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-21  5:22                   ` Drew Adams
@ 2022-12-21  9:07                     ` Philip Kaludercic
  2022-12-21 15:50                       ` Drew Adams
  0 siblings, 1 reply; 18+ messages in thread
From: Philip Kaludercic @ 2022-12-21  9:07 UTC (permalink / raw)
  To: Drew Adams; +Cc: Akib Azmain Turja, Emacs Developer List

Drew Adams <drew.adams@oracle.com> writes:

>> >> Another point is that in the case of deftheme, the () might look like a
>> >> empty parameter list, sort of like how (defun foo () ...) might look
>> >> like.  By explicitly quoting the list, we "clarify" that this is not the
>> >> same kind of thing.
>> >
>> > Can't speak to this; dunno what () you mean.
>> 
>> This one: (defun foo (bar) baz)
>>                      ^
>> or in the case of a nullary function:
>>      (defun foo () baz)
>>                 ^
>
> I guess we're miscommunicating?
>
> I understood that.  I meant that I don't know
> what () you meant for `deftheme'.  That's all.

If I said deftheme in a previous message, I blame that on a careless
M-/.  I never meant to say that.

> But again, `defun' and `deftheme' are macros.
> By default macros don't evaluate their args.
> What they do with their args is up to them.
> (And `defun' doesn't evaluate the (bar) or ().)

Right, but defgroup passes the list further to be evaluated.

>> > But `deftheme' is a macro.  Any understanding
>> > of any of its parts has to come from the doc
>> > string (or code).  A part (including ()) of a
>> > macro call could mean anything, depending on
>> > the macro definition.
>> 
>> I'll be honest, I have never used the MEMBERS parameter of `defgroup' (I
>> assume you meant that), 
>
> No idea what you're talking about, sorry.
> I was talking about `deftheme' being a macro.
> I didn't mention `defgroup' or MEMBERS.

I was under the impression that the entire discussion was about the
MEMBERS argument of the defgroup macro?



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

* RE: [External] : Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-21  9:07                     ` Philip Kaludercic
@ 2022-12-21 15:50                       ` Drew Adams
  0 siblings, 0 replies; 18+ messages in thread
From: Drew Adams @ 2022-12-21 15:50 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Akib Azmain Turja, Emacs Developer List

> >> I'll be honest, I have never used the MEMBERS parameter 
> >> of `defgroup' (I assume you meant that),
> >
> > No idea what you're talking about, sorry.
> > I was talking about `deftheme' being a macro.
> > I didn't mention `defgroup' or MEMBERS.
> 
> I was under the impression that the entire discussion 
> was about the MEMBERS argument of the defgroup macro?

Not the discussion with me (not my part of any
discussion, anyway).  Chalk this one up to the
facility of miscommunication by email, I guess.



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

* Re: [NonGNU ELPA] New package: Denote-Refs
  2022-12-20 22:02             ` Stefan Monnier
@ 2022-12-21 16:03               ` Akib Azmain Turja
  0 siblings, 0 replies; 18+ messages in thread
From: Akib Azmain Turja @ 2022-12-21 16:03 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Philip Kaludercic, Emacs Developer List

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

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>>> Anyway, do you think it is a good idea to write some text temporarily in
>>>> a buffer?
>
> It's useful to clarify your question by mentioning that you're talking
> about a file buffer :-)
>
> It's usually not recommended to make the buffer's content different from
> the file's content, because it makes things more complicated and comes
> with various caveat and rough edges.
>
> But we do that on various occasions nevertheless.
>
> Packages that come to mind are `hexl-mode`, `archive-mode` and
> `tar-mode`, for example.  Rmail to some extent as well, I'm sure there
> are many more.
>
>>>> My experience suggests no, but if I use overlays then I can't select
>>>> and press RET on the links, and I can't scroll if the list is too
>>>> long.  WDYT?
>
> Indeed.  In `nhexl-mode` I try to make overlays work a bit like "plain
> text" works in `hexl-mode`, but it takes work and the result is
> still limited.
>
>> While saving, reverted:
>
> Which mechanism did you use for that?

'before-save-hook'.

>
>> (I don't know what happens while auto-saving :( )
>
> If you haven't done anything for that, autosaving will save the
> buffer's content as is.
>
> A good way to make the save work correctly both for `save-buffer` and
> for auto-save is to use `write-region-annotate-functions`.
> That hook doesn't directly let you remove text, but it can `set-buffer`
> to a new buffer in which case that other buffer's content will be
> written instead.
>

Seems to be an hack, but probably better.

>> Inside 'xref--collect-matches', reverted, otherwise xref doesn't match
>> correctly, since the file and buffer lines don't really match.  After
>> 'xref--collect-matches', again the text.
>
> Exactly: it comes with a lot of caveats :-(
>
> Another approach is to use *another* buffer than the file buffer.
> This is less transparent to the user but tends to come with fewer
> dark corners.

My goal is show on the file buffer.  And the list can be quite large.

>
>
>         Stefan
>

-- 
Akib Azmain Turja, GPG key: 70018CE5819F17A3BBA666AFE74F0EFA922AE7F5
Fediverse: akib@hostux.social
Codeberg: akib
emailselfdefense.fsf.org | "Nothing can be secure without encryption."

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

end of thread, other threads:[~2022-12-21 16:03 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-19 16:31 [NonGNU ELPA] New package: Denote-Refs Akib Azmain Turja
2022-12-19 16:58 ` Philip Kaludercic
2022-12-19 18:00   ` Akib Azmain Turja
2022-12-19 19:19     ` Philip Kaludercic
2022-12-19 20:20       ` [External] : " Drew Adams
2022-12-19 21:08         ` Philip Kaludercic
2022-12-19 21:51           ` Drew Adams
2022-12-20 16:48             ` Philip Kaludercic
2022-12-20 17:39               ` Drew Adams
2022-12-21  0:05                 ` Philip Kaludercic
2022-12-21  5:22                   ` Drew Adams
2022-12-21  9:07                     ` Philip Kaludercic
2022-12-21 15:50                       ` Drew Adams
2022-12-20 15:09       ` Akib Azmain Turja
2022-12-20 16:55         ` Philip Kaludercic
2022-12-20 20:17           ` Akib Azmain Turja
2022-12-20 22:02             ` Stefan Monnier
2022-12-21 16:03               ` Akib Azmain Turja

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.