comparison lisp/subr.el @ 77092:055a54275ec3

Fix indentation.
author Vinicius Jose Latorre <viniciusjl@ig.com.br>
date Mon, 09 Apr 2007 23:10:00 +0000
parents 85841d693997
children d57bf0ca865e dc002877ce12 4ef881a120fe
comparison
equal deleted inserted replaced
77091:b3589a49ba09 77092:055a54275ec3
577 nil) 577 nil)
578 578
579 ;;;; substitute-key-definition and its subroutines. 579 ;;;; substitute-key-definition and its subroutines.
580 580
581 (defvar key-substitution-in-progress nil 581 (defvar key-substitution-in-progress nil
582 "Used internally by `substitute-key-definition'.") 582 "Used internally by `substitute-key-definition'.")
583 583
584 (defun substitute-key-definition (olddef newdef keymap &optional oldmap prefix) 584 (defun substitute-key-definition (olddef newdef keymap &optional oldmap prefix)
585 "Replace OLDDEF with NEWDEF for any keys in KEYMAP now defined as OLDDEF. 585 "Replace OLDDEF with NEWDEF for any keys in KEYMAP now defined as OLDDEF.
586 In other words, OLDDEF is replaced with NEWDEF where ever it appears. 586 In other words, OLDDEF is replaced with NEWDEF where ever it appears.
587 Alternatively, if optional fourth argument OLDMAP is specified, we redefine 587 Alternatively, if optional fourth argument OLDMAP is specified, we redefine
819 (nth 1 position)))) 819 (nth 1 position))))
820 820
821 (defun posn-set-point (position) 821 (defun posn-set-point (position)
822 "Move point to POSITION. 822 "Move point to POSITION.
823 Select the corresponding window as well." 823 Select the corresponding window as well."
824 (if (not (windowp (posn-window position))) 824 (if (not (windowp (posn-window position)))
825 (error "Position not in text area of window")) 825 (error "Position not in text area of window"))
826 (select-window (posn-window position)) 826 (select-window (posn-window position))
827 (if (numberp (posn-point position)) 827 (if (numberp (posn-point position))
828 (goto-char (posn-point position)))) 828 (goto-char (posn-point position))))
829 829
830 (defsubst posn-x-y (position) 830 (defsubst posn-x-y (position)
831 "Return the x and y coordinates in POSITION. 831 "Return the x and y coordinates in POSITION.
832 POSITION should be a list of the form returned by the `event-start' 832 POSITION should be a list of the form returned by the `event-start'
833 and `event-end' functions." 833 and `event-end' functions."
947 947
948 948
949 ;;;; Obsolescence declarations for variables, and aliases. 949 ;;;; Obsolescence declarations for variables, and aliases.
950 950
951 (make-obsolete-variable 'directory-sep-char "do not use it." "21.1") 951 (make-obsolete-variable 'directory-sep-char "do not use it." "21.1")
952 (make-obsolete-variable 'mode-line-inverse-video "use the appropriate faces instead." "21.1") 952 (make-obsolete-variable
953 (make-obsolete-variable 'unread-command-char 953 'mode-line-inverse-video
954 "use `unread-command-events' instead. That variable is a list of events 954 "use the appropriate faces instead."
955 "21.1")
956 (make-obsolete-variable
957 'unread-command-char
958 "use `unread-command-events' instead. That variable is a list of events
955 to reread, so it now uses nil to mean `no event', instead of -1." 959 to reread, so it now uses nil to mean `no event', instead of -1."
956 "before 19.15") 960 "before 19.15")
957 961
958 ;; Lisp manual only updated in 22.1. 962 ;; Lisp manual only updated in 22.1.
959 (define-obsolete-variable-alias 'executing-macro 'executing-kbd-macro 963 (define-obsolete-variable-alias 'executing-macro 'executing-kbd-macro
960 "before 19.34") 964 "before 19.34")
961 965
962 (defvaralias 'x-lost-selection-hooks 'x-lost-selection-functions) 966 (defvaralias 'x-lost-selection-hooks 'x-lost-selection-functions)
963 (make-obsolete-variable 'x-lost-selection-hooks 'x-lost-selection-functions "22.1") 967 (make-obsolete-variable 'x-lost-selection-hooks
968 'x-lost-selection-functions "22.1")
964 (defvaralias 'x-sent-selection-hooks 'x-sent-selection-functions) 969 (defvaralias 'x-sent-selection-hooks 'x-sent-selection-functions)
965 (make-obsolete-variable 'x-sent-selection-hooks 'x-sent-selection-functions "22.1") 970 (make-obsolete-variable 'x-sent-selection-hooks
971 'x-sent-selection-functions "22.1")
966 972
967 (defvaralias 'messages-buffer-max-lines 'message-log-max) 973 (defvaralias 'messages-buffer-max-lines 'message-log-max)
968 974
969 ;;;; Alternate names for functions - these are not being phased out. 975 ;;;; Alternate names for functions - these are not being phased out.
970 976
1532 1538
1533 ;; open-network-stream is a wrapper around make-network-process. 1539 ;; open-network-stream is a wrapper around make-network-process.
1534 1540
1535 (when (featurep 'make-network-process) 1541 (when (featurep 'make-network-process)
1536 (defun open-network-stream (name buffer host service) 1542 (defun open-network-stream (name buffer host service)
1537 "Open a TCP connection for a service to a host. 1543 "Open a TCP connection for a service to a host.
1538 Returns a subprocess-object to represent the connection. 1544 Returns a subprocess-object to represent the connection.
1539 Input and output work as for subprocesses; `delete-process' closes it. 1545 Input and output work as for subprocesses; `delete-process' closes it.
1540 1546
1541 Args are NAME BUFFER HOST SERVICE. 1547 Args are NAME BUFFER HOST SERVICE.
1542 NAME is name for process. It is modified if necessary to make it unique. 1548 NAME is name for process. It is modified if necessary to make it unique.
1546 BUFFER may be also nil, meaning that this process is not associated 1552 BUFFER may be also nil, meaning that this process is not associated
1547 with any buffer. 1553 with any buffer.
1548 HOST is name of the host to connect to, or its IP address. 1554 HOST is name of the host to connect to, or its IP address.
1549 SERVICE is name of the service desired, or an integer specifying 1555 SERVICE is name of the service desired, or an integer specifying
1550 a port number to connect to." 1556 a port number to connect to."
1551 (make-network-process :name name :buffer buffer 1557 (make-network-process :name name :buffer buffer
1552 :host host :service service))) 1558 :host host :service service)))
1553 1559
1554 ;; compatibility 1560 ;; compatibility
1555 1561
1556 (make-obsolete 'process-kill-without-query 1562 (make-obsolete
1557 "use `process-query-on-exit-flag' or `set-process-query-on-exit-flag'." 1563 'process-kill-without-query
1558 "22.1") 1564 "use `process-query-on-exit-flag' or `set-process-query-on-exit-flag'."
1565 "22.1")
1559 (defun process-kill-without-query (process &optional flag) 1566 (defun process-kill-without-query (process &optional flag)
1560 "Say no query needed if PROCESS is running when Emacs is exited. 1567 "Say no query needed if PROCESS is running when Emacs is exited.
1561 Optional second argument if non-nil says to require a query. 1568 Optional second argument if non-nil says to require a query.
1562 Value is t if a query was formerly required." 1569 Value is t if a query was formerly required."
1563 (let ((old (process-query-on-exit-flag process))) 1570 (let ((old (process-query-on-exit-flag process)))
1586 1593
1587 (custom-declare-variable-early 1594 (custom-declare-variable-early
1588 'read-quoted-char-radix 8 1595 'read-quoted-char-radix 8
1589 "*Radix for \\[quoted-insert] and other uses of `read-quoted-char'. 1596 "*Radix for \\[quoted-insert] and other uses of `read-quoted-char'.
1590 Legitimate radix values are 8, 10 and 16." 1597 Legitimate radix values are 8, 10 and 16."
1591 :type '(choice (const 8) (const 10) (const 16)) 1598 :type '(choice (const 8) (const 10) (const 16))
1592 :group 'editing-basics) 1599 :group 'editing-basics)
1593 1600
1594 (defun read-quoted-char (&optional prompt) 1601 (defun read-quoted-char (&optional prompt)
1595 "Like `read-char', but do not allow quitting. 1602 "Like `read-char', but do not allow quitting.
1596 Also, if the first character read is an octal digit, 1603 Also, if the first character read is an octal digit,
1597 we read any number of octal digits and return the 1604 we read any number of octal digits and return the
2230 ;; If last inserted char has properties, mark them as rear-nonsticky. 2237 ;; If last inserted char has properties, mark them as rear-nonsticky.
2231 (if (and (> end opoint) 2238 (if (and (> end opoint)
2232 (text-properties-at (1- end))) 2239 (text-properties-at (1- end)))
2233 (put-text-property (1- end) end 'rear-nonsticky t)) 2240 (put-text-property (1- end) end 'rear-nonsticky t))
2234 2241
2235 (if (eq yank-undo-function t) ;; not set by FUNCTION 2242 (if (eq yank-undo-function t) ;; not set by FUNCTION
2236 (setq yank-undo-function (nth 3 handler))) ;; UNDO 2243 (setq yank-undo-function (nth 3 handler))) ;; UNDO
2237 (if (nth 4 handler) ;; COMMAND 2244 (if (nth 4 handler) ;; COMMAND
2238 (setq this-command (nth 4 handler))))) 2245 (setq this-command (nth 4 handler)))))
2239 2246
2240 (defun insert-buffer-substring-no-properties (buffer &optional start end) 2247 (defun insert-buffer-substring-no-properties (buffer &optional start end)
2241 "Insert before point a substring of BUFFER, without text properties. 2248 "Insert before point a substring of BUFFER, without text properties.
2242 BUFFER may be a buffer or a buffer name. 2249 BUFFER may be a buffer or a buffer name.
2760 (if (eq (aref newstr i) fromchar) 2767 (if (eq (aref newstr i) fromchar)
2761 (aset newstr i tochar))) 2768 (aset newstr i tochar)))
2762 newstr)) 2769 newstr))
2763 2770
2764 (defun replace-regexp-in-string (regexp rep string &optional 2771 (defun replace-regexp-in-string (regexp rep string &optional
2765 fixedcase literal subexp start) 2772 fixedcase literal subexp start)
2766 "Replace all matches for REGEXP with REP in STRING. 2773 "Replace all matches for REGEXP with REP in STRING.
2767 2774
2768 Return a new string containing the replacements. 2775 Return a new string containing the replacements.
2769 2776
2770 Optional arguments FIXEDCASE, LITERAL and SUBEXP are like the 2777 Optional arguments FIXEDCASE, LITERAL and SUBEXP are like the
2810 (setq matches 2817 (setq matches
2811 (cons (replace-match (if (stringp rep) 2818 (cons (replace-match (if (stringp rep)
2812 rep 2819 rep
2813 (funcall rep (match-string 0 str))) 2820 (funcall rep (match-string 0 str)))
2814 fixedcase literal str subexp) 2821 fixedcase literal str subexp)
2815 (cons (substring string start mb) ; unmatched prefix 2822 (cons (substring string start mb) ; unmatched prefix
2816 matches))) 2823 matches)))
2817 (setq start me)) 2824 (setq start me))
2818 ;; Reconstruct a string from the pieces. 2825 ;; Reconstruct a string from the pieces.
2819 (setq matches (cons (substring string start l) matches)) ; leftover 2826 (setq matches (cons (substring string start l) matches)) ; leftover
2820 (apply #'concat (nreverse matches))))) 2827 (apply #'concat (nreverse matches)))))
2831 (cons element buffer-invisibility-spec))) 2838 (cons element buffer-invisibility-spec)))
2832 2839
2833 (defun remove-from-invisibility-spec (element) 2840 (defun remove-from-invisibility-spec (element)
2834 "Remove ELEMENT from `buffer-invisibility-spec'." 2841 "Remove ELEMENT from `buffer-invisibility-spec'."
2835 (if (consp buffer-invisibility-spec) 2842 (if (consp buffer-invisibility-spec)
2836 (setq buffer-invisibility-spec (delete element buffer-invisibility-spec)))) 2843 (setq buffer-invisibility-spec
2844 (delete element buffer-invisibility-spec))))
2837 2845
2838 ;;;; Syntax tables. 2846 ;;;; Syntax tables.
2839 2847
2840 (defmacro with-syntax-table (table &rest body) 2848 (defmacro with-syntax-table (table &rest body)
2841 "Evaluate BODY with syntax table of current buffer set to TABLE. 2849 "Evaluate BODY with syntax table of current buffer set to TABLE.
3177 Usually the separator is \".\", but it can be any other string.") 3185 Usually the separator is \".\", but it can be any other string.")
3178 3186
3179 3187
3180 (defvar version-regexp-alist 3188 (defvar version-regexp-alist
3181 '(("^[-_+ ]?a\\(lpha\\)?$" . -3) 3189 '(("^[-_+ ]?a\\(lpha\\)?$" . -3)
3182 ("^[-_+]$" . -3) ; treat "1.2.3-20050920" and "1.2-3" as alpha releases 3190 ("^[-_+]$" . -3) ; treat "1.2.3-20050920" and "1.2-3" as alpha releases
3183 ("^[-_+ ]cvs$" . -3) ; treat "1.2.3-CVS" as alpha release 3191 ("^[-_+ ]cvs$" . -3) ; treat "1.2.3-CVS" as alpha release
3184 ("^[-_+ ]?b\\(eta\\)?$" . -2) 3192 ("^[-_+ ]?b\\(eta\\)?$" . -2)
3185 ("^[-_+ ]?\\(pre\\|rc\\)$" . -1)) 3193 ("^[-_+ ]?\\(pre\\|rc\\)$" . -1))
3186 "*Specify association between non-numeric version part and a priority. 3194 "*Specify association between non-numeric version part and a priority.
3187 3195
3251 (or (and (stringp ver) (> (length ver) 0)) 3259 (or (and (stringp ver) (> (length ver) 0))
3252 (error "Invalid version string: '%s'" ver)) 3260 (error "Invalid version string: '%s'" ver))
3253 ;; Change .x.y to 0.x.y 3261 ;; Change .x.y to 0.x.y
3254 (if (and (>= (length ver) (length version-separator)) 3262 (if (and (>= (length ver) (length version-separator))
3255 (string-equal (substring ver 0 (length version-separator)) 3263 (string-equal (substring ver 0 (length version-separator))
3256 version-separator)) 3264 version-separator))
3257 (setq ver (concat "0" ver))) 3265 (setq ver (concat "0" ver)))
3258 (save-match-data 3266 (save-match-data
3259 (let ((i 0) 3267 (let ((i 0)
3260 (case-fold-search t) ; ignore case in matching 3268 (case-fold-search t) ; ignore case in matching
3261 lst s al) 3269 lst s al)