Please convert your programs to use `aref' with character-base index."
(let ((byte 0) (char 0))
(while (< byte byte-index)
- (setq byte (+ byte (char-bytes (aref string byte)))))
+ (setq byte (+ byte (char-bytes (aref string char)))
+ char (1+ char)))
(aref string char)))
;; Some programs still use this as a function.
(defalias 'search-forward-regexp (symbol-function 're-search-forward))
(defalias 'search-backward-regexp (symbol-function 're-search-backward))
(defalias 'int-to-string 'number-to-string)
-(defalias 'set-match-data 'store-match-data)
+(defalias 'store-match-data 'set-match-data)
;;; Should this be an obsolete name? If you decide it should, you get
;;; to go through all the sources and change them.
To make a hook variable buffer-local, always use
`make-local-hook', not `make-local-variable'."
(if (or (not (boundp hook)) ;unbound symbol, or
- (not (default-boundp 'hook))
+ (not (default-boundp hook))
(null (symbol-value hook)) ;value is nil, or
(null function)) ;function is nil, then
nil ;Do nothing.
into a hook function that will be run only after loading the package.
`eval-after-load' provides one way to do this. In some cases
other hooks, such as major mode hooks, can do the job."
- (or (member element (symbol-value list-var))
- (set list-var (cons element (symbol-value list-var)))))
+ (if (member element (symbol-value list-var))
+ (symbol-value list-var)
+ (set list-var (cons element (symbol-value list-var)))))
\f
;;;; Specifying things to do after certain files are loaded.
(setq first nil))
code))
-(defun read-password (prompt &optional default)
- "Read a password, echoing `.' for each character typed.
+(defun read-passwd (prompt &optional confirm default)
+ "Read a password, prompting with PROMPT. Echo `.' for each character typed.
End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line.
-Optional DEFAULT is password to start with."
- (let ((pass nil)
- (c 0)
- (echo-keystrokes 0)
- (cursor-in-echo-area t))
- (while (progn (message "%s%s"
- prompt
- (make-string (length pass) ?.))
- (setq c (read-char))
- (and (/= c ?\r) (/= c ?\n) (/= c ?\e)))
- (if (= c ?\C-u)
- (setq pass "")
- (if (and (/= c ?\b) (/= c ?\177))
- (setq pass (concat pass (char-to-string c)))
- (if (> (length pass) 0)
- (setq pass (substring pass 0 -1))))))
- (message nil)
- (or pass default "")))
+Optional argument CONFIRM, if non-nil, then read it twice to make sure.
+Optional DEFAULT is a default password to use instead of empty input."
+ (if confirm
+ (let (success)
+ (while (not success)
+ (let ((first (read-passwd prompt nil default))
+ (second (read-passwd "Confirm password: " nil default)))
+ (if (equal first second)
+ (setq success first)
+ (message "Password not repeated accurately; please start over")
+ (sit-for 1))))
+ success)
+ (let ((pass nil)
+ (c 0)
+ (echo-keystrokes 0)
+ (cursor-in-echo-area t))
+ (while (progn (message "%s%s"
+ prompt
+ (make-string (length pass) ?.))
+ (setq c (read-char))
+ (and (/= c ?\r) (/= c ?\n) (/= c ?\e)))
+ (if (= c ?\C-u)
+ (setq pass "")
+ (if (and (/= c ?\b) (/= c ?\177))
+ (setq pass (concat pass (char-to-string c)))
+ (if (> (length pass) 0)
+ (setq pass (substring pass 0 -1))))))
+ (message nil)
+ (or pass default ""))))
\f
(defun force-mode-line-update (&optional all)
"Force the mode-line of the current buffer to be redisplayed.
(insert-before-markers string)
(setq insert-end (point))
;; If the message end is off screen, recenter now.
- (if (< (window-end) insert-end)
+ (if (< (window-end nil t) insert-end)
(recenter (/ (window-height) 2)))
;; If that pushed message start off the screen,
;; scroll to start it at the top of the screen.
`(let ((save-match-data-internal (match-data)))
(unwind-protect
(progn ,@body)
- (store-match-data save-match-data-internal))))
+ (set-match-data save-match-data-internal))))
(defun match-string (num &optional string)
"Return string of text matched by last search.
(interactive "KSet key globally: \nCSet key %s to command: ")
(or (vectorp key) (stringp key)
(signal 'wrong-type-argument (list 'arrayp key)))
- (define-key (current-global-map) key command)
- nil)
+ (define-key (current-global-map) key command))
(defun local-set-key (key command)
"Give KEY a local binding as COMMAND.
(use-local-map (setq map (make-sparse-keymap))))
(or (vectorp key) (stringp key)
(signal 'wrong-type-argument (list 'arrayp key)))
- (define-key map key command))
- nil)
+ (define-key map key command)))
(defun global-unset-key (key)
"Remove global binding of KEY.