From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id YFKcBlob0mVVHQEAqHPOHw:P1 (envelope-from ) for ; Sun, 18 Feb 2024 15:59:38 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id YFKcBlob0mVVHQEAqHPOHw (envelope-from ) for ; Sun, 18 Feb 2024 15:59:38 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=TfKVeh2a; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1708268378; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=TQ9j3cTM1XZkDVpmxkQUxJr3+nqSsk0MxLn9TEj6cN4=; b=J9uufOSXTzZpFipk7Ii9Y0EZlTPYsS1mpD3TimIm6wW65CKaY37rVkYnorzaQ4+8Rjz84g x5wPdYOOM3sH/tdK1zq7b2HDcdudmvOIF/BtoGug5atxh5wnCK3WEAqAthtnKjQe1nyEDP ZAASgvSO5tkd5yvBd4oxGEI8KSe6l2qBtfp7JP0DYR7YbOitJXZTkP43u9PJCRfEyJ62lc bl1hA2gVQ0J6Ox94Y/SYJr1wuV1VPcVmH3uVRCKwLJwRlIpzPzJUJxf70E5aOHA9aZMf1X I9l5nBl24TWHoZ3YD9RYbJwA+gjFErJ7lbhCLE7mXyBv4P5LE6lBTWyfSDpsGw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=TfKVeh2a; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1708268378; a=rsa-sha256; cv=none; b=qdZ5eUJ4Wz44ZWboDMw3SEDvLxkotM3cfcrse1kJmmQppoJuPRW+ZAKsLpaqXf2JECtQjR zGGq1AMZ5sR4Q1dytI3yxGkou7WN+sRE6zbSoeHAy9tKDM6vzaVFIO6Hkg6LWXwCdU8ajr 4ZmCVc9nxp4kVJZ5Mw9AFNIyjtMK1SK3h0u4DRvlmtMBG/LReu6UAcUH38fn+OBRf5xVCp kwuPUPjWJviynTI/lN1rswohpvaMcQ3wQVMkpSJLG0FGy4RlQo6PxIZeq+2I+jWIbled0m pvxw95cgSh0+N6KShC2g8FTMO5h7v978wwdDs6OOocPLLVTaRLKBDkCEOK+yHg== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 791922293F for ; Sun, 18 Feb 2024 15:59:37 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rbicy-000628-In; Sun, 18 Feb 2024 09:58:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rbicw-00061V-VR for emacs-orgmode@gnu.org; Sun, 18 Feb 2024 09:58:46 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rbicu-0002TO-7a for emacs-orgmode@gnu.org; Sun, 18 Feb 2024 09:58:46 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id CE057240028 for ; Sun, 18 Feb 2024 15:58:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1708268321; bh=7sCofPvVOxrSA23YwWM/sBDvFffsXCb0Oe6M9N5292g=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=TfKVeh2aJCZJ19NiYoXzK/0evYlVDNt/BOgrmdzx/tkFrcn/usxqtZP0mWhw1yinI Qn0qLZ5bK4Qu5avDXiVtUsaLb61LRhWUEeJSrECx+obItwlmoW6rpf8Ye9Pc9WQXxY 0+h1SLXGSCB4ERQQM5AyJpbCZCTyaBpHtCvQrQCk1DjEks3NmwJay/rzmE4GAjuDCL +iKNy/MQPKrypsF3Ac8CwMniXqKIGtjd1L2wjODulHOVt2BDh+XS/0ws3lyBc/rZ4Z itpKsf85DNOe05U/5u67Zg58fUlpqRLApZhuX02t5rM9CGRbaOGMLIPB/hlgDYur66 Db1CgDrUEg9Bg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Td81s0stkz6tw7; Sun, 18 Feb 2024 15:58:40 +0100 (CET) From: Ihor Radchenko To: Uwe Brauer Cc: Uwe Brauer via Subject: Re: old pkg fstree stopped working In-Reply-To: <87zfw22ke9.fsf@mat.ucm.es> References: <87zfw22ke9.fsf@mat.ucm.es> Date: Sun, 18 Feb 2024 16:58:56 +0000 Message-ID: <87msrxr9nz.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -7.83 X-Spam-Score: -7.83 X-Migadu-Queue-Id: 791922293F X-TUID: FDSPuyIGZWVx --=-=-= Content-Type: text/plain Uwe Brauer writes: > I using a pretty old package called org-fstree > > > All it requires, after loading it of course, is to have in an org file the lines > --8<---------------cut here---------------start------------->8--- > > #+begin_fstree: /home/oub/ALLES/HGs/HG-CVS-Formular :non-recursive t > > #+end_fstree: > --8<---------------cut here---------------end--------------->8--- > ... > > However not any longer when I now hit C-c C-c org tells me: > can't do anything useful here. > > > I updated org-mode recently could that be the reason? I have changed my emacs version lately. Is you see "can't do anything useful here", it most likely means that you did not load the package. http://www.burtzlaff.de/org-fstree/org-fstree.el has (add-hook 'org-ctrl-c-ctrl-c-hook 'org-fstree-apply-maybe) which should make things work, unless you somehow do not load the package. When I tried on my side, things work, except that I had to change "reduce" calls to "cl-reduce" - "reduce" name alias has been deprecated and removed Emacs 27. I am attaching the modified working version of the package. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=org-fstree.el ;;; org-fstree.el --- include a filesystem subtree into an org file ;; Copyright 2009 Andreas Burtzlaff ;; ;; Author: Andreas Burtzlaff < andreas at burtz[REMOVE]laff dot de > ;; Version: 0.4 ;; Keywords: org-mode filesystem tree ;; X-URL: ;; ;; This file is not part of GNU Emacs. ;; ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation; either version 2, or (at ;; your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, write to the Free Software ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Commentary: ;; org-fstree inserts the filesystem subtree for a given directory. ;; Each file/directory is formatted as a headline, provides links back ;; to all headlines that are associated with it (by containing links to the file) ;; and is assigned their tags. ;; ;; Installation: ;; - put this file into your load-path ;; - insert "(require 'org-fstree)" into ~/.emacs ;; ;; Usage: ;; - enter a line containing "#+BEGIN_FSTREE: " into an org buffer, ;; where is the directory, that is to be inserted. ;; - while the cursor is in the line mentioned, press "C-c C-c" ;; ;; Options: ;; Specify options in the form: ;; "#+BEGIN_FSTREE: : : ... ;; Options are: ;; - :non-recursive t , to suppress recursion into directories ;; - :exclude-regexp-name , exclude file/directory names matching either ;; of the given regexp expressions ;; Examples: ;; :exclude-regexp-name (".*\\.pdf$" ".*\\.zip$"), excludes files/directories ending with either ".pdf" or ".zip" ;; :exclude-regexp-name ("^\\.git$") , excludes files/directories named ".git" ;; ;; - :exclude-regexp-fullpath , same as :exclude-regexp-name but matches absolute path to file/directory ;; - :relative-links t , generates relative instead of absolute links ;; - :show-only-matches t , only files that are being linked to show up ;; - :dynamic-update t , [EXPERIMENTAL] dynamically update a subtree on visibility cycling. ;; - :links-as-properties t, sets the links as properties Link1, Link2,... for use in column view [Does not work with dynamic-update!] ;; ;; Limitations and warnings: ;; ;; - when triggering an update (by pressing "C-c C-c" while in the line mentioned above) ;; the COMPLETE REGION BETWEEN "#+BEGIN_FSTREE" AND "#+END_FSTREE" IS REPLACED. ;; - speed ;; ;; Code: (provide 'org-fstree) (require 'org) (defun org-fstree-generate (dir level options) (interactive) ;; (message "org-fstree-generate") ;; DEBUG (if (file-directory-p dir) (let ( (non-recursive (plist-get options :non-recursive)) (exclude-regexp-name-list (plist-get options :exclude-regexp-name)) (exclude-regexp-fullpath-list (plist-get options :exclude-regexp-fullpath)) (links-as-properties (plist-get options :links-as-properties)) (dynamic-update (plist-get options :dynamic-update)) (fullFileNames (directory-files dir 1 nil nil) ) (fileNames (directory-files dir nil nil nil) ) fileName fullFileName currentHeadline orgHeadlineInfo curTags curPos (linksList nil) (retString "") ) (while fileNames (setq fullFileName (car fullFileNames)) (setq fullFileNames (cdr fullFileNames)) (setq fileName (car fileNames)) (setq fileNames (cdr fileNames)) (setq linksList nil) (setq curTags nil) (cond ((member fileName '("." ".."))) ;; the following two lines are really ugly. I'll be glad if someone with more lisp experience tidies this up. ((cl-reduce (function (lambda (a b) (or a b))) (mapcar (function (lambda (regexp) (not (string= fullFileName (replace-regexp-in-string regexp "" fullFileName) )) )) exclude-regexp-fullpath-list ) :initial-value nil)) ((cl-reduce (function (lambda (a b) (or a b))) (mapcar (function (lambda (regexp) (not (string= fileName (replace-regexp-in-string regexp "" fileName) )) )) exclude-regexp-name-list ) :initial-value nil)) (t (save-excursion ;; Search for links in current buffer (goto-char (point-min)) (setq curPos (point)) (while (re-search-forward org-bracket-link-regexp nil t) (let ((filenameInLink (match-string 1))) (cond ( (org-fstree-get-parameters-if-inside-fstree-block) (re-search-forward "#\\+END_FSTREE" nil t) ) ( (string= fullFileName (expand-file-name (replace-regexp-in-string "^file:" "" filenameInLink ) ":" ) ) (let ((p (point))) (cond ((org-before-first-heading-p)) (t ;; go to associated heading (org-back-to-heading t) (setq orgHeadlineInfo (org-heading-components)) (setq curTags (concat curTags (nth 5 orgHeadlineInfo) )) (setq currentHeadline (nth 4 orgHeadlineInfo)) ;; filter all links from headline, generate link to it and append to linksList (let ((cleanedHeadline (replace-regexp-in-string "\\[\\[.*\\]\\]" "" currentHeadline))) (setq linksList (cons (concat "[[*" cleanedHeadline "]" (cond ( (plist-get options :show-only-matches) "[" (replace-regexp-in-string (regexp-quote fullFileName) "" cleanedHeadline) "]" ) ) "]") linksList) ) ) (goto-char p) ))))))) (cond ((or (not (plist-get options :show-only-matches)) (not (null linksList))) ;; construct headline for current file/directory (let* ((tagString (cond ((not (null curTags)) (concat " " (replace-regexp-in-string "::" ":" curTags)) ) )) (linkCount 0) (headingString (format "\n%s |%s| [[file:%s][%s]] " (make-string level ?*) (if (file-directory-p fullFileName) "D" " ") (if (plist-get options :relative-links) (file-relative-name fullFileName) fullFileName) fileName))) (cond (links-as-properties (setq retString (concat retString headingString (if tagString tagString "") (if (not (null linksList)) (concat "\n :PROPERTIES:\n " (mapconcat (function (lambda (string) (setq linkCount (1+ linkCount)) (concat ":Link" (number-to-string linkCount) ":" string ))) linksList "\n") "\n :END:" ) )))) (t (setq retString (concat retString headingString (make-string (max 0 (- 100 (length headingString))) ? ) (if linksList (concat "{ " (mapconcat 'identity linksList " | ") " }")) (if tagString tagString) )))) (if (and (not non-recursive) (not dynamic-update) (file-directory-p fullFileName) ) (setq retString (concat retString (org-fstree-generate fullFileName (1+ level) options) ) ) )))))))) retString) (message "%s is not a directory" dir))) (defun org-fstree-apply-maybe () (interactive) ;; (message "org-fstree-apply-maybe") (sit-for 1) ;; DEBUG (save-excursion (if (save-excursion (beginning-of-line 1) (looking-at "#\\+END_FSTREE")) (re-search-backward "#\\+BEGIN_FSTREE" nil t)) (cond ((save-excursion (beginning-of-line 1) (looking-at "#\\+BEGIN_FSTREE")) (let* ((params (org-fstree-gather-parameters)) (dir (plist-get params :dir)) (options (plist-get params :params)) level) ;; get current level; there is a BUG if "#+BEGIN_FSTREE" is inserted after the last headlines dots, that indicate its folded state. ;; (let ((p (point))) (save-excursion (cond ((org-before-first-heading-p) (setq level 1)) (t (org-back-to-heading) (setq level (+ (funcall outline-level) 1)) ;; (goto-char p) ))) (forward-line) (let ((beg (point))) (re-search-forward "#\\+END_FSTREE\\|#\\+BEGIN_FSTREE" nil t) (let ((generatedString (org-fstree-generate dir level options))) (cond ( (looking-back "#\\+END_FSTREE") (forward-line -1) (end-of-line 1) (delete-region beg (point) ) (insert (concat generatedString "\n"))) (t (goto-char beg) (insert (concat generatedString "\n\n#+END_FSTREE")))) ;; hide all subtrees (org-map-region (function (lambda () (hide-subtree))) beg (point)) ))) 1)))) (defun org-fstree-show-entry-maybe (state) (interactive) ;; (message "show-entry-maybe..") (sit-for 1) ;; DEBUG (let* ( (parameters (save-excursion (org-fstree-get-parameters-if-inside-fstree-block))) (options (plist-get parameters :params))) (cond ((and parameters (not (plist-get options :non-recursive)) (plist-get options :dynamic-update) ) ;; we are inside the FSTREE block and have to update ;; delete existing content (save-excursion (let ((end (save-excursion ;; go to the end of the subtree, specifically to the beginning of the next headline (org-end-of-subtree nil t) ;; got back on character, because editing heading lines in column mode is not possible. ;; this line is supposed to be either empty or an entry. (forward-char -1) (point) ))) (beginning-of-line 2) (if (looking-at " *:PROPERTIES:") (progn (re-search-forward ":END:" nil t) (forward-line 1))) (when (and (> (count-lines (point) end) 0) (< (point) end)) (delete-region (point) end) ) ) ) (cond ((eq state 'folded)) (t ;; insert new content (save-excursion (let ((beg (point)) end (level (1+ (funcall outline-level))) (dir (org-fstree-extract-path-from-headline)) (newOptions (plist-put (plist-get parameters :params) ':non-recursive 't))) (when (file-directory-p dir) ;;(when (plist-get options :links-as-properties) (forward-line 1)) (if (looking-at " *:PROPERTIES:") (progn (re-search-forward ":END" nil t) (forward-line 1))) (end-of-line 1) (when (plist-get options :links-as-parameters) (org-columns-quit)) (insert (org-fstree-generate dir level newOptions)) (when (plist-get options :links-as-parameters) (org-columns)) (setq end (point)) ;; hide all subtrees ;;(if (plist-get options :links-as-properties) ;;(progn ;; (org-map-region (function (lambda () (hide-subtree))) beg (point))) (org-end-of-subtree) (hide-subtree) )))) ))))) (defun org-fstree-extract-path-from-headline () ;; (interactive) ;;DEBUG (save-excursion (beginning-of-line 1) (if (looking-at org-fstree-heading-regexp) (match-string-no-properties 1)))) (defconst org-fstree-heading-regexp ".*\\[\\[file:\\(.*\\)\\]\\[.*\\]\\]" "Matches headline in org-fstree section.") (make-variable-buffer-local 'org-fstree-heading-regexp) (defun org-fstree-get-parameters-if-inside-fstree-block () (interactive) (and (save-excursion (re-search-forward "#\\+END_FSTREE" nil t) ) (save-excursion (re-search-backward "#\\+BEGIN_FSTREE" nil t) (org-fstree-gather-parameters)))) (defun org-fstree-gather-parameters () (save-excursion (let (rtn) (beginning-of-line 1) (if (looking-at "#\\+BEGIN_FSTREE[: \t][ \t]*\\([^ \t\r\n]+\\)\\( +.*\\)?") (let ((dir (org-no-properties (match-string 1))) (params (if (match-end 2) (read (concat "(" (match-string 2) ")"))))) (setq rtn (list :dir dir :params params) ) )) rtn) ) ) (defun org-fstree-get-current-outline-level () (save-excursion (cond ((org-before-first-heading-p) 1) (t (org-back-to-heading) (+ (funcall outline-level) 1))))) (add-hook 'org-ctrl-c-ctrl-c-hook 'org-fstree-apply-maybe) (add-hook 'org-pre-cycle-hook 'org-fstree-show-entry-maybe) --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--