emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Patch to add a new org-archive hook and context info type
@ 2024-11-07  6:19 John Wiegley
  2024-11-23 16:45 ` Problem installing Org using the Emacs packaging system Alain.Cochard
  0 siblings, 1 reply; 2+ messages in thread
From: John Wiegley @ 2024-11-07  6:19 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

The following patch adds ‘org-archive-finalize-hook’, which runs earlier than
‘org-archive-hook’ and in the destination buffer, not the original file. This
allows the context to be extended, the archived entry to be cleaned up after
inseration, maybe even encrypted or hashed to prevent changes.

I also added a new ‘ARCHIVE_OLID’ context type, which preserves the ID of the
parent the archived entry was previously under. This is because ARCHIVE_OLPATH
is not stable: it’s very possible the tree structure may change over time and
invalidate the path. But as long as the original parent is not deleted, there
stands a better chance that the original context of the archived entry can be
restored.

John

--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -144,13 +144,26 @@ information."
 	      (const :tag "Priority" priority)
 	      (const :tag "Inherited tags" itags)
 	      (const :tag "Outline path" olpath)
+	      (const :tag "Outline parent id" olid)
 	      (const :tag "Local tags" ltags)))
 
-(defvar org-archive-hook nil
+(defcustom org-archive-hook nil
   "Hook run after successfully archiving a subtree.
 Hook functions are called with point on the subtree in the
 original file.  At this stage, the subtree has been added to the
-archive location, but not yet deleted from the original file.")
+archive location, but not yet deleted from the original file."
+  :group 'org-archive
+  :type 'hook)
+
+(defcustom org-archive-finalize-hook nil
+  "Hook run after successfully archiving a subtree in final location.
+Hook functions are called with point on the subtree in the
+destination file. Compare this with `org-archive-hook', which
+runs in the original file. At this stage, the subtree has been
+added to the archive location, but not yet deleted from the
+original file."
+  :group 'org-archive
+  :type 'hook)
 
 ;;;###autoload
 (defun org-add-archive-files (files)
@@ -299,6 +312,9 @@ direct children of this heading."
 		    (olpath . ,(mapconcat #'identity
 					  (org-get-outline-path)
 					  "/"))
+                    (olid . ,(org-with-wide-buffer
+                              (and (org-up-heading-safe)
+	                           (org-entry-get (point) "ID"))))
 		    (time . ,time)
 		    (todo . ,(org-entry-get (point) "TODO")))))
 	    ;; We first only copy, in case something goes wrong
@@ -393,6 +409,7 @@ direct children of this heading."
 		     (point)
 		     (concat "ARCHIVE_" (upcase (symbol-name item)))
 		     value))))
+              (run-hooks 'org-archive-finalize-hook)
 	      ;; Save the buffer, if it is not the same buffer and
 	      ;; depending on `org-archive-subtree-save-file-p'.
 	      (unless (eq this-buffer buffer)


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

* Problem installing Org using the Emacs packaging system
  2024-11-07  6:19 Patch to add a new org-archive hook and context info type John Wiegley
@ 2024-11-23 16:45 ` Alain.Cochard
  0 siblings, 0 replies; 2+ messages in thread
From: Alain.Cochard @ 2024-11-23 16:45 UTC (permalink / raw)
  To: emacs-orgmode

Hello.  An excerpt of the page 

https://orgmode.org/manual/Installation.html

is 

   Using Emacs packaging system

   Recent Emacs distributions include a packaging system which lets you
   install Elisp libraries. You can install Org from the “package menu”,
   with M-x list-packages. See Package Menu.

       Important: You need to do this in a session where no ‘.org’ file has
       been visited, i.e., where no Org built-in function have been
       loaded. Otherwise autoload Org functions will mess up the
       installation.

   To avoid interference with built-in Org mode, you can use command line:

   emacs -Q -batch -eval "(progn (require 'package) (package-initialize)
   (package-refresh-contents) (package-upgrade 'org))"

   This approach has the advantage of isolating the upgrade process from a
   running Emacs session, ensuring that version conflicts can not arise.

I have used the emacs batch command above on a number of machines but it
always failed (see below), so I guess I am doing something wrong, but what?

Anyway, is it correct that one does not need this command to avoid the
above mentioned interferences, provided that a single Emacs session is
running, and in which no org file has been visited (.org or otherwise)?

Thanks.


NB: I of course type the emacs command on a single line of a regular
terminal.

* Fedora 40 

Linux frac.u-strasbg.fr 6.11.5-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Tue
Oct 22 19:13:11 UTC 2024 x86_64 GNU/Linux

GNU Emacs 29.4 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.42,
cairo version 1.18.0) of 2024-07-16

Org mode version 9.6.15 (release_9.6.15 @ /usr/share/emacs/29.4/lisp/org/)
Mark set

$ emacs -Q -batch -eval "(progn (require 'package) (package-initialize)
(package-refresh-contents) (package-upgrade 'org))"

Importing package-keyring.gpg...
Importing package-keyring.gpg...done
Contacting host: elpa.gnu.org:443
Contacting host: elpa.gnu.org:443
Package refresh done
Contacting host: elpa.nongnu.org:443
Contacting host: elpa.nongnu.org:443
Package refresh done

Error: wrong-type-argument (package-desc nil)
  mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode
  0x1a9410ba93aef0d9>)) debug-early-backtrace() debug-early(error
  (wrong-type-argument package-desc nil)) package-upgrade(org) (progn
  (require 'package) (package-initialize) (package-refresh-contents)
  (package-upgrade 'org)) command-line-1(("-eval" "(progn (require
  'package) (package-initialize) (package-refresh-contents)
  (package-upgrade 'org))")) command-line() normal-top-level()
Wrong type argument: package-desc, nil

* Fedora 38

Linux fedora 6.8.9-100.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2
18:50:49 UTC 2024 x86_64 GNU/Linux

GNU Emacs 29.3 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.41,
cairo version 1.17.8) of 2024-03-25

Org mode version 9.6.15 (release_9.6.15 @ /usr/share/emacs/29.3/lisp/org/)

$ emacs -Q -batch -eval "(progn (require 'package) (package-initialize)
(package-refresh-contents) (package-upgrade 'org))"

Importing package-keyring.gpg...
Importing package-keyring.gpg...done
Contacting host: elpa.gnu.org:443
Contacting host: elpa.gnu.org:443
Package refresh done
Contacting host: elpa.nongnu.org:443
Package refresh done

Error: wrong-type-argument (package-desc nil)
  mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode 0x1880ef4263aef0ea>))
  debug-early-backtrace()
  debug-early(error (wrong-type-argument package-desc nil))
  package-upgrade(org)
  (progn (require 'package) (package-initialize) (package-refresh-contents) (package-upgrade 'org))
  command-line-1(("-eval" "(progn (require 'package) (package-initialize) (package-refresh-contents) (package-upgrade 'org))"))
  command-line()
  normal-top-level()
Wrong type argument: package-desc, nil


* Another Fedora 38

Linux fruc.u-strasbg.fr 6.5.6-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Fri
Oct 6 19:02:35 UTC 2023 x86_64 GNU/Linux

GNU Emacs 28.3 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.38,
cairo version 1.17.8) of 2023-09-24

Org mode version 9.5.5 (release_9.5.5 @ /usr/share/emacs/28.3/lisp/org/)

$ emacs -Q -batch -eval "(progn (require 'package) (package-initialize)
(package-refresh-contents) (package-upgrade 'org))"

Importing package-keyring.gpg...
Importing package-keyring.gpg...done
Contacting host: elpa.gnu.org:443
Contacting host: elpa.gnu.org:443
Failed to download ‘gnu’ archive.
Contacting host: elpa.nongnu.org:443
Package refresh done
Failed to download ‘nongnu’ archive.
Debugger entered--Lisp error: (void-function package-upgrade)
  (package-upgrade 'org)
  (progn (require 'package) (package-initialize) (package-refresh-contents) (package-upgrade 'org))
  command-line-1(("-eval" "(progn (require 'package) (package-initialize) (pa..."))
  command-line()
  normal-top-level()

* Fedora 34

Linux frac 5.17.12-100.fc34.x86_64 #1 SMP PREEMPT Mon May 30 17:47:02 UTC
2022 x86_64 x86_64 x86_64 GNU/Linux

GNU Emacs 27.2 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.30,
cairo version 1.17.4) of 2021-08-07

Org mode version 9.4.4 (release_9.4.4 @ /usr/share/emacs/27.2/lisp/org/)

$ emacs -Q -batch -eval "(progn (require 'package) (package-initialize)
(package-refresh-contents) (package-upgrade 'org))"

Importing package-keyring.gpg...
Importing package-keyring.gpg...done
Contacting host: elpa.gnu.org:443
Contacting host: elpa.gnu.org:443
Package refresh done

Symbol’s function definition is void: package-upgrade

* Debian

Linux petrelvm-lin.eost.unistra.fr 6.1.0-22-amd64 #1 SMP PREEMPT_DYNAMIC
Debian 6.1.94-1 (2024-06-21) x86_64 GNU/Linux

GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo
version 1.16.0) of 2024-06-25, modified by Debian

Org mode version 9.5.5 (release_9.5.5 @ /usr/share/emacs/28.2/lisp/org/)

$ emacs -Q -batch -eval "(progn (require 'package) (package-initialize)
(package-refresh-contents) (package-upgrade 'org))"

Importing package-keyring.gpg...
Importing package-keyring.gpg...done
Contacting host: elpa.gnu.org:443
Contacting host: elpa.gnu.org:443
Contacting host: elpa.nongnu.org:443
Contacting host: elpa.nongnu.org:443
Package refresh done
Debugger entered--Lisp error: (void-function package-upgrade)
  (package-upgrade 'org)
  (progn (require 'package) (package-initialize) (package-refresh-contents) (package-upgrade 'org))
  command-line-1(("-eval" "(progn (require 'package) (package-initialize) (pa..."))
  command-line()
  normal-top-level()

* Ubuntu

Linux loreen-tablet 6.8.0-45-generic #45~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC
Wed Sep 11 15:25:05 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo
version 1.16.0) of 2022-05-31

Org mode version 9.5.2 (release_9.5.2-25-gaf6f12 @
/usr/share/emacs/28.1/lisp/org/)

$ emacs -Q -batch -eval "(progn (require 'package) (package-initialize)
(package-refresh-contents) (package-upgrade 'org))"

Importing package-keyring.gpg...
Importing package-keyring.gpg...done
Contacting host: elpa.gnu.org:443
Contacting host: elpa.gnu.org:443
Package refresh done
Contacting host: elpa.nongnu.org:443
Package refresh done

Error: wrong-type-argument (package-desc nil)
  mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode 0x9d980ba93aef0ed>))
  debug-early-backtrace()
  debug-early(error (wrong-type-argument package-desc nil))
  package-upgrade(org)
  (progn (require 'package) (package-initialize) (package-refresh-contents) (package-upgrade 'org))
  command-line-1(("-eval" "(progn (require 'package) (package-initialize) (package-refresh-contents) (package-upgrade 'org))"))
  command-line()
  normal-top-level()
Wrong type argument: package-desc, nil

-- 
EOST (École et Observatoire des Sciences de la Terre) 
ITE (Institut Terre & Environnement) | alain.cochard@unistra.fr
5 rue René Descartes   [bureau 110]  | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France     | [ slot available for rent ]



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

end of thread, other threads:[~2024-11-23 16:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-07  6:19 Patch to add a new org-archive hook and context info type John Wiegley
2024-11-23 16:45 ` Problem installing Org using the Emacs packaging system Alain.Cochard

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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).