aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2006-04-04 01:21:26 +0000
committerKenichi Handa2006-04-04 01:21:26 +0000
commit979a59c2bfba8a282f612501ce0dd8b429867bc9 (patch)
tree91eba99ca8aedbfc65fc3a7421d407eb178c014e
parent260a5020a4f8c1996061adc83dbedbcf9a58000a (diff)
downloademacs-979a59c2bfba8a282f612501ce0dd8b429867bc9.tar.gz
emacs-979a59c2bfba8a282f612501ce0dd8b429867bc9.zip
(sort-build-lists): Don't bind inhibit-field-text-motion
here. (sort-lines, sort-numeric-fields, sort-fields, sort-columns): Temporarily bind inhibit-field-text-motion to t.
-rw-r--r--lisp/sort.el63
1 files changed, 34 insertions, 29 deletions
diff --git a/lisp/sort.el b/lisp/sort.el
index c3d135f4c66..359067a4af3 100644
--- a/lisp/sort.el
+++ b/lisp/sort.el
@@ -121,9 +121,6 @@ it defaults to `<', otherwise it defaults to `string<'."
121(defun sort-build-lists (nextrecfun endrecfun startkeyfun endkeyfun) 121(defun sort-build-lists (nextrecfun endrecfun startkeyfun endkeyfun)
122 (let ((sort-lists ()) 122 (let ((sort-lists ())
123 (start-rec nil) 123 (start-rec nil)
124 ;; To avoid such functins as `end-of-line' being affected by
125 ;; fields.
126 (inhibit-field-text-motion t)
127 done key) 124 done key)
128 ;; Loop over sort records. 125 ;; Loop over sort records.
129 ;(goto-char (point-min)) -- it is the caller's responsibility to 126 ;(goto-char (point-min)) -- it is the caller's responsibility to
@@ -205,7 +202,9 @@ the sort order."
205 (save-restriction 202 (save-restriction
206 (narrow-to-region beg end) 203 (narrow-to-region beg end)
207 (goto-char (point-min)) 204 (goto-char (point-min))
208 (sort-subr reverse 'forward-line 'end-of-line)))) 205 (let ;; To make `end-of-line' and etc. to ignore fields.
206 ((inhibit-field-text-motion t))
207 (sort-subr reverse 'forward-line 'end-of-line)))))
209 208
210;;;###autoload 209;;;###autoload
211(defun sort-paragraphs (reverse beg end) 210(defun sort-paragraphs (reverse beg end)
@@ -271,25 +270,27 @@ With a negative arg, sorts by the ARGth field counted from the right.
271Called from a program, there are three arguments: 270Called from a program, there are three arguments:
272FIELD, BEG and END. BEG and END specify region to sort." 271FIELD, BEG and END. BEG and END specify region to sort."
273 (interactive "p\nr") 272 (interactive "p\nr")
274 (sort-fields-1 field beg end 273 (let ;; To make `end-of-line' and etc. to ignore fields.
275 (lambda () 274 ((inhibit-field-text-motion t))
276 (sort-skip-fields field) 275 (sort-fields-1 field beg end
277 (let* ((case-fold-search t) 276 (lambda ()
278 (base 277 (sort-skip-fields field)
279 (if (looking-at "\\(0x\\)[0-9a-f]\\|\\(0\\)[0-7]") 278 (let* ((case-fold-search t)
280 (cond ((match-beginning 1) 279 (base
281 (goto-char (match-end 1)) 280 (if (looking-at "\\(0x\\)[0-9a-f]\\|\\(0\\)[0-7]")
282 16) 281 (cond ((match-beginning 1)
283 ((match-beginning 2) 282 (goto-char (match-end 1))
284 (goto-char (match-end 2)) 283 16)
285 8) 284 ((match-beginning 2)
286 (t nil))))) 285 (goto-char (match-end 2))
287 (string-to-number (buffer-substring (point) 286 8)
288 (save-excursion 287 (t nil)))))
289 (forward-sexp 1) 288 (string-to-number (buffer-substring (point)
290 (point))) 289 (save-excursion
291 (or base sort-numeric-base)))) 290 (forward-sexp 1)
292 nil)) 291 (point)))
292 (or base sort-numeric-base))))
293 nil)))
293 294
294;;;;;###autoload 295;;;;;###autoload
295;;(defun sort-float-fields (field beg end) 296;;(defun sort-float-fields (field beg end)
@@ -322,11 +323,13 @@ FIELD, BEG and END. BEG and END specify region to sort.
322The variable `sort-fold-case' determines whether alphabetic case affects 323The variable `sort-fold-case' determines whether alphabetic case affects
323the sort order." 324the sort order."
324 (interactive "p\nr") 325 (interactive "p\nr")
325 (sort-fields-1 field beg end 326 (let ;; To make `end-of-line' and etc. to ignore fields.
326 (function (lambda () 327 ((inhibit-field-text-motion t))
327 (sort-skip-fields field) 328 (sort-fields-1 field beg end
328 nil)) 329 (function (lambda ()
329 (function (lambda () (skip-chars-forward "^ \t\n"))))) 330 (sort-skip-fields field)
331 nil))
332 (function (lambda () (skip-chars-forward "^ \t\n"))))))
330 333
331(defun sort-fields-1 (field beg end startkeyfun endkeyfun) 334(defun sort-fields-1 (field beg end startkeyfun endkeyfun)
332 (let ((tbl (syntax-table))) 335 (let ((tbl (syntax-table)))
@@ -471,7 +474,9 @@ it uses the `sort' utility program, which doesn't understand tabs.
471Use \\[untabify] to convert tabs to spaces before sorting." 474Use \\[untabify] to convert tabs to spaces before sorting."
472 (interactive "P\nr") 475 (interactive "P\nr")
473 (save-excursion 476 (save-excursion
474 (let (beg1 end1 col-beg1 col-end1 col-start col-end) 477 (let ;; To make `end-of-line' and etc. to ignore fields.
478 ((inhibit-field-text-motion t)
479 beg1 end1 col-beg1 col-end1 col-start col-end)
475 (goto-char (min beg end)) 480 (goto-char (min beg end))
476 (setq col-beg1 (current-column)) 481 (setq col-beg1 (current-column))
477 (beginning-of-line) 482 (beginning-of-line)