[ESS-bugs] ess-mode 5.3.4; Words of praise, suggestions
Markus Triska
markus.triska at gmx.at
Mon Feb 12 17:11:19 CET 2007
Hi ESS-Team,
first of all, thank you so much for ESS, it makes my work much easier.
Second, I recommend the following ess-write-to-dribble-buffer:
(defun ess-write-to-dribble-buffer (text)
"Write TEXT to dribble buffer."
(unless (buffer-live-p ess-dribble-buffer)
;; ESS dribble buffer must be re-created.
(setq ess-dribble-buffer (get-buffer-create "*ESS*")))
(let (deactivate-mark)
(with-current-buffer ess-dribble-buffer
(goto-char (point-max))
(insert text))))
The most important change is that deactivate-mark is set to nil, so
that the region, if active, isn't deactivated. Without this, in
transient-mark-mode in GNU Emacs, highlighting of the region is lost
when moving over chunks, and M-h (= mark-paragraph) on chunks doesn't
work as expected.
The with-current-buffer macro I use can help to replace many
"set-buffer, save-excursion" calls in other places as well.
The "(if (not ...))" is replaced by "unless". This and the "when"
construct can simplify a lot of code in noweb-mode.el, which uses many
"if" constructs with only one branch. For example, a patch simplifying
noweb-select-mode:
Index: noweb-mode.el
===================================================================
--- noweb-mode.el (revision 3696)
+++ noweb-mode.el (working copy)
@@ -1209,35 +1209,30 @@
(let ((this-chunk-index (noweb-find-chunk-index-buffer)))
;; Has the last change to the buffer taken us into a different
;; chunk ?
- (if (not (equal this-chunk-index noweb-last-chunk-index))
- (progn
- (setq noweb-last-chunk-index this-chunk-index)
- (if (noweb-in-code-chunk)
- ;; Inside a code chunk
- (progn
- ;; Find out which code mode to use
- (noweb-set-chunk-code-mode)
- ;; If we aren't already using it, use it.
- (if (not (equal major-mode noweb-code-mode))
- (progn
- (funcall noweb-code-mode)
- (run-hooks 'noweb-select-mode-hook)
- (run-hooks 'noweb-select-code-mode-hook))))
- ;; Inside a documentation chunk
- (progn
- (if (not (equal major-mode noweb-doc-mode))
- (progn
- (funcall noweb-doc-mode)))
- (if (not noweb-doc-mode-syntax-table)
- (progn
- (message "Setting up syntax table")
- (setq noweb-doc-mode-syntax-table
- (make-syntax-table (syntax-table)))
- (noweb-set-doc-syntax-table)))
- (set-syntax-table noweb-doc-mode-syntax-table)
- (run-hooks 'noweb-select-mode-hook)
- (run-hooks 'noweb-select-doc-mode-hook)))
- (run-hooks 'noweb-changed-chunk-hook)))))
+ (unless (equal this-chunk-index noweb-last-chunk-index)
+ (setq noweb-last-chunk-index this-chunk-index)
+ (if (noweb-in-code-chunk)
+ ;; Inside a code chunk
+ (progn
+ ;; Find out which code mode to use
+ (noweb-set-chunk-code-mode)
+ ;; If we aren't already using it, use it.
+ (unless (equal major-mode noweb-code-mode)
+ (funcall noweb-code-mode)
+ (run-hooks 'noweb-select-mode-hook)
+ (run-hooks 'noweb-select-code-mode-hook)))
+ ;; Inside a documentation chunk
+ (unless (equal major-mode noweb-doc-mode)
+ (funcall noweb-doc-mode))
+ (unless noweb-doc-mode-syntax-table
+ (message "Setting up syntax table")
+ (setq noweb-doc-mode-syntax-table
+ (make-syntax-table (syntax-table)))
+ (noweb-set-doc-syntax-table))
+ (set-syntax-table noweb-doc-mode-syntax-table)
+ (run-hooks 'noweb-select-mode-hook)
+ (run-hooks 'noweb-select-doc-mode-hook))
+ (run-hooks 'noweb-changed-chunk-hook)))))
(defvar noweb-doc-mode noweb-default-doc-mode
"Default major mode for editing noweb documentation chunks.
All the best,
Markus Triska
More information about the ESS-bugs
mailing list