views:

59

answers:

1

I want to be able to use the emacs folding mode provided by folding.el from http://www.emacswiki.org/emacs/FoldingMode

I put the following in my .emacs file:

(setq load-path (cons (concat (getenv "HOME") "/.emacs.d") load-path))
(load "folding")
(folding-mode-add-find-file-hook)
(folding-add-to-marks-list 'latex-mode   "%{"  "%}"  nil t)

Then, when I select a region and run

M-x folding-fold-region

I get the error

Wrong type argument: char-or-string-p, nil
+4  A: 

There are two problems :

  • you don't have to re-declare marks for latex-mode as this is already done in folder.el line 4411. Thus you should remove the line (folding-add-to-marks-list 'latex-mode "%{" "%}" nil t)

  • You get the error Wrong type argument: char-or-string-p, nil when the folder-mode is not enabled. Adding the line (folding-mode-add-find-file-hook) is not enough to open a file in folder-mode by default. To open in folder-mode, you should also place the folded-file local variable in the first line of the file you want to open, for example, in lisp :

;; -*- folded-file: t; -*-

With this local variable, and the (folding-mode-add-find-file-hook) command in your .emacs the folder-mode is enabled and you don't have problem anymore when calling folding-fold-region on a region.

Do a C-h f folding-mode-add-find-file-hook RET to have the explanation of this mechanism.

Jérôme Radix
Cool, thanks!!!
forefinger