aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorKaroly Lorentey2004-06-05 17:21:43 +0000
committerKaroly Lorentey2004-06-05 17:21:43 +0000
commit3d63dd9d07a4ce2fbff5c4dd674f2593c1e3a278 (patch)
tree148939ccc16f4f81c8231987a0556ec21d529e7b /lisp
parentbf2d7b586bf6add7527739fcbdc007e921259397 (diff)
parent8e330b2257db682ec067cdd72d8e7a4580f97505 (diff)
downloademacs-3d63dd9d07a4ce2fbff5c4dd674f2593c1e3a278.tar.gz
emacs-3d63dd9d07a4ce2fbff5c4dd674f2593c1e3a278.zip
Merged in changes from CVS trunk.
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-366 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-367 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-368 Improve display-supports-face-attributes-p on non-ttys * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-369 Rewrite face-differs-from-default-p * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-370 Move `display-supports-face-attributes-p' entirely into C code * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-371 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-372 Simplify face-differs-from-default-p; don't consider :stipple. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-373 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-374 (tty_supports_face_attributes_p): Ensure attributes differ from default * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-375 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-185
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog62
-rw-r--r--lisp/battery.el45
-rw-r--r--lisp/faces.el62
-rw-r--r--lisp/help-fns.el17
-rw-r--r--lisp/textmodes/table.el17
-rw-r--r--lisp/vc-svn.el5
-rw-r--r--lisp/woman.el104
7 files changed, 188 insertions, 124 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 83f8a0e1cf0..3922ef9bf41 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,59 @@
12004-06-05 Juanma Barranquero <lektu@terra.es>
2
3 * help-fns.el (help-argument-name): Reintroduce face.
4 (help-default-arg-highlight): Use it, now that
5 `face-differs-from-default-p' can be trusted.
6
72004-06-05 Matt Hodges <matt@stchem.bham.ac.uk> (tiny change)
8
9 * textmodes/table.el: Sentence commands added to Point Motion
10 group; kill and backward-kill commands added to Extraction group.
11
122004-06-04 Mario Lang <mlang@delysid.org>
13
14 * battery.el (battery-linux-proc-acpi): mA was hardcored, but some
15 systems appear to use mW, make the code handle this. Fix a
16 division-by-zero bug while at it, and handle kernels with
17 a slightly different layout in /proc/acpi.
18
192004-06-04 Karl Fogel <kfogel@red-bean.com>
20
21 * vc-svn.el (vc-svn-checkin): Use 'nconc' instead of 'list*',
22 because the latter is a CL-ism. This fixes the bug reported by
23 Shawn Boyette <mdxi@collapsar.net> in
24 http://lists.gnu.org/archive/html/emacs-devel/2004-05/msg00442.html.
25
262004-06-04 Miles Bader <miles@gnu.org>
27
28 * faces.el (display-supports-face-attributes-p): Function moved to
29 C code. Previously only the tty-related portion of this function
30 was done in C; however the previous attempt to do a halfway-proper
31 job for non-tty displays in lisp didn't work properly because of
32 funny conditions during Emacs startup.
33 (face-differs-from-default-p): Simplify, now that
34 display-supports-face-attributes-p works properly on all display
35 types. Remove :stipple from comparison; it doesn't really work
36 in emacs anyway.
37
382004-06-04 Miles Bader <miles@gnu.org>
39
40 * faces.el (face-differs-from-default-p): Use a different
41 implementation, so we can really check whether FACE displays
42 differently or not.
43
442004-06-04 Miles Bader <miles@gnu.org>
45
46 * faces.el (display-supports-face-attributes-p): Implement a
47 `different from default' check for non-tty displays.
48
492004-06-03 David Kastrup <dak@gnu.org>
50
51 * woman.el (woman-mapcan): More concise code.
52 (woman-topic-all-completions, woman-topic-all-completions-1)
53 (woman-topic-all-completions-merge): Replace by a simpler and
54 much faster implementation based on O(n log n) sort/merge instead
55 of the old O(n^2) behavior.
56
12004-06-03 Miles Bader <miles@gnu.org> 572004-06-03 Miles Bader <miles@gnu.org>
2 58
3 * subr.el (read-number): Use canonical format for default in prompt. 59 * subr.el (read-number): Use canonical format for default in prompt.
@@ -193,7 +249,7 @@
193 * thumbs.el (thumbs-show-name): Do nothing if no image at point. 249 * thumbs.el (thumbs-show-name): Do nothing if no image at point.
194 (thumbs-mouse-find-image): New command. 250 (thumbs-mouse-find-image): New command.
195 (thumbs-mode-map): Bind it to mouse-2. 251 (thumbs-mode-map): Bind it to mouse-2.
196 (thumbs-mode): Make mode-class special. 252 (thumbs-mode): Make mode-class special.
197 (thumbs-view-image-mode): Likewise. 253 (thumbs-view-image-mode): Likewise.
198 254
1992004-05-29 Pavel Kobiakov <pk_at_work@yahoo.com> 2552004-05-29 Pavel Kobiakov <pk_at_work@yahoo.com>
@@ -1382,7 +1438,7 @@
1382 (sql-connect-postgres): Add username prompt. 1438 (sql-connect-postgres): Add username prompt.
1383 (sql-imenu-generic-expression, sql-mode-font-lock-object-name): 1439 (sql-imenu-generic-expression, sql-mode-font-lock-object-name):
1384 Make patterns less product specific. 1440 Make patterns less product specific.
1385 (sql-xemacs-p, sql-emacs19-p): Add flags for emacs variants. 1441 (sql-xemacs-p, sql-emacs19-p): Add flags for Emacs variants.
1386 (sql-mode-abbrev-table): Modify initialization. 1442 (sql-mode-abbrev-table): Modify initialization.
1387 (sql-builtin-face): Add variable. 1443 (sql-builtin-face): Add variable.
1388 (sql-keywords-re): Add macro. 1444 (sql-keywords-re): Add macro.
@@ -6381,7 +6437,7 @@
6381 (ffap-file-at-point): Use the new regexp to strip the prompts from 6437 (ffap-file-at-point): Use the new regexp to strip the prompts from
6382 the file names. This is an issue mostly for user prompts that 6438 the file names. This is an issue mostly for user prompts that
6383 don't have a trailing space and find-file-at-point is invoked from 6439 don't have a trailing space and find-file-at-point is invoked from
6384 within a shell inside emacs. 6440 within a shell inside Emacs.
6385 6441
63862003-09-24 Andre Spiegel <spiegel@gnu.org> 64422003-09-24 Andre Spiegel <spiegel@gnu.org>
6387 6443
diff --git a/lisp/battery.el b/lisp/battery.el
index c82d3ac02b3..73d78067571 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -61,7 +61,7 @@ introduced by a `%' character in a control string."
61 (cond ((eq battery-status-function 'battery-linux-proc-apm) 61 (cond ((eq battery-status-function 'battery-linux-proc-apm)
62 "Power %L, battery %B (%p%% load, remaining time %t)") 62 "Power %L, battery %B (%p%% load, remaining time %t)")
63 ((eq battery-status-function 'battery-linux-proc-acpi) 63 ((eq battery-status-function 'battery-linux-proc-acpi)
64 "Power %L, battery %B at %r mA (%p%% load, remaining time %t)")) 64 "Power %L, battery %B at %r (%p%% load, remaining time %t)"))
65 "*Control string formatting the string to display in the echo area. 65 "*Control string formatting the string to display in the echo area.
66Ordinary characters in the control string are printed as-is, while 66Ordinary characters in the control string are printed as-is, while
67conversion specifications introduced by a `%' character in the control 67conversion specifications introduced by a `%' character in the control
@@ -243,7 +243,8 @@ The following %-sequences are provided:
243%m Remaining time in minutes 243%m Remaining time in minutes
244%h Remaining time in hours 244%h Remaining time in hours
245%t Remaining time in the form `h:min'" 245%t Remaining time in the form `h:min'"
246 (let (capacity design-capacity rate charging-state warn low minutes hours) 246 (let (capacity design-capacity rate rate-type charging-state warn low
247 minutes hours)
247 (when (file-directory-p "/proc/acpi/battery/") 248 (when (file-directory-p "/proc/acpi/battery/")
248 ;; ACPI provides information about each battery present in the system in 249 ;; ACPI provides information about each battery present in the system in
249 ;; a separate subdirectory. We are going to merge the available 250 ;; a separate subdirectory. We are going to merge the available
@@ -261,32 +262,41 @@ The following %-sequences are provided:
261 ;; battery is "charging"/"discharging", the others are 262 ;; battery is "charging"/"discharging", the others are
262 ;; "unknown". 263 ;; "unknown".
263 (setq charging-state (match-string 1))) 264 (setq charging-state (match-string 1)))
264 (when (re-search-forward "present rate: +\\([0-9]+\\) mA$" nil t) 265 (when (re-search-forward "present rate: +\\([0-9]+\\) \\(m[AW]\\)$"
265 (setq rate (+ (or rate 0) (string-to-int (match-string 1))))) 266 nil t)
266 (when (re-search-forward "remaining capacity: +\\([0-9]+\\) mAh$" 267 (setq rate (+ (or rate 0) (string-to-int (match-string 1)))
268 rate-type (or (and rate-type
269 (if (string= rate-type (match-string 2))
270 rate-type
271 (error
272 "Inconsistent rate types (%s vs. %s)"
273 rate-type (match-string 2))))
274 (match-string 2))))
275 (when (re-search-forward "remaining capacity: +\\([0-9]+\\) m[AW]h$"
267 nil t) 276 nil t)
268 (setq capacity 277 (setq capacity
269 (+ (or capacity 0) (string-to-int (match-string 1)))))) 278 (+ (or capacity 0) (string-to-int (match-string 1))))))
270 (goto-char (point-max)) 279 (goto-char (point-max))
271 (insert-file-contents (expand-file-name "info" dir)) 280 (insert-file-contents (expand-file-name "info" dir))
272 (when (re-search-forward "present: +yes$" nil t) 281 (when (re-search-forward "present: +yes$" nil t)
273 (when (re-search-forward "design capacity: +\\([0-9]+\\) mAh$" 282 (when (re-search-forward "design capacity: +\\([0-9]+\\) m[AW]h$"
274 nil t) 283 nil t)
275 (setq design-capacity (+ (or design-capacity 0) 284 (setq design-capacity (+ (or design-capacity 0)
276 (string-to-int (match-string 1))))) 285 (string-to-int (match-string 1)))))
277 (when (re-search-forward "design capacity warning: +\\([0-9]+\\) mAh$" 286 (when (re-search-forward "design capacity warning: +\\([0-9]+\\) m[AW]h$"
278 nil t) 287 nil t)
279 (setq warn (+ (or warn 0) (string-to-int (match-string 1))))) 288 (setq warn (+ (or warn 0) (string-to-int (match-string 1)))))
280 (when (re-search-forward "design capacity low: +\\([0-9]+\\) mAh$" 289 (when (re-search-forward "design capacity low: +\\([0-9]+\\) m[AW]h$"
281 nil t) 290 nil t)
282 (setq low (+ (or low 0) 291 (setq low (+ (or low 0)
283 (string-to-int (match-string 1)))))))) 292 (string-to-int (match-string 1))))))))
284 (directory-files "/proc/acpi/battery/" t "BAT"))) 293 (directory-files "/proc/acpi/battery/" t "BAT")))
285 (and capacity rate 294 (and capacity rate
286 (setq minutes (floor (* (/ (float (if (string= charging-state 295 (setq minutes (if (zerop rate) 0
287 "charging") 296 (floor (* (/ (float (if (string= charging-state
288 (- design-capacity capacity) 297 "charging")
289 capacity)) rate) 60)) 298 (- design-capacity capacity)
299 capacity)) rate) 60)))
290 hours (/ minutes 60))) 300 hours (/ minutes 60)))
291 (list (cons ?c (or (and capacity (number-to-string capacity)) "N/A")) 301 (list (cons ?c (or (and capacity (number-to-string capacity)) "N/A"))
292 (cons ?L (or (when (file-exists-p "/proc/acpi/ac_adapter/AC/state") 302 (cons ?L (or (when (file-exists-p "/proc/acpi/ac_adapter/AC/state")
@@ -304,8 +314,17 @@ The following %-sequences are provided:
304 (when (re-search-forward 314 (when (re-search-forward
305 "temperature: +\\([0-9]+\\) C$" nil t) 315 "temperature: +\\([0-9]+\\) C$" nil t)
306 (match-string 1)))) 316 (match-string 1))))
317 (when (file-exists-p
318 "/proc/acpi/thermal_zone/THM/temperature")
319 (with-temp-buffer
320 (insert-file-contents
321 "/proc/acpi/thermal_zone/THM/temperature")
322 (when (re-search-forward
323 "temperature: +\\([0-9]+\\) C$" nil t)
324 (match-string 1))))
307 "N/A")) 325 "N/A"))
308 (cons ?r (or (and rate (number-to-string rate)) "N/A")) 326 (cons ?r (or (and rate (concat (number-to-string rate) " "
327 rate-type)) "N/A"))
309 (cons ?B (or charging-state "N/A")) 328 (cons ?B (or charging-state "N/A"))
310 (cons ?b (or (and (string= charging-state "charging") "+") 329 (cons ?b (or (and (string= charging-state "charging") "+")
311 (and low (< capacity low) "!") 330 (and low (< capacity low) "!")
diff --git a/lisp/faces.el b/lisp/faces.el
index 721c2fa3631..15e0f2549a8 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -240,27 +240,24 @@ If FRAME is omitted or nil, use the selected frame."
240 240
241 241
242(defun face-differs-from-default-p (face &optional frame) 242(defun face-differs-from-default-p (face &optional frame)
243 "Non-nil if FACE displays differently from the default face. 243 "Return non-nil if FACE displays differently from the default face.
244If the optional argument FRAME is given, report on face FACE in that frame. 244If the optional argument FRAME is given, report on face FACE in that frame.
245If FRAME is t, report on the defaults for face FACE (for new frames). 245If FRAME is t, report on the defaults for face FACE (for new frames).
246If FRAME is omitted or nil, use the selected frame. 246If FRAME is omitted or nil, use the selected frame."
247A face is considered to be ``the same'' as the default face if it is 247 (let ((attrs
248actually specified in the same way (equal attributes) or if it is 248 '(:family :width :height :weight :slant :foreground
249fully-unspecified, and thus inherits the attributes of any face it 249 :foreground :background :underline :overline
250is displayed on top of." 250 :strike-through :box :inverse-video))
251 (cond ((eq frame t) (setq frame nil)) 251 (differs nil))
252 ((null frame) (setq frame (selected-frame)))) 252 (while (and attrs (not differs))
253 (let* ((v1 (internal-lisp-face-p face frame)) 253 (let* ((attr (pop attrs))
254 (n (if v1 (length v1) 0)) 254 (attr-val (face-attribute face attr frame t)))
255 (v2 (internal-lisp-face-p 'default frame)) 255 (when (and
256 (i 1)) 256 (not (eq attr-val 'unspecified))
257 (unless v1 257 (display-supports-face-attributes-p (list attr attr-val)
258 (error "Not a face: %S" face)) 258 frame))
259 (while (and (< i n) 259 (setq differs attr))))
260 (or (eq 'unspecified (aref v1 i)) 260 differs))
261 (equal (aref v1 i) (aref v2 i))))
262 (setq i (1+ i)))
263 (< i n)))
264 261
265 262
266(defun face-nontrivial-p (face &optional frame) 263(defun face-nontrivial-p (face &optional frame)
@@ -1489,33 +1486,6 @@ If omitted or nil, that stands for the selected frame's display."
1489 (t 1486 (t
1490 (> (tty-color-gray-shades display) 2))))) 1487 (> (tty-color-gray-shades display) 2)))))
1491 1488
1492(defun display-supports-face-attributes-p (attributes &optional display)
1493 "Return non-nil if all the face attributes in ATTRIBUTES are supported.
1494The optional argument DISPLAY can be a display name, a frame, or
1495nil (meaning the selected frame's display)
1496
1497The definition of `supported' is somewhat heuristic, but basically means
1498that a face containing all the attributes in ATTRIBUTES, when merged
1499with the default face for display, can be represented in a way that's
1500
1501 (1) different in appearance than the default face, and
1502 (2) `close in spirit' to what the attributes specify, if not exact.
1503
1504Point (2) implies that a `:weight black' attribute will be satisfied by
1505any display that can display bold, and a `:foreground \"yellow\"' as long
1506as it can display a yellowish color, but `:slant italic' will _not_ be
1507satisfied by the tty display code's automatic substitution of a `dim'
1508face for italic."
1509 (let ((frame
1510 (if (framep display)
1511 display
1512 (car (frames-on-display-list display)))))
1513 ;; For now, we assume that non-tty displays can support everything.
1514 ;; Later, we should add the ability to query about specific fonts,
1515 ;; colors, etc.
1516 (or (memq (framep frame) '(x w32 mac))
1517 (tty-supports-face-attributes-p attributes frame))))
1518
1519 1489
1520;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1490;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1521;;; Background mode. 1491;;; Background mode.
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index e7e09a431bd..03ea5bef653 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -237,14 +237,19 @@ KIND should be `var' for a variable or `subr' for a subroutine."
237 (concat "src/" file) 237 (concat "src/" file)
238 file))))) 238 file)))))
239 239
240;;;###autoload
241(defface help-argument-name '((((supports :slant italic)) :inherit italic))
242 "Face to highlight argument names in *Help* buffers.")
243
240(defun help-default-arg-highlight (arg) 244(defun help-default-arg-highlight (arg)
241 "Default function to highlight arguments in *Help* buffers. 245 "Default function to highlight arguments in *Help* buffers.
242It returns ARG in lowercase italics, if the display supports it; 246It returns ARG in face `help-argument-name'; ARG is also
243else ARG is returned in uppercase normal." 247downcased if it displays differently than the default
244 (let ((attrs '(:slant italic))) 248face (according to `face-differs-from-default-p')."
245 (if (display-supports-face-attributes-p attrs) 249 (propertize (if (face-differs-from-default-p 'help-argument-name)
246 (propertize (downcase arg) 'face attrs) 250 (downcase arg)
247 arg))) 251 arg)
252 'face 'help-argument-name))
248 253
249(defun help-do-arg-highlight (doc args) 254(defun help-do-arg-highlight (doc args)
250 (with-syntax-table (make-syntax-table emacs-lisp-mode-syntax-table) 255 (with-syntax-table (make-syntax-table emacs-lisp-mode-syntax-table)
diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el
index 93ea3cc0c14..7b13d498b2e 100644
--- a/lisp/textmodes/table.el
+++ b/lisp/textmodes/table.el
@@ -1,11 +1,11 @@
1;;; table.el --- create and edit WYSIWYG text based embedded tables 1;;; table.el --- create and edit WYSIWYG text based embedded tables
2 2
3;; Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. 3;; Copyright (C) 2000, 01, 02, 03, 04 Free Software Foundation, Inc.
4 4
5;; Keywords: wp, convenience 5;; Keywords: wp, convenience
6;; Author: Takaaki Ota <Takaaki.Ota@am.sony.com> 6;; Author: Takaaki Ota <Takaaki.Ota@am.sony.com>
7;; Created: Sat Jul 08 2000 13:28:45 (PST) 7;; Created: Sat Jul 08 2000 13:28:45 (PST)
8;; Revised: Tue Dec 09 2003 14:36:50 (PST) 8;; Revised: Tue Jun 01 2004 11:36:39 (PDT)
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -1410,6 +1410,8 @@ the last cache point coordinate."
1410 end-of-buffer 1410 end-of-buffer
1411 forward-word 1411 forward-word
1412 backward-word 1412 backward-word
1413 forward-sentence
1414 backward-sentence
1413 forward-paragraph 1415 forward-paragraph
1414 backward-paragraph)) 1416 backward-paragraph))
1415 1417
@@ -1434,9 +1436,18 @@ the last cache point coordinate."
1434 (cons (cons command func-symbol) 1436 (cons (cons command func-symbol)
1435 table-command-remap-alist)))) 1437 table-command-remap-alist))))
1436 '(kill-region 1438 '(kill-region
1439 kill-ring-save
1437 delete-region 1440 delete-region
1438 copy-region-as-kill 1441 copy-region-as-kill
1439 kill-line)) 1442 kill-line
1443 kill-word
1444 backward-kill-word
1445 kill-sentence
1446 backward-kill-sentence
1447 kill-paragraph
1448 backward-kill-paragraph
1449 kill-sexp
1450 backward-kill-sexp))
1440 1451
1441;; Pasting Group 1452;; Pasting Group
1442(mapcar 1453(mapcar
diff --git a/lisp/vc-svn.el b/lisp/vc-svn.el
index 4db9788cc3b..82c09cbd435 100644
--- a/lisp/vc-svn.el
+++ b/lisp/vc-svn.el
@@ -195,8 +195,9 @@ This is only possible if SVN is responsible for FILE's directory.")
195 195
196(defun vc-svn-checkin (file rev comment) 196(defun vc-svn-checkin (file rev comment)
197 "SVN-specific version of `vc-backend-checkin'." 197 "SVN-specific version of `vc-backend-checkin'."
198 (let ((status (apply 'vc-svn-command nil 1 file 198 (let ((status (apply
199 "ci" (list* "-m" comment (vc-switches 'SVN 'checkin))))) 199 'vc-svn-command nil 1 file "ci"
200 (nconc (list "-m" comment) (vc-switches 'SVN 'checkin)))))
200 (set-buffer "*vc*") 201 (set-buffer "*vc*")
201 (goto-char (point-min)) 202 (goto-char (point-min))
202 (unless (equal status 0) 203 (unless (equal status 0)
diff --git a/lisp/woman.el b/lisp/woman.el
index d69c631f27b..ba511bca1ae 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -1,6 +1,6 @@
1;;; woman.el --- browse UN*X manual pages `wo (without) man' 1;;; woman.el --- browse UN*X manual pages `wo (without) man'
2 2
3;; Copyright (C) 2000, 2002 Free Software Foundation, Inc. 3;; Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
4 4
5;; Author: Francis J. Wright <F.J.Wright@qmul.ac.uk> 5;; Author: Francis J. Wright <F.J.Wright@qmul.ac.uk>
6;; Maintainer: Francis J. Wright <F.J.Wright@qmul.ac.uk> 6;; Maintainer: Francis J. Wright <F.J.Wright@qmul.ac.uk>
@@ -402,6 +402,7 @@
402;; Alexander Hinds <ahinds@thegrid.net> 402;; Alexander Hinds <ahinds@thegrid.net>
403;; Stefan Hornburg <sth@hacon.de> 403;; Stefan Hornburg <sth@hacon.de>
404;; Theodore Jump <tjump@cais.com> 404;; Theodore Jump <tjump@cais.com>
405;; David Kastrup <dak@gnu.org>
405;; Paul Kinnucan <paulk@mathworks.com> 406;; Paul Kinnucan <paulk@mathworks.com>
406;; Jonas Linde <jonas@init.se> 407;; Jonas Linde <jonas@init.se>
407;; Andrew McRae <andrewm@optimation.co.nz> 408;; Andrew McRae <andrewm@optimation.co.nz>
@@ -438,7 +439,8 @@
438 "Return concatenated list of FN applied to successive `car' elements of X. 439 "Return concatenated list of FN applied to successive `car' elements of X.
439FN must return a list, cons or nil. Useful for splicing into a list." 440FN must return a list, cons or nil. Useful for splicing into a list."
440 ;; Based on the Standard Lisp function MAPCAN but with args swapped! 441 ;; Based on the Standard Lisp function MAPCAN but with args swapped!
441 (and x (nconc (funcall fn (car x)) (woman-mapcan fn (cdr x))))) 442 ;; More concise implementation than the recursive one. -- dak
443 (apply #'nconc (mapcar fn x)))
442 444
443(defun woman-parse-colon-path (paths) 445(defun woman-parse-colon-path (paths)
444 "Explode search path string PATHS into a list of directory names. 446 "Explode search path string PATHS into a list of directory names.
@@ -1367,15 +1369,16 @@ The cdr of each alist element is the path-index / filename."
1367 ;; is re-processed by `woman-topic-all-completions-merge'. 1369 ;; is re-processed by `woman-topic-all-completions-merge'.
1368 (let (dir files (path-index 0)) ; indexing starts at zero 1370 (let (dir files (path-index 0)) ; indexing starts at zero
1369 (while path 1371 (while path
1370 (setq dir (car path) 1372 (setq dir (pop path))
1371 path (cdr path))
1372 (if (woman-not-member dir path) ; use each directory only once! 1373 (if (woman-not-member dir path) ; use each directory only once!
1373 (setq files 1374 (push (woman-topic-all-completions-1 dir path-index)
1374 (nconc files 1375 files))
1375 (woman-topic-all-completions-1 dir path-index))))
1376 (setq path-index (1+ path-index))) 1376 (setq path-index (1+ path-index)))
1377 ;; Uniquefy topics: 1377 ;; Uniquefy topics:
1378 (woman-topic-all-completions-merge files))) 1378 ;; Concate all lists with a single nconc call to
1379 ;; avoid retraversing the first lists repeatedly -- dak
1380 (woman-topic-all-completions-merge
1381 (apply #'nconc files))))
1379 1382
1380(defun woman-topic-all-completions-1 (dir path-index) 1383(defun woman-topic-all-completions-1 (dir path-index)
1381 "Return an alist of the man topics in directory DIR with index PATH-INDEX. 1384 "Return an alist of the man topics in directory DIR with index PATH-INDEX.
@@ -1388,55 +1391,54 @@ of the first `woman-cache-level' elements from the following list:
1388 ;; unnecessary. So let us assume that `woman-file-regexp' will 1391 ;; unnecessary. So let us assume that `woman-file-regexp' will
1389 ;; filter out any directories, which probably should not be there 1392 ;; filter out any directories, which probably should not be there
1390 ;; anyway, i.e. it is a user error! 1393 ;; anyway, i.e. it is a user error!
1391 (mapcar 1394 ;;
1392 (lambda (file) 1395 ;; Don't sort files: we do that when merging, anyway. -- dak
1393 (cons 1396 (let (newlst (lst (directory-files dir nil woman-file-regexp t))
1394 (file-name-sans-extension 1397 ;; Make an explicit regexp for stripping extension and
1395 (if (string-match woman-file-compression-regexp file) 1398 ;; compression extension: file-name-sans-extension is a
1396 (file-name-sans-extension file) 1399 ;; far too costly function. -- dak
1397 file)) 1400 (ext (format "\\(\\.[^.\\/]*\\)?\\(%s\\)?\\'"
1398 (if (> woman-cache-level 1) 1401 woman-file-compression-regexp)))
1399 (cons 1402 ;; Use a loop instead of mapcar in order to avoid the speed
1400 path-index 1403 ;; penalty of binding function arguments. -- dak
1401 (if (> woman-cache-level 2) 1404 (dolist (file lst newlst)
1402 (cons file nil)))))) 1405 (push
1403 (directory-files dir nil woman-file-regexp))) 1406 (cons
1407 (if (string-match ext file)
1408 (substring file 0 (match-beginning 0))
1409 file)
1410 (and (> woman-cache-level 1)
1411 (cons
1412 path-index
1413 (and (> woman-cache-level 2)
1414 (list file)))))
1415 newlst))))
1404 1416
1405(defun woman-topic-all-completions-merge (alist) 1417(defun woman-topic-all-completions-merge (alist)
1406 "Merge the alist ALIST so that the keys are unique. 1418 "Merge the alist ALIST so that the keys are unique.
1407Also make each path-info component into a list. 1419Also make each path-info component into a list.
1408\(Note that this function changes the value of ALIST.)" 1420\(Note that this function changes the value of ALIST.)"
1409 ;; Intended to be fast by avoiding recursion and list copying. 1421 ;; Replaces unreadably "optimized" O(n^2) implementation.
1410 (if (> woman-cache-level 1) 1422 ;; Instead we use sorting to merge stuff efficiently. -- dak
1411 (let ((newalist alist)) 1423 (let (elt newalist)
1412 (while newalist 1424 ;; Sort list into reverse order
1413 (let ((tail newalist) (topic (car (car newalist)))) 1425 (setq alist (sort alist (lambda(x y) (string< (car y) (car x)))))
1414 ;; Make the path-info into a list: 1426 ;; merge duplicate keys.
1415 (setcdr (car newalist) (list (cdr (car newalist)))) 1427 (if (> woman-cache-level 1)
1416 (while tail 1428 (while alist
1417 (while (and tail (not (string= topic (car (car (cdr tail)))))) 1429 (setq elt (pop alist))
1418 (setq tail (cdr tail))) 1430 (if (equal (car elt) (caar newalist))
1419 (if tail ; merge path-info into (car newalist) 1431 (unless (member (cdr elt) (cdar newalist))
1420 (let ((path-info (cdr (car (cdr tail))))) 1432 (setcdr (car newalist) (cons (cdr elt)
1421 (if (member path-info (cdr (car newalist))) 1433 (cdar newalist))))
1422 () 1434 (setcdr elt (list (cdr elt)))
1423 ;; Make the path-info into a list: 1435 (push elt newalist)))
1424 (nconc (car newalist) (list path-info)))
1425 (setcdr tail (cdr (cdr tail))))
1426 ))
1427 (setq newalist (cdr newalist))))
1428 alist)
1429 ;; woman-cache-level = 1 => elements are single-element lists ... 1436 ;; woman-cache-level = 1 => elements are single-element lists ...
1430 (while (and alist (member (car alist) (cdr alist))) 1437 (while alist
1431 (setq alist (cdr alist))) 1438 (setq elt (pop alist))
1432 (if alist 1439 (unless (equal (car elt) (caar newalist))
1433 (let ((newalist alist) cdr_alist) 1440 (push elt newalist))))
1434 (while (setq cdr_alist (cdr alist)) 1441 newalist))
1435 (if (not (member (car cdr_alist) (cdr cdr_alist)))
1436 (setq alist cdr_alist)
1437 (setcdr alist (cdr cdr_alist)))
1438 )
1439 newalist))))
1440 1442
1441(defun woman-file-name-all-completions (topic) 1443(defun woman-file-name-all-completions (topic)
1442 "Return an alist of the files in all man directories that match TOPIC." 1444 "Return an alist of the files in all man directories that match TOPIC."