comparison lisp/simple.el @ 44252:0cdafef85267

(play-sound-file): Moved from subr.el, made unconditional.
author Richard M. Stallman <rms@gnu.org>
date Fri, 29 Mar 2002 23:14:00 +0000
parents 7213f46c80a0
children 5180d0ff95f6
comparison
equal deleted inserted replaced
44251:3900f65547f0 44252:0cdafef85267
370 (delete-region 370 (delete-region
371 (point) 371 (point)
372 (progn 372 (progn
373 (skip-chars-forward " \t") 373 (skip-chars-forward " \t")
374 (constrain-to-field nil orig-pos t))))) 374 (constrain-to-field nil orig-pos t)))))
375 375
376 (defun beginning-of-buffer (&optional arg) 376 (defun beginning-of-buffer (&optional arg)
377 "Move point to the beginning of the buffer; leave mark at previous position. 377 "Move point to the beginning of the buffer; leave mark at previous position.
378 With arg N, put point N/10 of the way from the beginning. 378 With arg N, put point N/10 of the way from the beginning.
379 379
380 If the buffer is narrowed, this command uses the beginning and size 380 If the buffer is narrowed, this command uses the beginning and size
431 that uses or sets the mark." 431 that uses or sets the mark."
432 (interactive) 432 (interactive)
433 (push-mark (point)) 433 (push-mark (point))
434 (push-mark (point-max) nil t) 434 (push-mark (point-max) nil t)
435 (goto-char (point-min))) 435 (goto-char (point-min)))
436 436
437 437
438 ;; Counting lines, one way or another. 438 ;; Counting lines, one way or another.
439 439
440 (defun goto-line (arg) 440 (defun goto-line (arg)
441 "Goto line ARG, counting from line 1 at beginning of buffer." 441 "Goto line ARG, counting from line 1 at beginning of buffer."
557 (message "Char: %s %s point=%d of %d (%d%%) column %d %s" 557 (message "Char: %s %s point=%d of %d (%d%%) column %d %s"
558 (if (< char 256) 558 (if (< char 256)
559 (single-key-description char) 559 (single-key-description char)
560 (buffer-substring-no-properties (point) (1+ (point)))) 560 (buffer-substring-no-properties (point) (1+ (point))))
561 encoding-msg pos total percent col hscroll)))))) 561 encoding-msg pos total percent col hscroll))))))
562 562
563 (defvar read-expression-map 563 (defvar read-expression-map
564 (let ((m (make-sparse-keymap))) 564 (let ((m (make-sparse-keymap)))
565 (define-key m "\M-\t" 'lisp-complete-symbol) 565 (define-key m "\M-\t" 'lisp-complete-symbol)
566 (set-keymap-parent m minibuffer-local-map) 566 (set-keymap-parent m minibuffer-local-map)
567 m) 567 m)
673 ;; add it to the history. 673 ;; add it to the history.
674 (or (equal newcmd (car command-history)) 674 (or (equal newcmd (car command-history))
675 (setq command-history (cons newcmd command-history))) 675 (setq command-history (cons newcmd command-history)))
676 (eval newcmd)) 676 (eval newcmd))
677 (ding)))) 677 (ding))))
678 678
679 (defvar minibuffer-history nil 679 (defvar minibuffer-history nil
680 "Default minibuffer history list. 680 "Default minibuffer history list.
681 This is used for all minibuffer input 681 This is used for all minibuffer input
682 except when an alternate history list is specified.") 682 except when an alternate history list is specified.")
683 (defvar minibuffer-history-sexp-flag nil 683 (defvar minibuffer-history-sexp-flag nil
884 "Return the display width of the minibuffer prompt. 884 "Return the display width of the minibuffer prompt.
885 Return 0 if current buffer is not a mini-buffer." 885 Return 0 if current buffer is not a mini-buffer."
886 ;; Return the width of everything before the field at the end of 886 ;; Return the width of everything before the field at the end of
887 ;; the buffer; this should be 0 for normal buffers. 887 ;; the buffer; this should be 0 for normal buffers.
888 (1- (minibuffer-prompt-end))) 888 (1- (minibuffer-prompt-end)))
889 889
890 ;Put this on C-x u, so we can force that rather than C-_ into startup msg 890 ;Put this on C-x u, so we can force that rather than C-_ into startup msg
891 (defalias 'advertised-undo 'undo) 891 (defalias 'advertised-undo 'undo)
892 892
893 (defun undo (&optional arg) 893 (defun undo (&optional arg)
894 "Undo some previous changes. 894 "Undo some previous changes.
1517 "Execute shell command COMMAND and return its output as a string." 1517 "Execute shell command COMMAND and return its output as a string."
1518 (with-output-to-string 1518 (with-output-to-string
1519 (with-current-buffer 1519 (with-current-buffer
1520 standard-output 1520 standard-output
1521 (call-process shell-file-name nil t nil shell-command-switch command)))) 1521 (call-process shell-file-name nil t nil shell-command-switch command))))
1522 1522
1523 (defvar universal-argument-map 1523 (defvar universal-argument-map
1524 (let ((map (make-sparse-keymap))) 1524 (let ((map (make-sparse-keymap)))
1525 (define-key map [t] 'universal-argument-other-key) 1525 (define-key map [t] 'universal-argument-other-key)
1526 (define-key map (vector meta-prefix-char t) 'universal-argument-other-key) 1526 (define-key map (vector meta-prefix-char t) 'universal-argument-other-key)
1527 (define-key map [switch-frame] nil) 1527 (define-key map [switch-frame] nil)
1633 (setq unread-command-events 1633 (setq unread-command-events
1634 (append (nthcdr universal-argument-num-events keylist) 1634 (append (nthcdr universal-argument-num-events keylist)
1635 unread-command-events))) 1635 unread-command-events)))
1636 (reset-this-command-lengths) 1636 (reset-this-command-lengths)
1637 (setq overriding-terminal-local-map nil)) 1637 (setq overriding-terminal-local-map nil))
1638 1638
1639 ;;;; Window system cut and paste hooks. 1639 ;;;; Window system cut and paste hooks.
1640 1640
1641 (defvar interprogram-cut-function nil 1641 (defvar interprogram-cut-function nil
1642 "Function to call to make a killed region available to other programs. 1642 "Function to call to make a killed region available to other programs.
1643 1643
1670 than Emacs has provided a string for pasting; if Emacs provided the 1670 than Emacs has provided a string for pasting; if Emacs provided the
1671 most recent string, the function should return nil. If it is 1671 most recent string, the function should return nil. If it is
1672 difficult to tell whether Emacs or some other program provided the 1672 difficult to tell whether Emacs or some other program provided the
1673 current string, it is probably good enough to return nil if the string 1673 current string, it is probably good enough to return nil if the string
1674 is equal (according to `string=') to the last text Emacs provided.") 1674 is equal (according to `string=') to the last text Emacs provided.")
1675 1675
1676 1676
1677 1677
1678 ;;;; The kill ring data structure. 1678 ;;;; The kill ring data structure.
1679 1679
1680 (defvar kill-ring nil 1680 (defvar kill-ring nil
1946 (defun rotate-yank-pointer (arg) 1946 (defun rotate-yank-pointer (arg)
1947 "Rotate the yanking point in the kill ring. 1947 "Rotate the yanking point in the kill ring.
1948 With argument, rotate that many kills forward (or backward, if negative)." 1948 With argument, rotate that many kills forward (or backward, if negative)."
1949 (interactive "p") 1949 (interactive "p")
1950 (current-kill arg)) 1950 (current-kill arg))
1951 1951
1952 ;; Some kill commands. 1952 ;; Some kill commands.
1953 1953
1954 ;; Internal subroutine of delete-char 1954 ;; Internal subroutine of delete-char
1955 (defun kill-forward-chars (arg) 1955 (defun kill-forward-chars (arg)
1956 (if (listp arg) (setq arg (car arg))) 1956 (if (listp arg) (setq arg (car arg)))
2127 (assq prop buffer-invisibility-spec))))) 2127 (assq prop buffer-invisibility-spec)))))
2128 (if (get-text-property (point) 'invisible) 2128 (if (get-text-property (point) 'invisible)
2129 (goto-char (next-single-property-change (point) 'invisible)) 2129 (goto-char (next-single-property-change (point) 'invisible))
2130 (goto-char (next-overlay-change (point)))) 2130 (goto-char (next-overlay-change (point))))
2131 (end-of-line))) 2131 (end-of-line)))
2132 2132
2133 (defun insert-buffer (buffer) 2133 (defun insert-buffer (buffer)
2134 "Insert after point the contents of BUFFER. 2134 "Insert after point the contents of BUFFER.
2135 Puts mark after the inserted text. 2135 Puts mark after the inserted text.
2136 BUFFER may be a buffer or a buffer name. 2136 BUFFER may be a buffer or a buffer name.
2137 2137
2209 (set-buffer (get-buffer-create buffer)) 2209 (set-buffer (get-buffer-create buffer))
2210 (barf-if-buffer-read-only) 2210 (barf-if-buffer-read-only)
2211 (erase-buffer) 2211 (erase-buffer)
2212 (save-excursion 2212 (save-excursion
2213 (insert-buffer-substring oldbuf start end))))) 2213 (insert-buffer-substring oldbuf start end)))))
2214 2214
2215 (put 'mark-inactive 'error-conditions '(mark-inactive error)) 2215 (put 'mark-inactive 'error-conditions '(mark-inactive error))
2216 (put 'mark-inactive 'error-message "The mark is not active now") 2216 (put 'mark-inactive 'error-message "The mark is not active now")
2217 2217
2218 (defun mark (&optional force) 2218 (defun mark (&optional force)
2219 "Return this buffer's mark value as integer; error if mark inactive. 2219 "Return this buffer's mark value as integer; error if mark inactive.
2414 (or (and (>= position (point-min)) 2414 (or (and (>= position (point-min))
2415 (<= position (point-max))) 2415 (<= position (point-max)))
2416 (widen)) 2416 (widen))
2417 (goto-char position) 2417 (goto-char position)
2418 (switch-to-buffer buffer))) 2418 (switch-to-buffer buffer)))
2419 2419
2420 (defcustom next-line-add-newlines nil 2420 (defcustom next-line-add-newlines nil
2421 "*If non-nil, `next-line' inserts newline to avoid `end of buffer' error." 2421 "*If non-nil, `next-line' inserts newline to avoid `end of buffer' error."
2422 :type 'boolean 2422 :type 'boolean
2423 :version "21.1" 2423 :version "21.1"
2424 :group 'editing-basics) 2424 :group 'editing-basics)
2679 (setq goal-column (current-column)) 2679 (setq goal-column (current-column))
2680 (message (substitute-command-keys 2680 (message (substitute-command-keys
2681 "Goal column %d (use \\[set-goal-column] with an arg to unset it)") 2681 "Goal column %d (use \\[set-goal-column] with an arg to unset it)")
2682 goal-column)) 2682 goal-column))
2683 nil) 2683 nil)
2684 2684
2685 2685
2686 (defun scroll-other-window-down (lines) 2686 (defun scroll-other-window-down (lines)
2687 "Scroll the \"other window\" down. 2687 "Scroll the \"other window\" down.
2688 For more details, see the documentation for `scroll-other-window'." 2688 For more details, see the documentation for `scroll-other-window'."
2689 (interactive "P") 2689 (interactive "P")
2725 (progn 2725 (progn
2726 (select-window window) 2726 (select-window window)
2727 (end-of-buffer arg) 2727 (end-of-buffer arg)
2728 (recenter '(t))) 2728 (recenter '(t)))
2729 (select-window orig-window)))) 2729 (select-window orig-window))))
2730 2730
2731 (defun transpose-chars (arg) 2731 (defun transpose-chars (arg)
2732 "Interchange characters around point, moving forward one character. 2732 "Interchange characters around point, moving forward one character.
2733 With prefix arg ARG, effect is to take character before point 2733 With prefix arg ARG, effect is to take character before point
2734 and drag it forward past ARG other characters (backward if ARG negative). 2734 and drag it forward past ARG other characters (backward if ARG negative).
2735 If no argument and at end of line, the previous two chars are exchanged." 2735 If no argument and at end of line, the previous two chars are exchanged."
2809 (setq word2 (delete-and-extract-region (car pos2) (cdr pos2))) 2809 (setq word2 (delete-and-extract-region (car pos2) (cdr pos2)))
2810 (goto-char (car pos2)) 2810 (goto-char (car pos2))
2811 (insert (delete-and-extract-region (car pos1) (cdr pos1))) 2811 (insert (delete-and-extract-region (car pos1) (cdr pos1)))
2812 (goto-char (car pos1)) 2812 (goto-char (car pos1))
2813 (insert word2)))) 2813 (insert word2))))
2814 2814
2815 (defun backward-word (arg) 2815 (defun backward-word (arg)
2816 "Move backward until encountering the beginning of a word. 2816 "Move backward until encountering the beginning of a word.
2817 With argument, do this that many times." 2817 With argument, do this that many times."
2818 (interactive "p") 2818 (interactive "p")
2819 (forward-word (- arg))) 2819 (forward-word (- arg)))
2878 (setq end (point)) 2878 (setq end (point))
2879 (skip-syntax-backward "w_") 2879 (skip-syntax-backward "w_")
2880 (setq start (point))) 2880 (setq start (point)))
2881 (buffer-substring-no-properties start end))) 2881 (buffer-substring-no-properties start end)))
2882 (buffer-substring-no-properties start end))))) 2882 (buffer-substring-no-properties start end)))))
2883 2883
2884 (defcustom fill-prefix nil 2884 (defcustom fill-prefix nil
2885 "*String for filling to insert at front of new line, or nil for none." 2885 "*String for filling to insert at front of new line, or nil for none."
2886 :type '(choice (const :tag "None" nil) 2886 :type '(choice (const :tag "None" nil)
2887 string) 2887 string)
2888 :group 'fill) 2888 :group 'fill)
3081 (if (not (integerp arg)) 3081 (if (not (integerp arg))
3082 ;; Disallow missing argument; it's probably a typo for C-x C-f. 3082 ;; Disallow missing argument; it's probably a typo for C-x C-f.
3083 (error "set-fill-column requires an explicit argument") 3083 (error "set-fill-column requires an explicit argument")
3084 (message "Fill column set to %d (was %d)" arg fill-column) 3084 (message "Fill column set to %d (was %d)" arg fill-column)
3085 (setq fill-column arg))) 3085 (setq fill-column arg)))
3086 3086
3087 (defun set-selective-display (arg) 3087 (defun set-selective-display (arg)
3088 "Set `selective-display' to ARG; clear it if no arg. 3088 "Set `selective-display' to ARG; clear it if no arg.
3089 When the value of `selective-display' is a number > 0, 3089 When the value of `selective-display' is a number > 0,
3090 lines whose indentation is >= that value are not displayed. 3090 lines whose indentation is >= that value are not displayed.
3091 The variable `selective-display' has a separate value for each buffer." 3091 The variable `selective-display' has a separate value for each buffer."
3181 (interactive "P") 3181 (interactive "P")
3182 (setq column-number-mode 3182 (setq column-number-mode
3183 (if (null arg) (not column-number-mode) 3183 (if (null arg) (not column-number-mode)
3184 (> (prefix-numeric-value arg) 0))) 3184 (> (prefix-numeric-value arg) 0)))
3185 (force-mode-line-update)) 3185 (force-mode-line-update))
3186 3186
3187 (defgroup paren-blinking nil 3187 (defgroup paren-blinking nil
3188 "Blinking matching of parens and expressions." 3188 "Blinking matching of parens and expressions."
3189 :prefix "blink-matching-" 3189 :prefix "blink-matching-"
3190 :group 'paren-matching) 3190 :group 'paren-matching)
3191 3191
3296 ((not blink-matching-paren-distance) 3296 ((not blink-matching-paren-distance)
3297 (message "Unmatched parenthesis")))))))) 3297 (message "Unmatched parenthesis"))))))))
3298 3298
3299 ;Turned off because it makes dbx bomb out. 3299 ;Turned off because it makes dbx bomb out.
3300 (setq blink-paren-function 'blink-matching-open) 3300 (setq blink-paren-function 'blink-matching-open)
3301 3301
3302 ;; This executes C-g typed while Emacs is waiting for a command. 3302 ;; This executes C-g typed while Emacs is waiting for a command.
3303 ;; Quitting out of a program does not go through here; 3303 ;; Quitting out of a program does not go through here;
3304 ;; that happens in the QUIT macro at the C code level. 3304 ;; that happens in the QUIT macro at the C code level.
3305 (defun keyboard-quit () 3305 (defun keyboard-quit ()
3306 "Signal a `quit' condition. 3306 "Signal a `quit' condition.
3339 (funcall buffer-quit-function)) 3339 (funcall buffer-quit-function))
3340 ((not (one-window-p t)) 3340 ((not (one-window-p t))
3341 (delete-other-windows)) 3341 (delete-other-windows))
3342 ((string-match "^ \\*" (buffer-name (current-buffer))) 3342 ((string-match "^ \\*" (buffer-name (current-buffer)))
3343 (bury-buffer)))) 3343 (bury-buffer))))
3344
3345 (defun play-sound-file (file &optional volume device)
3346 "Play sound stored in FILE.
3347 VOLUME and DEVICE correspond to the keywords of the sound
3348 specification for `play-sound'."
3349 (interactive "fPlay sound file: ")
3350 (let ((sound (list :file file)))
3351 (if volume
3352 (plist-put sound :volume volume))
3353 (if device
3354 (plist-put sound :device device))
3355 (push 'sound sound)
3356 (play-sound sound)))
3344 3357
3345 (define-key global-map "\e\e\e" 'keyboard-escape-quit) 3358 (define-key global-map "\e\e\e" 'keyboard-escape-quit)
3346 3359
3347 (defcustom read-mail-command 'rmail 3360 (defcustom read-mail-command 'rmail
3348 "*Your preference for a mail reading package. 3361 "*Your preference for a mail reading package.