1

I want to use the package org-fstree (MELPA Link).

But in a file when I press C-c C-c at

#+BEGIN_FSTREE: ~/ 

I get the following error:

Symbol's function definition is void: reduce 

I am not sure if I installed the package correctly (this is the first time I am using MELPA). So here is all the information that I feel may be relevant:

I added the MELPA repository by adding the following to my ~/.emacs:

(when (>= emacs-major-version 24) (require 'package) (add-to-list 'package-archives ;; '("melpa" . "http://stable.melpa.org/packages/") ; many packages won't show if using stable '("melpa" . "http://melpa.milkbox.net/packages/") t)) 

Then I restarted Emacs. I pressed M-x list-packages and pressed i at org-fstree to mark it for installation and pressed x to complete the installation.

I got the following warnings:

In org-fstree-extract-path-from-headline: org-fstree.el:271:21:Warning: reference to free variable `org-fstree-heading-regexp' In end of data: org-fstree.el:311:1:Warning: the following functions are not known to be defined: reduce, org-columns-quit 

Then I added the following lines to my ~/.emacs:

;; org-fstree (add-to-list 'load-path "~/.emacs.d/elpa/org-fstree-20090723.819/") (require 'org-fstree) 

I got the above mentioned error after these steps.

Please advice me on what to do?

5
  • That package is very old. I think it would never make it into melpa nowadays. Try replacing reduce with cl-reduce in org-fstree.el. Furthermore, you should not need anything directly related to that package in your init file. Better add the comment line ;;;###autoload before the two hooks at the end of the library and before the definitions of the hooked functions org-fstree-show-entry-maybe and org-fstree-apply-maybe. Byte-compile the library afterwards. Commented Feb 25, 2018 at 23:09
  • I notified the melpa maintainers about the problem: github.com/melpa/melpa/issues/5334 Commented Feb 25, 2018 at 23:31
  • 1
    Note that adding those autoload cookies to the source isn't going to do anything unless the modified library is package-install'd (or equivalent). Commented Feb 26, 2018 at 2:55
  • 1
    @phils (package-generate-autoloads "org-fstree" (current-directory)) called from within org-fstree.el (i.e., with default-directory set to the package directory) should do. Commented Feb 26, 2018 at 21:56
  • I am sorry for the late response. Thanks @Tobias: I think I understand the problem now. However I don't understand: 1. What will comment ;;;###autoload do? 2. How should one byte-compile the library? 3. The point that @phils raised - what does that mean? 4. How does your comment to @phils solve the above problem? And thanks for raising the issue on github. Commented Feb 27, 2018 at 11:42

2 Answers 2

1

The package org-fstree is very old. The correction code below fixes several problems in the elisp file org-fstree.el of the package. It also prepares the package for autoload. That means that the hooks and functions that work as entry points of the package are marked as auto-loaded. The package is only loaded on demand when one of those is really called. All fixed problems are listed as comments in the correction code.

After installation of org-fstree-20090723.819 you can copy-paste the correction code into your *scratch* buffer place point somewhere in the code and call eval-defun which is bound to C-M-x.

(with-current-file "~/.emacs.d/elpa/org-fstree-20090723.819/org-fstree.el" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 1: Add ;;;###autoload at hooks and corresponding functions (goto-char (point-min)) (let ((m (make-marker))) (while (progn (set-marker m (search-forward "(add-hook" nil t)) (marker-position m)) (forward-line 0) (unless (looking-back ";;;###autoload\n") (insert ";;;###autoload\n")) (let* ((form (read (current-buffer))) (fun (nth 1 ;; function in (quote function) (nth 2 form)))) ;; (quote function) in (add-hook (quote hook) (quote function)) (find-function fun) (unless (looking-back ";;;###autoload\n") (insert ";;;###autoload\n")) (goto-char m)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 2: replace `reduce' with `cl-reduce' to autoload the required cl package (goto-char (point-min)) (while (re-search-forward "\\_<reduce\\_>" nil t) (replace-match "cl-reduce")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 3: add `org-colview' required for the used function `org-columns-quit': (goto-char (point-min)) (re-search-forward "^;; *Code:") (unless (looking-at "\n(require 'org-colview)") (insert "\n(require 'org-colview) ; needed for `org-columns-quit'")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 4: Correct order of "defun org-fstree-extract-path-from-headline" and ;; "defconst org-fstree-heading-regexp". (goto-char (point-min)) (let ((pos-defun (re-search-forward "(defun *org-fstree-extract-path-from-headline" nil t)) (pos-defvar (re-search-forward "(defconst *org-fstree-heading-regexp" nil t)) (pos-make-local (re-search-forward "make-variable-buffer-local *'org-fstree-heading-regexp" nil t))) (when (and pos-defun pos-defvar pos-make-local) (transpose-regions (progn (goto-char pos-defun) (forward-line 0) (point)) (progn (forward-sexp) (point)) (progn (goto-char pos-defvar) (forward-line 0) (point)) (progn (goto-char pos-make-local) (up-list) (point))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 5: Installation tasks (write-region nil nil (buffer-file-name)) (package-generate-autoloads "org-fstree" default-directory) (cl-assert (byte-compile-file (buffer-file-name)))) 

Note that there are some more minor problems reported by byte-compile-file for the corrected version of org-fstree. Nevertheless, the corrected version of org-fstree is running in emacs-version 25.3.2 with org-version 9.1.6 and does more or less what it is supposed to do (as far as I see).

0

If anyone gets here because they read Emacs' Wiki: Eshell Prompt and wanted to try their "Summarising the path" prompt but got the same error as this question, you can fix it by replacing reduce with cl-reduce per @Tobias' comment. But why fix when you can copy?

 (defun shortened-path (path max-len) "Return a modified version of `path', replacing some components with single characters starting from the left to try and get the path down to `max-len'" (let* ((components (split-string (abbreviate-file-name path) "/")) (len (+ (1- (length components)) (cl-reduce '+ components :key 'length))) (str "")) (while (and (> len max-len) (cdr components)) (setq str (concat str (if (= 0 (length (car components))) "/" (string (elt (car components) 0) ?/))) len (- len (1- (length (car components)))) components (cdr components))) (concat str (cl-reduce (lambda (a b) (concat a "/" b)) components)))) (defun rjs-eshell-prompt-function () (concat (shortened-path (eshell/pwd) 40) (if (= (user-uid) 0) " # " " $ "))) (setq eshell-prompt-function 'rjs-eshell-prompt-function) 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.