Re: Issues with japanese support
Masayuki Ataka <[email protected]>
| Newsgroups | gmane.emacs.auc-tex |
|---|---|
| Message-ID | <[email protected]> |
From: Ralf Angeli <[email protected]> Subject: Re: Issues with japanese support Date: Wed, 16 Feb 2005 10:28:48 +0100 > * Masayuki Ataka (2005-02-16) writes: > > > Maybe we need a new variable for Emacs21 and XEmacs. > > (defvar LaTeX-word-across-newline > > (if (boundp 'word-across-newline) word-across-newline "\\c|")) > > Although I have a `re-search-forward' phobia since we had these > performance problems related to filling, I think this would be a > pragmatic solution. At least there is not much difference in > execution time between the following two implementations (work only > with Emacs): > Let me name the code for convenience. fill-cvs-emacs: > (with-temp-buffer > (dotimes (i 100000) > (insert "\n\n")) > (goto-char (point-min)) > (abs (- (prog1 (float-time (current-time)) > (while (search-forward "\n" nil t) > (let ((prev (char-before (match-beginning 0))) > (next (following-char))) > (when (or (aref (char-category-set next) ?|) > (aref (char-category-set prev) ?|)) > (delete-char -1))))) > (float-time (current-time))))) fill-replace: > (with-temp-buffer > (dotimes (i 100000) > (insert "\n\n")) > (goto-char (point-min)) > (abs (- (prog1 (float-time (current-time)) > (while (re-search-forward "\\(\\c|\\)\n\\(\\c|\\)" nil t) > (replace-match "\\1\\2"))) > (float-time (current-time))))) And new code. fill-skip-char: (with-temp-buffer (dotimes (i 100000) (insert "\n\n")) (goto-char (point-min)) (abs (- (prog1 (float-time (current-time)) (while (re-search-forward "\\(\\c|\\)\n\\(\\c|\\)" nil t) (skip-chars-backward "^\n") (delete-char -1))) (float-time (current-time))))) In my computer and Emacs-21.4, `fill-re-search' is faster than `fill-cvs-emacs': (fill-cvs-emacs) 2.065401077270508 (fill-replace) 1.1991240978240967 (fill-skip-char) 0.9685571193695068 But, after byte-compile, `fill-cvs-emacs' becomes much faster: (fill-cvs-emacs) 0.5713150501251221 (fill-replace) 1.1394240856170654 (fill-skip-char) 0.9528110027313232 Yes. `re-search-forward' has a performance problem. `fill-cvs-emacs' is the fastest. `fill-skip-char' is better than `re-search-forward'. So, our new function will be... (defun LaTeX-fill-delete-newlines (from to justify nosqueeze squeeze-after) ;; COMPATIBILITY for Emacs <= 22.1 (if (fboundp 'fill-delete-newlines) (fill-delete-newlines from to justify nosqueeze squeeze-after) (if (featurep 'xemacs) (when (featurep 'mule) (goto-char from) (while (re-search-forward "\\(\\cj\\)\n\\(\\cj\\)" to t) (skip-chars-backward "^\n") (delete-char -1))) ;; This else-sentence was copied from the function `fill-delete-newlines' ;; in `fill.el' (CVS Emacs, 2005-02-17). (while (search-forward "\n" nil t) (let ((prev (char-before (match-beginning 0))) (next (following-char))) (when (or (aref (char-category-set next) ?|) (aref (char-category-set prev) ?|)) (delete-char -1))))) (snip) (snip) (snip) ;; Is comment appropriate? If no objection, I'll commit this tonight. > > What I don't like is the name `LaTeX-word-across-newline'. What about > something matching better its value/purpose, like > `LaTeX-nospace-between-words-char-regexp'. Argh, I created a > monster. A little bit shorter: `LaTeX-nospace-between-char-regexp'. > Any better suggestions? I like it. --- email: [email protected] Name:: Masayuki Ataka // (Japan)