[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dict-tree 26f5dd3 011/154: Work around byte-compilation
From: |
Stefan Monnier |
Subject: |
[elpa] externals/dict-tree 26f5dd3 011/154: Work around byte-compilation and goto-line bugs. |
Date: |
Mon, 14 Dec 2020 12:21:34 -0500 (EST) |
branch: externals/dict-tree
commit 26f5dd38cae830c07ea3558f0b5d60a1bd8ef1ba
Author: Toby Cubitt <toby-predictive@dr-qubit.org>
Commit: tsc25 <toby-predictive@dr-qubit.org>
Work around byte-compilation and goto-line bugs.
---
dict-tree.el | 46 +++++++++++++++++++++++++++++++++++++---------
1 file changed, 37 insertions(+), 9 deletions(-)
diff --git a/dict-tree.el b/dict-tree.el
index b6793a7..be8b4b3 100644
--- a/dict-tree.el
+++ b/dict-tree.el
@@ -5,7 +5,7 @@
;; Copyright (C) 2004-2008 Toby Cubitt
;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
-;; Version: 0.11
+;; Version: 0.11.1
;; Keywords: dictionary, tree
;; URL: http://www.dr-qubit.org/emacs.php
@@ -54,6 +54,11 @@
;;; Change log:
;;
+;; Version 0.11.1
+;; * set and restore value of `byte-compile-disable-print-circle' instead of
+;; let-binding it, to avoid warnings when compiling
+;; * added `dictree-goto-line' macro to work around `goto-line' bug
+;;
;; Version 0.11
;; * modified `dictree-write' so that, by default, both compiled and uncompiled
;; versions of dictionaries are created when writing dictionaries to file
@@ -164,6 +169,7 @@
(provide 'dict-tree)
(require 'tstree)
+(require 'bytecomp)
@@ -473,6 +479,24 @@ sorted before the second."
+;;; ================================================================
+;;; Miscelaneous macros
+
+;; `goto-line' without messing around with mark and messages
+;; Note: this is a bug in simple.el; there clearly can be a need for
+;; non-interactive calls to goto-line from Lisp code, and
+;; there's no warning about doing this. Yet goto-line *always*
+;; calls push-mark, which usually *shouldn't* be invoked by
+;; Lisp programs, as its docstring warns.
+(defmacro dictree-goto-line (line)
+ "Goto line LINE, counting from line 1 at beginning of buffer."
+ `(progn
+ (goto-char 1)
+ (if (eq selective-display t)
+ (re-search-forward "[\n\C-m]" nil 'end (1- ,line))
+ (forward-line (1- ,line)))))
+
+
;;; ================================================================
;;; The public functions which operate on dictionaries
@@ -1512,7 +1536,7 @@ dictionary structure."
(midpt (+ (/ lines 2) (mod lines 2)))
entry)
;; insert the median key and set the dictionary's modified flag
- (goto-line midpt)
+ (dictree-goto-line midpt)
(when (setq entry (dictree-read-line))
(dictree-insert dict (car entry) (nth 1 entry))
(dictree-set-meta-data dict (car entry) (nth 2 entry)))
@@ -1521,14 +1545,14 @@ dictionary structure."
;; insert keys successively further away from the median in both
;; directions
(dotimes (i (1- midpt))
- (goto-line (+ midpt i 1))
+ (dictree-goto-line (+ midpt i 1))
(when (setq entry (dictree-read-line))
(dictree-insert dict (car entry) (nth 1 entry))
(dictree-set-meta-data dict (car entry) (nth 2 entry)))
(when (= 49 (mod i 50))
(message "Inserting keys in %s...(%d of %d)"
(dictree--name dict) (+ (* 2 i) 2) lines))
- (goto-line (- midpt i 1))
+ (dictree-goto-line (- midpt i 1))
(when (setq entry (dictree-read-line))
(dictree-insert dict (car entry) (nth 1 entry))
(dictree-set-meta-data dict (car entry) (nth 2 entry))))
@@ -1536,7 +1560,7 @@ dictionary structure."
;; if file contains an even number of keys, we still have to add
;; the last one
(when (= 0 (mod lines 2))
- (goto-line lines)
+ (dictree-goto-line lines)
(when (setq entry (dictree-read-line))
(dictree-insert dict (car entry) (nth 1 entry))
(dictree-set-meta-data dict (car entry) (nth 2 entry))))
@@ -1692,7 +1716,7 @@ and OVERWRITE is the prefix argument."
(y-or-n-p
(format "File %s already exists. Overwrite? "
(concat filename ".el(c)"))))
- (condition-case nil
+; (condition-case nil
(progn
;; move the uncompiled version to its final destination
(unless (eq compilation 'compiled)
@@ -1701,12 +1725,16 @@ and OVERWRITE is the prefix argument."
;; destination
(unless (eq compilation 'uncompiled)
(if (save-window-excursion
- (let ((byte-compile-disable-print-circle t))
- (byte-compile-file tmpfile)))
+ (let ((restore byte-compile-disable-print-circle)
+ err)
+ (setq byte-compile-disable-print-circle t)
+ (setq err (byte-compile-file tmpfile))
+ (setq byte-compile-disable-print-circle restore)
+ err))
(rename-file (concat tmpfile ".elc")
(concat filename ".elc") t)
(error))))
- (error (error "Error saving %s. Dictionary not saved" dictname)))
+; (error (error "Error saving %s. Dictionary not saved" dictname)))
;; if writing to a different name, unload dictionary under old name and
;; reload it under new one
- [elpa] externals/dict-tree 3a18a06 042/154: Modified dictree-populate-from-file to read linearly by default,, (continued)
- [elpa] externals/dict-tree 3a18a06 042/154: Modified dictree-populate-from-file to read linearly by default,, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree ca2c562 050/154: Bug-fix to dictree-complete, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree e1a9f19 051/154: Documentation updates related to wildcard searches and predictive features that make use of them, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree bf4002d 063/154: Bug-fixes to dictree--write-dict-code; allow loading non-matching filenames in read-dict, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 6d9921e 067/154: Updated docstrings for regexp-related functions and others., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree d88b867 002/154: Version 0.10.3 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 7b52ebd 005/154: Version 0.13.1 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree ac40f3c 004/154: Version 0.12.2 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 2bca928 003/154: Version 0.12 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 3ecd763 006/154: Added minor miscellaneous new features, mostly to predictive.el., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 26f5dd3 011/154: Work around byte-compilation and goto-line bugs.,
Stefan Monnier <=
- [elpa] externals/dict-tree 7562023 012/154: Make use of :family attribute of completion-tooltip-face., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree f9bf379 013/154: Complete re-write of dict-tree.el, based on new trie.el., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 329110b 018/154: Fixed bug in unranked dictree-complete., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree baa4931 028/154: Doesn't quite work - revert to breaking setf abstraction, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 5834dac 036/154: Replaced bare avl-trees, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 673fd2a 029/154: Abstract away the setcar used to set the data component of a cell, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 2700e21 035/154: Don't compile wrapped functions explicitly, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 70f99ee 037/154: Make certain dictionary commands (mostly saving and loading) interactive again., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 35346a4 041/154: Bug-fix in dictree--write-dict-code, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 608fcd4 049/154: Bug-fix to dictree--write-dict-code, Stefan Monnier, 2020/12/14