Mercurial > hg > xemacs-beta
comparison lisp/subr.el @ 398:74fd4e045ea6 r21-2-29
Import from CVS: tag r21-2-29
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:13:30 +0200 |
parents | 8626e4521993 |
children | 2f8bb876ab1d |
comparison
equal
deleted
inserted
replaced
397:f4aeb21a5bad | 398:74fd4e045ea6 |
---|---|
221 (defvar kill-buffer-hook nil | 221 (defvar kill-buffer-hook nil |
222 "Function or functions to be called when a buffer is killed. | 222 "Function or functions to be called when a buffer is killed. |
223 The value of this variable may be buffer-local. | 223 The value of this variable may be buffer-local. |
224 The buffer about to be killed is current when this hook is run.") | 224 The buffer about to be killed is current when this hook is run.") |
225 | 225 |
226 ;; called by Frecord_buffer() | |
227 (defvar record-buffer-hook nil | |
228 "Function or functions to be called when a buffer is recorded. | |
229 The value of this variable may be buffer-local. | |
230 The buffer being recorded is passed as an argument to the hook.") | |
231 | |
226 ;; in C in FSFmacs | 232 ;; in C in FSFmacs |
227 (defvar kill-emacs-hook nil | 233 (defvar kill-emacs-hook nil |
228 "Function or functions to be called when `kill-emacs' is called, | 234 "Function or functions to be called when `kill-emacs' is called, |
229 just before emacs is actually killed.") | 235 just before emacs is actually killed.") |
230 | 236 |
236 ;; (setcar conscell newcar) | 242 ;; (setcar conscell newcar) |
237 ;; conscell) | 243 ;; conscell) |
238 ;; ...and analogously for RPLACD. | 244 ;; ...and analogously for RPLACD. |
239 (define-function 'rplaca 'setcar) | 245 (define-function 'rplaca 'setcar) |
240 (define-function 'rplacd 'setcdr) | 246 (define-function 'rplacd 'setcdr) |
247 | |
248 (defun copy-symbol (symbol &optional copy-properties) | |
249 "Return a new uninterned symbol with the same name as SYMBOL. | |
250 If COPY-PROPERTIES is non-nil, the new symbol will have a copy of | |
251 SYMBOL's value, function, and property lists." | |
252 (let ((new (make-symbol (symbol-name symbol)))) | |
253 (when copy-properties | |
254 ;; This will not copy SYMBOL's chain of forwarding objects, but | |
255 ;; I think that's OK. Callers should not expect such magic to | |
256 ;; keep working in the copy in the first place. | |
257 (and (boundp symbol) | |
258 (set new (symbol-value symbol))) | |
259 (and (fboundp symbol) | |
260 (fset new (symbol-function symbol))) | |
261 (setplist new (copy-list (symbol-plist symbol)))) | |
262 new)) | |
241 | 263 |
242 ;;;; String functions. | 264 ;;;; String functions. |
243 | 265 |
244 ;; XEmacs | 266 ;; XEmacs |
245 (defun replace-in-string (str regexp newtext &optional literal) | 267 (defun replace-in-string (str regexp newtext &optional literal) |
292 (defun split-string (string &optional pattern) | 314 (defun split-string (string &optional pattern) |
293 "Return a list of substrings of STRING which are separated by PATTERN. | 315 "Return a list of substrings of STRING which are separated by PATTERN. |
294 If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." | 316 If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." |
295 (or pattern | 317 (or pattern |
296 (setq pattern "[ \f\t\n\r\v]+")) | 318 (setq pattern "[ \f\t\n\r\v]+")) |
297 ;; The FSF version of this function takes care not to cons in case | 319 (let (parts (start 0) (len (length string))) |
298 ;; of infloop. Maybe we should synch? | 320 (if (string-match pattern string) |
299 (let (parts (start 0)) | 321 (setq parts (cons (substring string 0 (match-beginning 0)) parts) |
300 (while (string-match pattern string start) | 322 start (match-end 0))) |
323 (while (and (< start len) | |
324 (string-match pattern string (if (> start (match-beginning 0)) | |
325 start | |
326 (1+ start)))) | |
301 (setq parts (cons (substring string start (match-beginning 0)) parts) | 327 (setq parts (cons (substring string start (match-beginning 0)) parts) |
302 start (match-end 0))) | 328 start (match-end 0))) |
303 (nreverse (cons (substring string start) parts)))) | 329 (nreverse (cons (substring string start) parts)))) |
304 | 330 |
305 ;; #### #### #### AAaargh! Must be in C, because it is used insanely | 331 ;; #### #### #### AAaargh! Must be in C, because it is used insanely |
328 (prog1 | 354 (prog1 |
329 (buffer-string) | 355 (buffer-string) |
330 (erase-buffer)))) | 356 (erase-buffer)))) |
331 | 357 |
332 (defmacro with-current-buffer (buffer &rest body) | 358 (defmacro with-current-buffer (buffer &rest body) |
333 "Execute the forms in BODY with BUFFER as the current buffer. | 359 "Temporarily make BUFFER the current buffer and execute the forms in BODY. |
334 The value returned is the value of the last form in BODY. | 360 The value returned is the value of the last form in BODY. |
335 See also `with-temp-buffer'." | 361 See also `with-temp-buffer'." |
336 `(save-current-buffer | 362 `(save-current-buffer |
337 (set-buffer ,buffer) | 363 (set-buffer ,buffer) |
338 ,@body)) | 364 ,@body)) |
562 (defun ignore (&rest ignore) | 588 (defun ignore (&rest ignore) |
563 "Do nothing and return nil. | 589 "Do nothing and return nil. |
564 This function accepts any number of arguments, but ignores them." | 590 This function accepts any number of arguments, but ignores them." |
565 (interactive) | 591 (interactive) |
566 nil) | 592 nil) |
567 | |
568 (define-function 'mapc-internal 'mapc) | |
569 (make-obsolete 'mapc-internal 'mapc) | |
570 | 593 |
571 (define-function 'eval-in-buffer 'with-current-buffer) | 594 (define-function 'eval-in-buffer 'with-current-buffer) |
572 (make-obsolete 'eval-in-buffer 'with-current-buffer) | 595 (make-obsolete 'eval-in-buffer 'with-current-buffer) |
573 | 596 |
574 ;;; The real defn is in abbrev.el but some early callers | 597 ;;; The real defn is in abbrev.el but some early callers |
612 (and (eq (car-safe spec) 'interactive) | 635 (and (eq (car-safe spec) 'interactive) |
613 spec))) | 636 spec))) |
614 (t | 637 (t |
615 (error "Non-funcallable object: %s" function)))) | 638 (error "Non-funcallable object: %s" function)))) |
616 | 639 |
640 ;; This function used to be an alias to `buffer-substring', except | |
641 ;; that FSF Emacs 20.4 added a BUFFER argument in an incompatible way. | |
642 ;; The new FSF's semantics makes more sense, but we try to support | |
643 ;; both for backward compatibility. | |
644 (defun buffer-string (&optional buffer old-end old-buffer) | |
645 "Return the contents of the current buffer as a string. | |
646 If narrowing is in effect, this function returns only the visible part | |
647 of the buffer. | |
648 | |
649 If BUFFER is specified, the contents of that buffer are returned. | |
650 | |
651 The arguments OLD-END and OLD-BUFFER are supported for backward | |
652 compatibility with pre-21.2 XEmacsen times when arguments to this | |
653 function were (buffer-string &optional START END BUFFER)." | |
654 (cond | |
655 ((or (stringp buffer) (bufferp buffer)) | |
656 ;; Most definitely the new way. | |
657 (buffer-substring nil nil buffer)) | |
658 ((or (stringp old-buffer) (bufferp old-buffer) | |
659 (natnump buffer) (natnump old-end)) | |
660 ;; Definitely the old way. | |
661 (buffer-substring buffer old-end old-buffer)) | |
662 (t | |
663 ;; Probably the old way. | |
664 (buffer-substring buffer old-end old-buffer)))) | |
665 | |
617 ;; This was not present before. I think Jamie had some objections | 666 ;; This was not present before. I think Jamie had some objections |
618 ;; to this, so I'm leaving this undefined for now. --ben | 667 ;; to this, so I'm leaving this undefined for now. --ben |
619 | 668 |
620 ;;; The objection is this: there is more than one way to load the same file. | 669 ;;; The objection is this: there is more than one way to load the same file. |
621 ;;; "foo", "foo.elc", "foo.el", and "/some/path/foo.elc" are all different | 670 ;;; "foo", "foo.elc", "foo.el", and "/some/path/foo.elc" are all different |
665 (define-function 'search-forward-regexp (symbol-function 're-search-forward)) | 714 (define-function 'search-forward-regexp (symbol-function 're-search-forward)) |
666 (define-function 'search-backward-regexp (symbol-function 're-search-backward)) | 715 (define-function 'search-backward-regexp (symbol-function 're-search-backward)) |
667 (define-function 'remove-directory 'delete-directory) | 716 (define-function 'remove-directory 'delete-directory) |
668 (define-function 'set-match-data 'store-match-data) | 717 (define-function 'set-match-data 'store-match-data) |
669 (define-function 'send-string-to-terminal 'external-debugging-output) | 718 (define-function 'send-string-to-terminal 'external-debugging-output) |
670 (define-function 'buffer-string 'buffer-substring) | |
671 | 719 |
672 ;;; subr.el ends here | 720 ;;; subr.el ends here |