X-Git-Url: http://git.chise.org/gitweb/?p=elisp%2Fapel.git;a=blobdiff_plain;f=poe.el;h=0c7b4fff9db8aa2c1cdb61cb43e620df939401b2;hp=3ad269918e82bfe5419266ae9b6677b565da6241;hb=8b0dbe5092ae30b5092d7abf96649f96635d1060;hpb=6a1aa0cd36b1b3254c9a1ac95e8ccb44e48b9815 diff --git a/poe.el b/poe.el index 3ad2699..0c7b4ff 100644 --- a/poe.el +++ b/poe.el @@ -1,6 +1,7 @@ ;;; poe.el --- Portable Outfit for Emacsen -;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc. +;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2005, +;; 2008 Free Software Foundation, Inc. ;; Author: MORIOKA Tomohiko ;; Shuhei KOBAYASHI @@ -20,8 +21,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -900,7 +901,7 @@ On other systems, this variable is normally always nil.") ;; Emacs 20.3 or later. (defvar-maybe minor-mode-overriding-map-alist nil "Alist of keymaps to use for minor modes, in current major mode. -APEL provides this as dummy for a compatibility.") +APEL provides this as dummy for compatibility.") ;; Emacs 20.1/XEmacs 20.3(?) and later: (save-current-buffer &rest BODY) ;; @@ -1484,7 +1485,7 @@ Not fully compatible especially when invalid format is specified." ;; Emacs 19.29-19.34/XEmacs: `format-time-string' neither supports the ;; format string "%z" nor the third argument `universal'. -(unless (string-match "\\`[\\-\\+][0-9]+\\'" +(unless (string-match "\\`[---+][0-9]+\\'" (format-time-string "%z" (current-time))) (defadvice format-time-string (before support-timezone-in-numeric-form-and-3rd-arg @@ -1523,20 +1524,62 @@ Not fully compatible especially when invalid format is specified." ls (- ls 65536)))) (setq time (append (list ms ls) (nth 2 time)))))))) -;; Emacs 20.1/XEmacs 20.3(?) and later: (split-string STRING &optional PATTERN) -;; Here is a XEmacs version. -(defun-maybe split-string (string &optional pattern) - "Return a list of substrings of STRING which are separated by PATTERN. -If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." - (or pattern - (setq pattern "[ \f\t\n\r\v]+")) - ;; The FSF version of this function takes care not to cons in case - ;; of infloop. Maybe we should synch? - (let (parts (start 0)) - (while (string-match pattern string start) - (setq parts (cons (substring string start (match-beginning 0)) parts) - start (match-end 0))) - (nreverse (cons (substring string start) parts)))) +(defconst-maybe split-string-default-separators "[ \f\t\n\r\v]+" + "The default value of separators for `split-string'. + +A regexp matching strings of whitespace. May be locale-dependent +\(as yet unimplemented). Should not match non-breaking spaces. + +Warning: binding this to a different value and using it as default is +likely to have undesired semantics.") + +;; Here is a Emacs 22 version. OMIT-NULLS +(defun-maybe split-string (string &optional separators omit-nulls) + "Split STRING into substrings bounded by matches for SEPARATORS. + +The beginning and end of STRING, and each match for SEPARATORS, are +splitting points. The substrings matching SEPARATORS are removed, and +the substrings between the splitting points are collected as a list, +which is returned. + +If SEPARATORS is non-nil, it should be a regular expression matching text +which separates, but is not part of, the substrings. If nil it defaults to +`split-string-default-separators', normally \"[ \\f\\t\\n\\r\\v]+\", and +OMIT-NULLS is forced to t. + +If OMIT-NULLS is t, zero-length substrings are omitted from the list \(so +that for the default value of SEPARATORS leading and trailing whitespace +are effectively trimmed). If nil, all zero-length substrings are retained, +which correctly parses CSV format, for example. + +Note that the effect of `(split-string STRING)' is the same as +`(split-string STRING split-string-default-separators t)'). In the rare +case that you wish to retain zero-length substrings when splitting on +whitespace, use `(split-string STRING split-string-default-separators)'. + +Modifies the match data; use `save-match-data' if necessary." + (let ((keep-nulls (not (if separators omit-nulls t))) + (rexp (or separators split-string-default-separators)) + (start 0) + notfirst + (list nil)) + (while (and (string-match rexp string + (if (and notfirst + (= start (match-beginning 0)) + (< start (length string))) + (1+ start) start)) + (< start (length string))) + (setq notfirst t) + (if (or keep-nulls (< start (match-beginning 0))) + (setq list + (cons (substring string start (match-beginning 0)) + list))) + (setq start (match-end 0))) + (if (or keep-nulls (< start (length string))) + (setq list + (cons (substring string start) + list))) + (nreverse list))) ;;; @ Window commands emulation. (lisp/window.el)