(setq tail (cdr tail))))
list)
+;; See http://lists.gnu.org/archive/html/emacs-devel/2013-05/msg00204.html
+(defun delete-consecutive-dups (list &optional circular)
+ "Destructively remove `equal' consecutive duplicates from LIST.
+First and last elements are considered consecutive if CIRCULAR is
+non-nil."
+ (let ((tail list) last)
+ (while (consp tail)
+ (if (equal (car tail) (cadr tail))
+ (setcdr tail (cddr tail))
+ (setq last (car tail)
+ tail (cdr tail))))
+ (if (and circular
+ (cdr list)
+ (equal last (car list)))
+ (nbutlast list)
+ list)))
+
(defun number-sequence (from &optional to inc)
"Return a sequence of numbers from FROM to TO (both inclusive) as a list.
INC is the increment used between numbers in the sequence and defaults to 1.
;; And of course, don't keep the sensitive data around.
(erase-buffer))))))))
-;; This should be used by `call-interactively' for `n' specs.
(defun read-number (prompt &optional default)
"Read a numeric value in the minibuffer, prompting with PROMPT.
DEFAULT specifies a default value to return if the user just types RET.
-The value of DEFAULT is inserted into PROMPT."
+The value of DEFAULT is inserted into PROMPT.
+This function is used by the `interactive' code letter `n'."
(let ((n nil)
(default1 (if (consp default) (car default) default)))
(when default1
(condition-case nil
(setq n (cond
((zerop (length str)) default1)
- ((stringp str) (string-to-number str))))
+ ((stringp str) (read str))))
(error nil)))
(unless (numberp n)
(message "Please enter a number.")
Note that this should end with a directory separator.
See also `locate-user-emacs-file'.")
+(custom-declare-variable-early 'user-emacs-directory-warning t
+ "Non-nil means warn if cannot access `user-emacs-directory'.
+Set this to nil at your own risk..."
+ :type 'boolean
+ :group 'initialization
+ :version "24.4")
+
(defun locate-user-emacs-file (new-name &optional old-name)
"Return an absolute per-user Emacs-specific file name.
If NEW-NAME exists in `user-emacs-directory', return it.
(file-readable-p at-home))
at-home
;; Make sure `user-emacs-directory' exists,
- ;; unless we're in batch mode or dumping Emacs
+ ;; unless we're in batch mode or dumping Emacs.
(or noninteractive
purify-flag
- (file-accessible-directory-p
- (directory-file-name user-emacs-directory))
- (let ((umask (default-file-modes)))
- (unwind-protect
- (progn
- (set-default-file-modes ?\700)
- (make-directory user-emacs-directory))
- (set-default-file-modes umask))))
+ (let (errtype)
+ (if (file-directory-p user-emacs-directory)
+ (or (file-accessible-directory-p user-emacs-directory)
+ (setq errtype "access"))
+ (let ((umask (default-file-modes)))
+ (unwind-protect
+ (progn
+ (set-default-file-modes ?\700)
+ (condition-case nil
+ (make-directory user-emacs-directory)
+ (error (setq errtype "create"))))
+ (set-default-file-modes umask))))
+ (when (and errtype
+ user-emacs-directory-warning
+ (not (get 'user-emacs-directory-warning 'this-session)))
+ ;; Only warn once per Emacs session.
+ (put 'user-emacs-directory-warning 'this-session t)
+ (display-warning 'initialization
+ (format "\
+Unable to %s `user-emacs-directory' (%s).
+Any data that would normally be written there may be lost!
+If you never want to see this message again,
+customize the variable `user-emacs-directory-warning'."
+ errtype user-emacs-directory)))))
bestname))))
\f
;;;; Misc. useful functions.
"Return non-nil if the current buffer is narrowed."
(/= (- (point-max) (point-min)) (buffer-size)))
-(defun find-tag-default ()
- "Determine default tag to search for, based on text at point.
+(defun find-tag-default-bounds ()
+ "Determine the boundaries of the default tag, based on text at point.
+Return a cons cell with the beginning and end of the found tag.
If there is no plausible default, return nil."
(let (from to bound)
(when (or (progn
(< (setq from (point)) bound)
(skip-syntax-forward "w_")
(setq to (point)))))
- (buffer-substring-no-properties from to))))
+ (cons from to))))
+
+(defun find-tag-default ()
+ "Determine default tag to search for, based on text at point.
+If there is no plausible default, return nil."
+ (let ((bounds (find-tag-default-bounds)))
+ (when bounds
+ (buffer-substring-no-properties (car bounds) (cdr bounds)))))
(defun find-tag-default-as-regexp ()
"Return regexp that matches the default tag at point.
(get major-mode 'find-tag-default-function)
'find-tag-default))
(tag (funcall tagf)))
- (cond ((not tag))
+ (cond ((null tag) nil)
((eq tagf 'find-tag-default)
(format "\\_<%s\\_>" (regexp-quote tag)))
(t (regexp-quote tag)))))
\f
;;;; Support for watching filesystem events.
-(defun inotify-event-p (event)
- "Check if EVENT is an inotify event."
- (and (listp event)
- (>= (length event) 3)
- (eq (car event) 'file-inotify)))
-
-;;;###autoload
-(defun inotify-handle-event (event)
- "Handle inotify file system monitoring event.
-If EVENT is an inotify filewatch event, call its callback.
-Otherwise, signal a `filewatch-error'."
- (interactive "e")
- (unless (inotify-event-p event)
- (signal 'filewatch-error (cons "Not a valid inotify event" event)))
- (funcall (nth 2 event) (nth 1 event)))
-
-(defun w32notify-handle-event (event)
- "Handle MS-Windows file system monitoring event.
-If EVENT is an MS-Windows filewatch event, call its callback.
+(defun file-notify-handle-event (event)
+ "Handle file system monitoring event.
+If EVENT is a filewatch event, call its callback.
Otherwise, signal a `filewatch-error'."
(interactive "e")
- (if (and (eq (car event) 'file-w32notify)
- (= (length event) 3))
+ (if (and (eq (car event) 'file-notify)
+ (>= (length event) 3))
(funcall (nth 2 event) (nth 1 event))
(signal 'filewatch-error
- (cons "Not a valid MS-Windows file-notify event" event))))
+ (cons "Not a valid file-notify event" event))))
\f
;;;; Comparing version strings.
(prin1-to-string (make-hash-table)))))
(provide 'hashtable-print-readable))
-;; This is used in lisp/Makefile.in to generate file names for
-;; autoloads, custom-deps, and finder-data.
-(defun reveal-filename (file)
- "Produce the real file name for FILE.
+;; This is used in lisp/Makefile.in and in leim/Makefile.in to
+;; generate file names for autoloads, custom-deps, and finder-data.
+(defun unmsys--file-name (file)
+ "Produce the canonical file name for FILE from its MSYS form.
On systems other than MS-Windows, just returns FILE.
On MS-Windows, converts /d/foo/bar form of file names
passed by MSYS Make into d:/foo/bar that Emacs can grok.
-This function is called from lisp/Makefile."
+This function is called from lisp/Makefile and leim/Makefile."
(when (and (eq system-type 'windows-nt)
(string-match "\\`/[a-zA-Z]/" file))
(setq file (concat (substring file 1 2) ":" (substring file 2))))