------------------------------------------------------------ revno: 117109 committer: Katsumi Yamaoka branch nick: trunk timestamp: Thu 2014-05-15 06:53:44 +0000 message: lisp/gnus/gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part): Don't delete next part button; keep spacing between buttons diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2014-05-14 08:50:51 +0000 +++ lisp/gnus/ChangeLog 2014-05-15 06:53:44 +0000 @@ -1,3 +1,8 @@ +2014-05-15 Katsumi Yamaoka + + * gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part): Don't + delete next part button; keep spacing between buttons. + 2014-05-14 Katsumi Yamaoka * gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part): === modified file 'lisp/gnus/gnus-art.el' --- lisp/gnus/gnus-art.el 2014-05-14 08:50:51 +0000 +++ lisp/gnus/gnus-art.el 2014-05-15 06:53:44 +0000 @@ -5311,14 +5311,14 @@ (text-property-any (point-min) (point) 'gnus-data handle))) (setq handle (get-text-property b 'gnus-data)) b)) - contents charset coding-system) + start contents charset coding-system) (when handle (when (= b (prog1 btn - (setq btn (previous-single-property-change - (or (next-single-property-change btn 'gnus-data) - (point-max)) - 'gnus-data)))) + (setq start (next-single-property-change btn 'gnus-data + nil (point-max)) + btn (previous-single-property-change start + 'gnus-data)))) (setq b btn)) (if (and (not arg) (mm-handle-undisplayer handle)) (mm-remove-part handle) @@ -5345,25 +5345,29 @@ (mm-read-coding-system "Charset: ")))) ((mm-handle-undisplayer handle) (mm-remove-part handle))) - (forward-line 1) + (goto-char start) (mm-display-inline handle)) ;; Toggle the button appearance between `[button]...' and `[button]'. (goto-char btn) - (gnus-insert-mime-button handle (get-text-property btn 'gnus-part) - (list (mm-handle-displayed-p handle))) - (if (featurep 'emacs) - (delete-region - (point) - (or (text-property-any (point) (point-max) 'gnus-data nil) - (point-max))) - (let* ((end (text-property-any (point) (point-max) 'gnus-data nil)) - (annots (annotations-at end))) - (delete-region (point) - (if end - (if annots (1+ end) end) - (point-max))) - (dolist (annot annots) - (set-extent-endpoints annot (point) (point))))) + (let ((displayed-p (mm-handle-displayed-p handle))) + (gnus-insert-mime-button handle (get-text-property btn 'gnus-part) + (list displayed-p)) + (if (featurep 'emacs) + (delete-region + (point) + (next-single-property-change (point) 'gnus-data nil (point-max))) + (let* ((end (next-single-property-change (point) 'gnus-data)) + (annots (annotations-at (or end (point-max))))) + (delete-region (point) + (if end + (if annots (1+ end) end) + (point-max))) + (dolist (annot annots) + (set-extent-endpoints annot (point) (point))))) + (unless (or displayed-p (eolp)) + ;; Add extra newline. + (insert (propertize (buffer-substring (1- (point)) (point)) + 'gnus-undeletable t)))) (unless (search-backward "\n\n" nil t) ;; We're in the article header. (delete-char -1) @@ -5686,17 +5690,16 @@ (with-current-buffer gnus-summary-buffer gnus-newsgroup-ignored-charsets) nil)) - retval) + start retval) (unwind-protect (progn (let ((win (gnus-get-buffer-window (current-buffer) t))) (when win (select-window win) (goto-char point))) - (setq point (previous-single-property-change - (or (next-single-property-change point 'gnus-data) - (point-max)) - 'gnus-data)) + (setq start (next-single-property-change point 'gnus-data + nil (point-max)) + point (previous-single-property-change start 'gnus-data)) (if (mm-handle-displayed-p handle) ;; This will remove the part. (setq retval (mm-display-part handle)) @@ -5708,7 +5711,7 @@ (setq retval (mm-display-part handle))) (unless (zerop (buffer-size)) (buffer-string)))))) - (forward-line) + (goto-char start) (cond ((stringp part) (save-restriction (narrow-to-region (point) @@ -5729,20 +5732,24 @@ (mm-display-inline handle)))))) (goto-char point) ;; Toggle the button appearance between `[button]...' and `[button]'. - (gnus-insert-mime-button handle id (list (mm-handle-displayed-p handle))) - (if (featurep 'emacs) - (delete-region - (point) - (or (text-property-any (point) (point-max) 'gnus-data nil) - (point-max))) - (let* ((end (text-property-any (point) (point-max) 'gnus-data nil)) - (annots (annotations-at end))) - (delete-region (point) - (if end - (if annots (1+ end) end) - (point-max))) - (dolist (annot annots) - (set-extent-endpoints annot (point) (point))))) + (let ((displayed-p (mm-handle-displayed-p handle))) + (gnus-insert-mime-button handle id (list displayed-p)) + (if (featurep 'emacs) + (delete-region + (point) + (next-single-property-change (point) 'gnus-data nil (point-max))) + (let* ((end (next-single-property-change (point) 'gnus-data)) + (annots (annotations-at (or end (point-max))))) + (delete-region (point) + (if end + (if annots (1+ end) end) + (point-max))) + (dolist (annot annots) + (set-extent-endpoints annot (point) (point))))) + (unless (or displayed-p (eolp)) + ;; Add extra newline. + (insert (propertize (buffer-substring (1- (point)) (point)) + 'gnus-undeletable t)))) (unless (search-backward "\n\n" nil t) ;; We're in the article header. (delete-char -1) ------------------------------------------------------------ revno: 117108 committer: Dmitry Antipov branch nick: trunk timestamp: Thu 2014-05-15 10:01:46 +0400 message: * src/fns.c (Freverse): Allow vectors, bool vectors and strings. * doc/lispref/lists.texi (Building Cons Cells and Lists): Remove description of `reverse' and generalize it... * doc/lispref/sequences.texi (Sequences): ...for sequences here. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2014-05-14 17:15:15 +0000 +++ doc/lispref/ChangeLog 2014-05-15 06:01:46 +0000 @@ -1,3 +1,9 @@ +2014-05-15 Dmitry Antipov + + * lists.texi (Building Cons Cells and Lists): Remove + description of `reverse' and generalize it... + * sequences.texi (Sequences): ...for sequences here. + 2014-05-14 Glenn Morris * files.texi (Changing Files): Mention with-file-modes. === modified file 'doc/lispref/lists.texi' --- doc/lispref/lists.texi 2014-03-18 01:19:03 +0000 +++ doc/lispref/lists.texi 2014-05-15 06:01:46 +0000 @@ -601,25 +601,6 @@ resulting list. Instead, the sequence becomes the final @sc{cdr}, like any other non-list final argument. -@defun reverse list -This function creates a new list whose elements are the elements of -@var{list}, but in reverse order. The original argument @var{list} is -@emph{not} altered. - -@example -@group -(setq x '(1 2 3 4)) - @result{} (1 2 3 4) -@end group -@group -(reverse x) - @result{} (4 3 2 1) -x - @result{} (1 2 3 4) -@end group -@end example -@end defun - @defun copy-tree tree &optional vecp This function returns a copy of the tree @code{tree}. If @var{tree} is a cons cell, this makes a new cons cell with the same @sc{car} and === modified file 'doc/lispref/sequences.texi' --- doc/lispref/sequences.texi 2014-03-09 11:36:51 +0000 +++ doc/lispref/sequences.texi 2014-05-15 06:01:46 +0000 @@ -217,6 +217,49 @@ @end example @end defun +@defun reverse seq +@cindex string reverse +@cindex list reverse +@cindex vector reverse +@cindex sequence reverse +This function creates a new sequence whose elements are the elements +of @var{seq}, but in reverse order. The original argument @var{seq} +is @emph{not} altered. Note that char-table cannot be reversed. + +@example +@group +(setq x '(1 2 3 4)) + @result{} (1 2 3 4) +@end group +@group +(reverse x) + @result{} (4 3 2 1) +x + @result{} (1 2 3 4) +@end group +@group +(setq x [1 2 3 4]) + @result{} [1 2 3 4] +@end group +@group +(reverse x) + @result{} [4 3 2 1] +x + @result{} [1 2 3 4] +@end group +@group +(setq x "xyzzy") + @result{} "xyzzy" +@end group +@group +(reverse x) + @result{} "yzzyx" +x + @result{} "xyzzy" +@end group +@end example +@end defun + @node Arrays @section Arrays @cindex array === modified file 'src/ChangeLog' --- src/ChangeLog 2014-05-14 13:55:37 +0000 +++ src/ChangeLog 2014-05-15 06:01:46 +0000 @@ -1,3 +1,7 @@ +2014-05-15 Dmitry Antipov + + * fns.c (Freverse): Allow vectors, bool vectors and strings. + 2014-05-14 Dmitry Antipov Minor cleanup for terminal setup. === modified file 'src/fns.c' --- src/fns.c 2014-04-01 20:18:12 +0000 +++ src/fns.c 2014-05-15 06:01:46 +0000 @@ -1719,18 +1719,70 @@ } DEFUN ("reverse", Freverse, Sreverse, 1, 1, 0, - doc: /* Reverse LIST, copying. Return the reversed list. + doc: /* Return the reversed copy of list, vector, or string SEQ. See also the function `nreverse', which is used more often. */) - (Lisp_Object list) + (Lisp_Object seq) { Lisp_Object new; - for (new = Qnil; CONSP (list); list = XCDR (list)) - { - QUIT; - new = Fcons (XCAR (list), new); - } - CHECK_LIST_END (list, list); + if (NILP (seq)) + return Qnil; + else if (CONSP (seq)) + { + for (new = Qnil; CONSP (seq); seq = XCDR (seq)) + { + QUIT; + new = Fcons (XCAR (seq), new); + } + CHECK_LIST_END (seq, seq); + } + else if (VECTORP (seq)) + { + ptrdiff_t i, size = ASIZE (seq); + + new = make_uninit_vector (size); + for (i = 0; i < size; i++) + ASET (new, i, AREF (seq, size - i - 1)); + } + else if (BOOL_VECTOR_P (seq)) + { + ptrdiff_t i; + EMACS_INT nbits = bool_vector_size (seq); + + new = make_uninit_bool_vector (nbits); + for (i = 0; i < nbits; i++) + bool_vector_set (new, i, bool_vector_bitref (seq, nbits - i - 1)); + } + else if (STRINGP (seq)) + { + ptrdiff_t size = SCHARS (seq), bytes = SBYTES (seq); + + if (size == bytes) + { + ptrdiff_t i; + + new = make_uninit_string (size); + for (i = 0; i < size; i++) + SSET (new, i, SREF (seq, size - i - 1)); + } + else + { + unsigned char *p, *q; + + new = make_uninit_multibyte_string (size, bytes); + p = SDATA (seq), q = SDATA (new) + bytes; + while (q > SDATA (new)) + { + int ch, len; + + ch = STRING_CHAR_AND_LENGTH (p, len); + p += len, q -= len; + CHAR_STRING (ch, q); + } + } + } + else + wrong_type_argument (Qsequencep, seq); return new; } ------------------------------------------------------------ revno: 117107 committer: Sam Steingold branch nick: trunk timestamp: Wed 2014-05-14 14:17:05 -0400 message: avoid unnecessary questions * lisp/progmodes/python.el (python-shell-get-or-create-process): Do not bind `current-prefix-arg' so that C-c C-z does not talk back unless requested. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-05-14 17:15:15 +0000 +++ lisp/ChangeLog 2014-05-14 18:17:05 +0000 @@ -1,3 +1,9 @@ +2014-05-14 Sam Steingold + + * progmodes/python.el (python-shell-get-or-create-process): + Do not bind `current-prefix-arg' so that C-c C-z does not talk + back unless requested. + 2014-05-14 Glenn Morris * subr.el (with-file-modes): New macro. === modified file 'lisp/progmodes/python.el' --- lisp/progmodes/python.el 2014-04-06 23:23:45 +0000 +++ lisp/progmodes/python.el 2014-05-14 18:17:05 +0000 @@ -2058,8 +2058,7 @@ (global-proc-name (python-shell-get-process-name nil)) (global-proc-buffer-name (format "*%s*" global-proc-name)) (dedicated-running (comint-check-proc dedicated-proc-buffer-name)) - (global-running (comint-check-proc global-proc-buffer-name)) - (current-prefix-arg 16)) + (global-running (comint-check-proc global-proc-buffer-name))) (when (and (not dedicated-running) (not global-running)) (if (call-interactively 'run-python) (setq dedicated-running t) ------------------------------------------------------------ revno: 117106 committer: Glenn Morris branch nick: trunk timestamp: Wed 2014-05-14 10:15:15 -0700 message: Add with-file-modes macro, and use it * lisp/subr.el (with-file-modes): New macro. * lisp/printing.el (pr-save-file-modes): * lisp/eshell/esh-util.el (eshell-with-file-modes): Make obsolete. * lisp/emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-2): Add with-file-modes. * lisp/doc-view.el (doc-view-make-safe-dir): * lisp/epg.el (epg--start): * lisp/files.el (locate-user-emacs-file, make-temp-file) (backup-buffer-copy, move-file-to-trash): * printing.el (pr-despool-print, pr-call-process, pr-text2ps): * eshell/esh-util.el (eshell-with-private-file-modes) (eshell-make-private-directory): * lisp/net/browse-url.el (browse-url-mosaic): * lisp/obsolete/mailpost.el (post-mail-send-it): * lisp/obsolete/pgg-pgp.el (pgg-pgp-verify-region): * lisp/obsolete/pgg-pgp5.el (pgg-pgp5-verify-region): * lisp/url/url-util.el (url-make-private-file): Use with-file-modes. * doc/lispref/files.texi (Changing Files): Mention with-file-modes. * etc/NEWS: Mention this. diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2014-05-08 03:41:21 +0000 +++ doc/lispref/ChangeLog 2014-05-14 17:15:15 +0000 @@ -1,3 +1,7 @@ +2014-05-14 Glenn Morris + + * files.texi (Changing Files): Mention with-file-modes. + 2014-05-08 Paul Eggert * internals.texi (C Dialect): New section. === modified file 'doc/lispref/files.texi' --- doc/lispref/files.texi 2014-03-26 15:57:13 +0000 +++ doc/lispref/files.texi 2014-05-14 17:15:15 +0000 @@ -1688,6 +1688,16 @@ permissions. @end defun +@defmac with-file-modes mode body@dots{} +This macro evaluates the @var{body} forms with the default +permissions for new files temporarily set to @var{modes} (whose value +is as for @code{set-file-modes} above). When finished, it restores +the original default file permissions, and returns the value of the +last form in @var{body}. + +This is useful for creating private files, for example. +@end defmac + @defun default-file-modes This function returns the default file permissions, as an integer. @end defun === modified file 'etc/NEWS' --- etc/NEWS 2014-05-04 23:49:33 +0000 +++ etc/NEWS 2014-05-14 17:15:15 +0000 @@ -122,6 +122,10 @@ *** (side-effect-free VAL), if VAL is non-nil, indicates the function does not have side effects. ++++ +** New macro `with-file-modes', for evaluating expressions with default file +permissions set to temporary values (e.g., for creating private files). + ** You can access the slots of structures using `cl-struct-slot-value'. === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-05-14 17:05:16 +0000 +++ lisp/ChangeLog 2014-05-14 17:15:15 +0000 @@ -1,5 +1,23 @@ 2014-05-14 Glenn Morris + * subr.el (with-file-modes): New macro. + * printing.el (pr-save-file-modes): Make obsolete. + * eshell/esh-util.el (eshell-with-file-modes): Make obsolete. + * emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-2): + Add with-file-modes. + * doc-view.el (doc-view-make-safe-dir): + * epg.el (epg--start): + * files.el (locate-user-emacs-file, make-temp-file) + (backup-buffer-copy, move-file-to-trash): + * printing.el (pr-despool-print, pr-call-process, pr-text2ps): + * eshell/esh-util.el (eshell-with-private-file-modes) + (eshell-make-private-directory): + * net/browse-url.el (browse-url-mosaic): + * obsolete/mailpost.el (post-mail-send-it): + * obsolete/pgg-pgp.el (pgg-pgp-verify-region): + * obsolete/pgg-pgp5.el (pgg-pgp5-verify-region): + Use with-file-modes. + * vc/emerge.el (emerge-make-temp-file): Simplify. 2014-05-14 Stephen Berman === modified file 'lisp/doc-view.el' --- lisp/doc-view.el 2014-04-17 03:58:25 +0000 +++ lisp/doc-view.el 2014-05-14 17:15:15 +0000 @@ -654,16 +654,10 @@ (defun doc-view-make-safe-dir (dir) (condition-case nil - (let ((umask (default-file-modes))) - (unwind-protect - (progn - ;; Create temp files with strict access rights. It's easy to - ;; loosen them later, whereas it's impossible to close the - ;; time-window of loose permissions otherwise. - (set-default-file-modes #o0700) - (make-directory dir)) - ;; Reset the umask. - (set-default-file-modes umask))) + ;; Create temp files with strict access rights. It's easy to + ;; loosen them later, whereas it's impossible to close the + ;; time-window of loose permissions otherwise. + (with-file-modes #o0700 (make-directory dir)) (file-already-exists (when (file-symlink-p dir) (error "Danger: %s points to a symbolic link" dir)) === modified file 'lisp/emacs-lisp/lisp-mode.el' --- lisp/emacs-lisp/lisp-mode.el 2014-05-11 03:48:15 +0000 +++ lisp/emacs-lisp/lisp-mode.el 2014-05-14 17:15:15 +0000 @@ -208,6 +208,7 @@ "with-category-table" "with-coding-priority" "with-current-buffer" "with-demoted-errors" "with-electric-help" "with-eval-after-load" + "with-file-modes" "with-local-quit" "with-no-warnings" "with-output-to-temp-buffer" "with-selected-window" "with-selected-frame" "with-silent-modifications" === modified file 'lisp/epg.el' --- lisp/epg.el 2014-01-06 06:25:30 +0000 +++ lisp/epg.el 2014-05-14 17:15:15 +0000 @@ -1206,7 +1206,6 @@ (coding-system-for-read 'binary) process-connection-type (process-environment process-environment) - (orig-mode (default-file-modes)) (buffer (generate-new-buffer " *epg*")) process terminal-name @@ -1265,14 +1264,9 @@ (setq epg-agent-file agent-file) (make-local-variable 'epg-agent-mtime) (setq epg-agent-mtime agent-mtime)) - (unwind-protect - (progn - (set-default-file-modes 448) - (setq process - (apply #'start-process "epg" buffer - (epg-context-program context) - args))) - (set-default-file-modes orig-mode)) + (with-file-modes 448 + (setq process (apply #'start-process "epg" buffer + (epg-context-program context) args))) (set-process-filter process #'epg--process-filter) (epg-context-set-process context process))) === modified file 'lisp/eshell/esh-util.el' --- lisp/eshell/esh-util.el 2014-01-01 07:43:34 +0000 +++ lisp/eshell/esh-util.el 2014-05-14 17:15:15 +0000 @@ -539,20 +539,17 @@ (defmacro eshell-with-file-modes (modes &rest forms) "Evaluate, with file-modes set to MODES, the given FORMS." - `(let ((modes (default-file-modes))) - (set-default-file-modes ,modes) - (unwind-protect - (progn ,@forms) - (set-default-file-modes modes)))) + (declare (obsolete with-file-modes "24.5")) + `(with-file-modes ,modes ,@forms)) (defmacro eshell-with-private-file-modes (&rest forms) "Evaluate FORMS with private file modes set." - `(eshell-with-file-modes ,eshell-private-file-modes ,@forms)) + `(with-file-modes ,eshell-private-file-modes ,@forms)) (defsubst eshell-make-private-directory (dir &optional parents) "Make DIR with file-modes set to `eshell-private-directory-modes'." - (eshell-with-file-modes eshell-private-directory-modes - (make-directory dir parents))) + (with-file-modes eshell-private-directory-modes + (make-directory dir parents))) (defsubst eshell-substring (string sublen) "Return the beginning of STRING, up to SUBLEN bytes." === modified file 'lisp/files.el' --- lisp/files.el 2014-05-12 06:59:30 +0000 +++ lisp/files.el 2014-05-14 17:15:15 +0000 @@ -941,14 +941,10 @@ (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)))) + (with-file-modes ?\700 + (condition-case nil + (make-directory user-emacs-directory) + (error (setq errtype "create"))))) (when (and errtype user-emacs-directory-warning (not (get 'user-emacs-directory-warning 'this-session))) @@ -1273,36 +1269,31 @@ If DIR-FLAG is non-nil, create a new empty directory instead of a file. If SUFFIX is non-nil, add that at the end of the file name." - (let ((umask (default-file-modes)) - file) - (unwind-protect - (progn - ;; Create temp files with strict access rights. It's easy to - ;; loosen them later, whereas it's impossible to close the - ;; time-window of loose permissions otherwise. - (set-default-file-modes ?\700) - (while (condition-case () - (progn - (setq file - (make-temp-name - (if (zerop (length prefix)) - (file-name-as-directory - temporary-file-directory) - (expand-file-name prefix - temporary-file-directory)))) - (if suffix - (setq file (concat file suffix))) - (if dir-flag - (make-directory file) - (write-region "" nil file nil 'silent nil 'excl)) - nil) - (file-already-exists t)) - ;; the file was somehow created by someone else between - ;; `make-temp-name' and `write-region', let's try again. - nil) - file) - ;; Reset the umask. - (set-default-file-modes umask)))) + ;; Create temp files with strict access rights. It's easy to + ;; loosen them later, whereas it's impossible to close the + ;; time-window of loose permissions otherwise. + (with-file-modes ?\700 + (let (file) + (while (condition-case () + (progn + (setq file + (make-temp-name + (if (zerop (length prefix)) + (file-name-as-directory + temporary-file-directory) + (expand-file-name prefix + temporary-file-directory)))) + (if suffix + (setq file (concat file suffix))) + (if dir-flag + (make-directory file) + (write-region "" nil file nil 'silent nil 'excl)) + nil) + (file-already-exists t)) + ;; the file was somehow created by someone else between + ;; `make-temp-name' and `write-region', let's try again. + nil) + file))) (defun recode-file-name (file coding new-coding &optional ok-if-already-exists) "Change the encoding of FILE's name from CODING to NEW-CODING. @@ -4071,31 +4062,26 @@ (file-error nil)))))) (defun backup-buffer-copy (from-name to-name modes extended-attributes) - (let ((umask (default-file-modes))) - (unwind-protect - (progn - ;; Create temp files with strict access rights. It's easy to - ;; loosen them later, whereas it's impossible to close the - ;; time-window of loose permissions otherwise. - (set-default-file-modes ?\700) - (when (condition-case nil - ;; Try to overwrite old backup first. - (copy-file from-name to-name t t t) - (error t)) - (while (condition-case nil - (progn - (when (file-exists-p to-name) - (delete-file to-name)) - (copy-file from-name to-name nil t t) - nil) - (file-already-exists t)) - ;; The file was somehow created by someone else between - ;; `delete-file' and `copy-file', so let's try again. - ;; rms says "I think there is also a possible race - ;; condition for making backup files" (emacs-devel 20070821). - nil))) - ;; Reset the umask. - (set-default-file-modes umask))) + ;; Create temp files with strict access rights. It's easy to + ;; loosen them later, whereas it's impossible to close the + ;; time-window of loose permissions otherwise. + (with-file-modes ?\700 + (when (condition-case nil + ;; Try to overwrite old backup first. + (copy-file from-name to-name t t t) + (error t)) + (while (condition-case nil + (progn + (when (file-exists-p to-name) + (delete-file to-name)) + (copy-file from-name to-name nil t t) + nil) + (file-already-exists t)) + ;; The file was somehow created by someone else between + ;; `delete-file' and `copy-file', so let's try again. + ;; rms says "I think there is also a possible race + ;; condition for making backup files" (emacs-devel 20070821). + nil))) ;; If set-file-extended-attributes fails, fall back on set-file-modes. (unless (and extended-attributes (with-demoted-errors @@ -6863,15 +6849,11 @@ trash-info-dir filename)) ;; Ensure that the trash directory exists; otherwise, create it. - (let ((saved-default-file-modes (default-file-modes))) - (unwind-protect - (progn - (set-default-file-modes #o700) - (unless (file-exists-p trash-files-dir) - (make-directory trash-files-dir t)) - (unless (file-exists-p trash-info-dir) - (make-directory trash-info-dir t))) - (set-default-file-modes saved-default-file-modes))) + (with-file-modes #o700 + (unless (file-exists-p trash-files-dir) + (make-directory trash-files-dir t)) + (unless (file-exists-p trash-info-dir) + (make-directory trash-info-dir t))) ;; Try to move to trash with .trashinfo undo information (save-excursion === modified file 'lisp/net/browse-url.el' --- lisp/net/browse-url.el 2014-05-13 08:54:08 +0000 +++ lisp/net/browse-url.el 2014-05-14 17:15:15 +0000 @@ -1343,16 +1343,12 @@ "newwin\n" "goto\n") url "\n") - (let ((umask (default-file-modes))) - (unwind-protect - (progn - (set-default-file-modes ?\700) - (if (file-exists-p - (setq pidfile (format "/tmp/Mosaic.%d" pid))) - (delete-file pidfile)) - ;; http://debbugs.gnu.org/17428. Use O_EXCL. - (write-region nil nil pidfile nil 'silent nil 'excl)) - (set-default-file-modes umask)))) + (with-file-modes ?\700 + (if (file-exists-p + (setq pidfile (format "/tmp/Mosaic.%d" pid))) + (delete-file pidfile)) + ;; http://debbugs.gnu.org/17428. Use O_EXCL. + (write-region nil nil pidfile nil 'silent nil 'excl))) ;; Send signal SIGUSR to Mosaic (message "Signaling Mosaic...") (signal-process pid 'SIGUSR1) === modified file 'lisp/obsolete/mailpost.el' --- lisp/obsolete/mailpost.el 2014-02-10 01:34:22 +0000 +++ lisp/obsolete/mailpost.el 2014-05-14 17:15:15 +0000 @@ -75,12 +75,7 @@ (if mail-interactive (with-current-buffer errbuf (erase-buffer)))) - (let ((m (default-file-modes))) - (unwind-protect - (progn - (set-default-file-modes 384) - (setq temfile (make-temp-file ",rpost"))) - (set-default-file-modes m))) + (with-file-modes 384 (setq temfile (make-temp-file ",rpost"))) (apply 'call-process (append (list (if (boundp 'post-mail-program) post-mail-program === modified file 'lisp/obsolete/pgg-pgp.el' --- lisp/obsolete/pgg-pgp.el 2014-01-01 07:43:34 +0000 +++ lisp/obsolete/pgg-pgp.el 2014-05-14 17:15:15 +0000 @@ -202,15 +202,11 @@ (defun pgg-pgp-verify-region (start end &optional signature) "Verify region between START and END as the detached signature SIGNATURE." (let* ((orig-file (pgg-make-temp-file "pgg")) - (args "+verbose=1 +batchmode +language=us") - (orig-mode (default-file-modes))) - (unwind-protect - (progn - (set-default-file-modes 448) - (let ((coding-system-for-write 'binary) - jka-compr-compression-info-list jam-zcat-filename-list) - (write-region start end orig-file))) - (set-default-file-modes orig-mode)) + (args "+verbose=1 +batchmode +language=us")) + (with-file-modes 448 + (let ((coding-system-for-write 'binary) + jka-compr-compression-info-list jam-zcat-filename-list) + (write-region start end orig-file))) (if (stringp signature) (progn (copy-file signature (setq signature (concat orig-file ".asc"))) === modified file 'lisp/obsolete/pgg-pgp5.el' --- lisp/obsolete/pgg-pgp5.el 2014-01-01 07:43:34 +0000 +++ lisp/obsolete/pgg-pgp5.el 2014-05-14 17:15:15 +0000 @@ -208,15 +208,11 @@ (defun pgg-pgp5-verify-region (start end &optional signature) "Verify region between START and END as the detached signature SIGNATURE." (let ((orig-file (pgg-make-temp-file "pgg")) - (args '("+verbose=1" "+batchmode=1" "+language=us")) - (orig-mode (default-file-modes))) - (unwind-protect - (progn - (set-default-file-modes 448) - (let ((coding-system-for-write 'binary) - jka-compr-compression-info-list jam-zcat-filename-list) - (write-region start end orig-file))) - (set-default-file-modes orig-mode)) + (args '("+verbose=1" "+batchmode=1" "+language=us"))) + (with-file-modes 448 + (let ((coding-system-for-write 'binary) + jka-compr-compression-info-list jam-zcat-filename-list) + (write-region start end orig-file))) (when (stringp signature) (copy-file signature (setq signature (concat orig-file ".asc"))) (setq args (append args (list signature)))) === modified file 'lisp/printing.el' --- lisp/printing.el 2014-05-14 06:35:36 +0000 +++ lisp/printing.el 2014-05-14 17:15:15 +0000 @@ -3171,12 +3171,9 @@ (defmacro pr-save-file-modes (&rest body) - "Set temporally file modes to `pr-file-modes'." - `(let ((pr--default-file-modes (default-file-modes))) ; save default - (set-default-file-modes pr-file-modes) - ,@body - (set-default-file-modes pr--default-file-modes))) ; restore default - + "Execute BODY with file permissions temporarily set to `pr-file-modes'." + (declare (obsolete with-file-modes "24.5")) + `(with-file-modes pr-file-modes ,@body)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Keys & Menus @@ -4372,12 +4369,12 @@ send the image to the printer. If FILENAME is a string, save the PostScript image in a file with that name." (interactive (list (ps-print-preprint current-prefix-arg))) - (pr-save-file-modes - (let ((ps-lpr-command (pr-command pr-ps-command)) - (ps-lpr-switches pr-ps-switches) - (ps-printer-name-option pr-ps-printer-switch) - (ps-printer-name pr-ps-printer)) - (ps-despool filename)))) + (with-file-modes pr-file-modes + (let ((ps-lpr-command (pr-command pr-ps-command)) + (ps-lpr-switches pr-ps-switches) + (ps-printer-name-option pr-ps-printer-switch) + (ps-printer-name pr-ps-printer)) + (ps-despool filename)))) ;;;###autoload @@ -5640,12 +5637,12 @@ (goto-char (point-max)) (insert (format "%s %S\n" cmd args))) ;; *Printing Command Output* == show any return message from command - (pr-save-file-modes - (setq status - (condition-case data - (apply 'call-process cmd nil buffer nil args) - ((quit error) - (error-message-string data))))) + (with-file-modes pr-file-modes + (setq status + (condition-case data + (apply 'call-process cmd nil buffer nil args) + ((quit error) + (error-message-string data))))) ;; *Printing Command Output* == show exit status (with-current-buffer buffer (goto-char (point-max)) @@ -5890,42 +5887,42 @@ (defun pr-text2ps (kind n-up filename &optional from to) - (pr-save-file-modes - (let ((ps-n-up-printing n-up) - (ps-spool-config (and (eq ps-spool-config 'setpagedevice) - 'setpagedevice))) - (pr-delete-file-if-exists filename) - (cond (pr-faces-p - (cond (pr-spool-p - ;; pr-faces-p and pr-spool-p - ;; here FILENAME arg is ignored - (cond ((eq kind 'buffer) - (ps-spool-buffer-with-faces)) - ((eq kind 'region) - (ps-spool-region-with-faces (or from (point)) - (or to (mark)))) - )) - ;; pr-faces-p and not pr-spool-p - ((eq kind 'buffer) - (ps-print-buffer-with-faces filename)) - ((eq kind 'region) - (ps-print-region-with-faces (or from (point)) - (or to (mark)) filename)) - )) - (pr-spool-p - ;; not pr-faces-p and pr-spool-p - ;; here FILENAME arg is ignored - (cond ((eq kind 'buffer) - (ps-spool-buffer)) - ((eq kind 'region) - (ps-spool-region (or from (point)) (or to (mark)))) - )) - ;; not pr-faces-p and not pr-spool-p - ((eq kind 'buffer) - (ps-print-buffer filename)) - ((eq kind 'region) - (ps-print-region (or from (point)) (or to (mark)) filename)) - )))) + (with-file-modes pr-file-modes + (let ((ps-n-up-printing n-up) + (ps-spool-config (and (eq ps-spool-config 'setpagedevice) + 'setpagedevice))) + (pr-delete-file-if-exists filename) + (cond (pr-faces-p + (cond (pr-spool-p + ;; pr-faces-p and pr-spool-p + ;; here FILENAME arg is ignored + (cond ((eq kind 'buffer) + (ps-spool-buffer-with-faces)) + ((eq kind 'region) + (ps-spool-region-with-faces (or from (point)) + (or to (mark)))) + )) + ;; pr-faces-p and not pr-spool-p + ((eq kind 'buffer) + (ps-print-buffer-with-faces filename)) + ((eq kind 'region) + (ps-print-region-with-faces (or from (point)) + (or to (mark)) filename)) + )) + (pr-spool-p + ;; not pr-faces-p and pr-spool-p + ;; here FILENAME arg is ignored + (cond ((eq kind 'buffer) + (ps-spool-buffer)) + ((eq kind 'region) + (ps-spool-region (or from (point)) (or to (mark)))) + )) + ;; not pr-faces-p and not pr-spool-p + ((eq kind 'buffer) + (ps-print-buffer filename)) + ((eq kind 'region) + (ps-print-region (or from (point)) (or to (mark)) filename)) + )))) (defun pr-command (command) === modified file 'lisp/subr.el' --- lisp/subr.el 2014-05-12 06:59:30 +0000 +++ lisp/subr.el 2014-05-14 17:15:15 +0000 @@ -3292,6 +3292,19 @@ ,@body) (with-current-buffer ,old-buffer (set-case-table ,old-case-table)))))) + +(defmacro with-file-modes (modes &rest body) + "Execute BODY with default file permissions temporarily set to MODES. +MODES is as for `set-default-file-modes'." + (declare (indent 1) (debug t)) + (let ((umask (make-symbol "umask"))) + `(let ((,umask (default-file-modes))) + (unwind-protect + (progn + (set-default-file-modes ,modes) + ,@body) + (set-default-file-modes ,umask))))) + ;;; Matching and match data. === modified file 'lisp/url/ChangeLog' --- lisp/url/ChangeLog 2014-05-12 06:59:30 +0000 +++ lisp/url/ChangeLog 2014-05-14 17:15:15 +0000 @@ -1,3 +1,7 @@ +2014-05-14 Glenn Morris + + * url-util.el (url-make-private-file): Use with-file-modes. + 2014-05-12 Michael Albinus * url-handlers.el (url-file-handler-load-in-progress): New defvar. === modified file 'lisp/url/url-util.el' --- lisp/url/url-util.el 2014-03-29 00:55:44 +0000 +++ lisp/url/url-util.el 2014-05-14 17:15:15 +0000 @@ -628,14 +628,9 @@ (make-directory dir t))) ;; Based on doc-view-make-safe-dir. (condition-case nil - (let ((umask (default-file-modes))) - (unwind-protect - (progn - (set-default-file-modes #o0600) - (with-temp-buffer - (write-region (point-min) (point-max) - file nil 'silent nil 'excl))) - (set-default-file-modes umask))) + (with-file-modes #o0600 + (with-temp-buffer + (write-region (point-min) (point-max) file nil 'silent nil 'excl))) (file-already-exists (if (file-symlink-p file) (error "Danger: `%s' is a symbolic link" file)) ------------------------------------------------------------ revno: 117105 committer: Glenn Morris branch nick: trunk timestamp: Wed 2014-05-14 10:05:16 -0700 message: * lisp/vc/emerge.el (emerge-make-temp-file): Simplify. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-05-14 17:01:29 +0000 +++ lisp/ChangeLog 2014-05-14 17:05:16 +0000 @@ -1,3 +1,7 @@ +2014-05-14 Glenn Morris + + * vc/emerge.el (emerge-make-temp-file): Simplify. + 2014-05-14 Stephen Berman Stefan Monnier === modified file 'lisp/vc/emerge.el' --- lisp/vc/emerge.el 2014-05-14 06:59:12 +0000 +++ lisp/vc/emerge.el 2014-05-14 17:05:16 +0000 @@ -2883,17 +2883,11 @@ (setq vars (cdr vars)) (setq values (cdr values)))) -;; Make a temporary file that only we have access to. -;; PREFIX is appended to emerge-temp-file-prefix to make the filename prefix. +;; When the pointless option emerge-temp-file-prefix goes, +;; make this function obsolete too, and just use make-temp-file. (defun emerge-make-temp-file (prefix) - (let (f (old-modes (default-file-modes))) - (unwind-protect - (progn - ;; This has no effect, since make-temp-file sets umask = 700. - (set-default-file-modes emerge-temp-file-mode) - (setq f (make-temp-file (concat emerge-temp-file-prefix prefix)))) - (set-default-file-modes old-modes)) - f)) + "Make a private temporary file based on `emerge-temp-file-prefix'." + (make-temp-file (concat emerge-temp-file-prefix prefix))) ;;; Functions that query the user before he can write out the current buffer. ------------------------------------------------------------ revno: 117104 [merge] committer: Glenn Morris branch nick: trunk timestamp: Wed 2014-05-14 10:01:29 -0700 message: Merge from emacs-24; up to r117113 diff: === modified file 'doc/emacs/ChangeLog' --- doc/emacs/ChangeLog 2014-05-04 19:37:56 +0000 +++ doc/emacs/ChangeLog 2014-05-14 17:01:29 +0000 @@ -1,3 +1,7 @@ +2014-05-14 Eli Zaretskii + + * mule.texi (Language Environments): Remove unused @anchor. (Bug#17479) + 2014-05-04 Eli Zaretskii * trouble.texi (Lossage, DEL Does Not Delete, Stuck Recursive) === modified file 'doc/emacs/mule.texi' --- doc/emacs/mule.texi 2014-04-29 14:45:24 +0000 +++ doc/emacs/mule.texi 2014-05-12 19:10:59 +0000 @@ -439,7 +439,6 @@ also shows some sample text to illustrate scripts used in this language environment. If you give an empty input for @var{lang-env}, this command describes the chosen language environment. -@anchor{Describe Language Environment} @vindex set-language-environment-hook You can customize any language environment with the normal hook === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-05-14 06:35:36 +0000 +++ lisp/ChangeLog 2014-05-14 17:01:29 +0000 @@ -1,3 +1,21 @@ +2014-05-14 Stephen Berman + Stefan Monnier + + * minibuffer.el (completion-pcm--merge-try): Merge trailing / with + suffix (bug#15419). + +2014-05-14 Glenn Morris + + * vc/emerge.el (emerge-temp-file-prefix): + Make pointless option obsolete. + (emerge-temp-file-mode): Make non-functional option obsolete. + +2014-05-14 Michael Albinus + + * net/browse-url.el (browse-url): + Use `unhandled-file-name-directory' when setting `default-directory', + in order to circumvent stalled remote connections. (Bug#17425) + 2014-05-14 Glenn Morris * printing.el (subst-char-in-string, make-temp-file, pr-get-symbol): === modified file 'lisp/minibuffer.el' --- lisp/minibuffer.el 2014-05-08 03:41:21 +0000 +++ lisp/minibuffer.el 2014-05-14 17:01:29 +0000 @@ -3216,11 +3216,20 @@ ;; Not `prefix'. mergedpat)) ;; New pos from the start. - (newpos (length (completion-pcm--pattern->string pointpat))) + (newpos (length (completion-pcm--pattern->string pointpat))) ;; Do it afterwards because it changes `pointpat' by side effect. (merged (completion-pcm--pattern->string (nreverse mergedpat)))) - (setq suffix (completion--merge-suffix merged newpos suffix)) + (setq suffix (completion--merge-suffix + ;; The second arg should ideally be "the position right + ;; after the last char of `merged' that comes from the text + ;; to be completed". But completion-pcm--merge-completions + ;; currently doesn't give us that info. So instead we just + ;; use the "last but one" position, which tends to work + ;; well in practice since `suffix' always starts + ;; with a boundary and we hence mostly/only care about + ;; merging this boundary (bug#15419). + merged (max 0 (1- (length merged))) suffix)) (cons (concat prefix merged suffix) (+ newpos (length prefix))))))) (defun completion-pcm-try-completion (string table pred point) === modified file 'lisp/net/browse-url.el' --- lisp/net/browse-url.el 2014-05-10 20:48:36 +0000 +++ lisp/net/browse-url.el 2014-05-13 08:54:08 +0000 @@ -807,15 +807,15 @@ (interactive (browse-url-interactive-arg "URL: ")) (unless (called-interactively-p 'interactive) (setq args (or args (list browse-url-new-window-flag)))) + (when (and url-handler-mode (not (file-name-absolute-p url))) + (setq url (expand-file-name url))) (let ((process-environment (copy-sequence process-environment)) (function (or (and (string-match "\\`mailto:" url) browse-url-mailto-function) browse-url-browser-function)) ;; Ensure that `default-directory' exists and is readable (b#6077). - (default-directory (if (and (file-directory-p default-directory) - (file-readable-p default-directory)) - default-directory - (expand-file-name "~/")))) + (default-directory (or (unhandled-file-name-directory default-directory) + (expand-file-name "~/")))) ;; When connected to various displays, be careful to use the display of ;; the currently selected frame, rather than the original start display, ;; which may not even exist any more. === modified file 'lisp/vc/emerge.el' --- lisp/vc/emerge.el 2014-02-03 00:40:49 +0000 +++ lisp/vc/emerge.el 2014-05-14 06:59:12 +0000 @@ -261,11 +261,19 @@ :type 'string :group 'emerge) +(make-obsolete-variable 'emerge-temp-file-prefix + "customize `temporary-file-directory' instead." + "24.4" 'set) + (defcustom emerge-temp-file-mode 384 ; u=rw only "Mode for Emerge temporary files." :type 'integer :group 'emerge) +(make-obsolete-variable 'emerge-temp-file-mode + "it has no effect, temporary files are always private." + "24.4" 'set) + (defcustom emerge-combine-versions-template "#ifdef NEW\n%b#else /* not NEW */\n%a#endif /* not NEW */\n" "Template for `emerge-combine-versions' to combine the two versions. @@ -2881,6 +2889,7 @@ (let (f (old-modes (default-file-modes))) (unwind-protect (progn + ;; This has no effect, since make-temp-file sets umask = 700. (set-default-file-modes emerge-temp-file-mode) (setq f (make-temp-file (concat emerge-temp-file-prefix prefix)))) (set-default-file-modes old-modes)) ------------------------------------------------------------ revno: 117103 committer: Dmitry Antipov branch nick: trunk timestamp: Wed 2014-05-14 17:55:37 +0400 message: Minor cleanup for terminal setup. * termhooks.h (create_terminal): Adjust prototype. * terminal.c (create_terminal): Pass output method and RIF as args. (init_initial_terminal): * nsterm.m (ns_create_terminal): * term.c (init_tty): * w32term.c (w32_create_terminal): * xterm.c (x_create_terminal): Adjust users. Avoid redundant NULL initializers and add comments. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-05-13 22:59:36 +0000 +++ src/ChangeLog 2014-05-14 13:55:37 +0000 @@ -1,3 +1,15 @@ +2014-05-14 Dmitry Antipov + + Minor cleanup for terminal setup. + * termhooks.h (create_terminal): Adjust prototype. + * terminal.c (create_terminal): Pass output method and RIF as args. + (init_initial_terminal): + * nsterm.m (ns_create_terminal): + * term.c (init_tty): + * w32term.c (w32_create_terminal): + * xterm.c (x_create_terminal): Adjust users. + Avoid redundant NULL initializers and add comments. + 2014-05-13 Paul Eggert * keyboard.c (Qdeactivate_mark): Now static. === modified file 'src/nsterm.m' --- src/nsterm.m 2014-04-07 20:54:16 +0000 +++ src/nsterm.m 2014-05-14 13:55:37 +0000 @@ -4153,38 +4153,28 @@ NSTRACE (ns_create_terminal); - terminal = create_terminal (); + terminal = create_terminal (output_ns, &ns_redisplay_interface); - terminal->type = output_ns; terminal->display_info.ns = dpyinfo; dpyinfo->terminal = terminal; - terminal->rif = &ns_redisplay_interface; - terminal->clear_frame_hook = ns_clear_frame; - terminal->ins_del_lines_hook = 0; /* XXX vestigial? */ - terminal->delete_glyphs_hook = 0; /* XXX vestigial? */ terminal->ring_bell_hook = ns_ring_bell; - terminal->reset_terminal_modes_hook = NULL; - terminal->set_terminal_modes_hook = NULL; terminal->update_begin_hook = ns_update_begin; terminal->update_end_hook = ns_update_end; - terminal->set_terminal_window_hook = NULL; /* XXX vestigial? */ terminal->read_socket_hook = ns_read_socket; terminal->frame_up_to_date_hook = ns_frame_up_to_date; terminal->mouse_position_hook = ns_mouse_position; terminal->frame_rehighlight_hook = ns_frame_rehighlight; terminal->frame_raise_lower_hook = ns_frame_raise_lower; - terminal->fullscreen_hook = ns_fullscreen_hook; - terminal->set_vertical_scroll_bar_hook = ns_set_vertical_scroll_bar; terminal->condemn_scroll_bars_hook = ns_condemn_scroll_bars; terminal->redeem_scroll_bar_hook = ns_redeem_scroll_bar; terminal->judge_scroll_bars_hook = ns_judge_scroll_bars; - terminal->delete_frame_hook = x_destroy_window; terminal->delete_terminal_hook = ns_delete_terminal; + /* Other hooks are NULL by default. */ return terminal; } === modified file 'src/term.c' --- src/term.c 2014-05-04 19:37:56 +0000 +++ src/term.c 2014-05-14 13:55:37 +0000 @@ -3940,43 +3940,24 @@ static void set_tty_hooks (struct terminal *terminal) { - terminal->rif = 0; /* ttys don't support window-based redisplay. */ - terminal->cursor_to_hook = &tty_cursor_to; terminal->raw_cursor_to_hook = &tty_raw_cursor_to; - terminal->clear_to_end_hook = &tty_clear_to_end; terminal->clear_frame_hook = &tty_clear_frame; terminal->clear_end_of_line_hook = &tty_clear_end_of_line; - terminal->ins_del_lines_hook = &tty_ins_del_lines; - terminal->insert_glyphs_hook = &tty_insert_glyphs; terminal->write_glyphs_hook = &tty_write_glyphs; terminal->delete_glyphs_hook = &tty_delete_glyphs; - terminal->ring_bell_hook = &tty_ring_bell; - terminal->reset_terminal_modes_hook = &tty_reset_terminal_modes; terminal->set_terminal_modes_hook = &tty_set_terminal_modes; - terminal->update_begin_hook = 0; /* Not needed. */ terminal->update_end_hook = &tty_update_end; terminal->set_terminal_window_hook = &tty_set_terminal_window; - - terminal->mouse_position_hook = 0; /* Not needed. */ - terminal->frame_rehighlight_hook = 0; /* Not needed. */ - terminal->frame_raise_lower_hook = 0; /* Not needed. */ - - terminal->set_vertical_scroll_bar_hook = 0; /* Not needed. */ - terminal->condemn_scroll_bars_hook = 0; /* Not needed. */ - terminal->redeem_scroll_bar_hook = 0; /* Not needed. */ - terminal->judge_scroll_bars_hook = 0; /* Not needed. */ - terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */ - terminal->frame_up_to_date_hook = 0; /* Not needed. */ - terminal->delete_frame_hook = &tty_free_frame_resources; terminal->delete_terminal_hook = &delete_tty; + /* Other hooks are NULL by default. */ } /* If FD is the controlling terminal, drop it. */ @@ -4040,7 +4021,7 @@ if (terminal) return terminal; - terminal = create_terminal (); + terminal = create_terminal (output_termcap, NULL); #ifdef MSDOS if (been_here > 0) maybe_fatal (0, 0, "Attempt to create another terminal %s", "", @@ -4054,7 +4035,6 @@ tty->next = tty_list; tty_list = tty; - terminal->type = output_termcap; terminal->display_info.tty = tty; tty->terminal = terminal; === modified file 'src/termhooks.h' --- src/termhooks.h 2014-04-16 13:27:28 +0000 +++ src/termhooks.h 2014-05-14 13:55:37 +0000 @@ -637,7 +637,8 @@ #endif extern struct terminal *get_terminal (Lisp_Object terminal, bool); -extern struct terminal *create_terminal (void); +extern struct terminal *create_terminal (enum output_method, + struct redisplay_interface *); extern void delete_terminal (struct terminal *); /* The initial terminal device, created by initial_term_init. */ === modified file 'src/terminal.c' --- src/terminal.c 2014-01-28 05:55:06 +0000 +++ src/terminal.c 2014-05-14 13:55:37 +0000 @@ -224,19 +224,19 @@ return result; } - - -/* Create a new terminal object and add it to the terminal list. */ +/* Create a new terminal object of TYPE and add it to the terminal list. RIF + may be NULL if this terminal type doesn't support window-based redisplay. */ struct terminal * -create_terminal (void) +create_terminal (enum output_method type, struct redisplay_interface *rif) { struct terminal *terminal = allocate_terminal (); Lisp_Object terminal_coding, keyboard_coding; terminal->next_terminal = terminal_list; terminal_list = terminal; - + terminal->type = type; + terminal->rif = rif; terminal->id = next_terminal_id++; terminal->keyboard_coding = xmalloc (sizeof (struct coding_system)); @@ -519,13 +519,12 @@ if (initialized || terminal_list || tty_list) emacs_abort (); - initial_terminal = create_terminal (); - initial_terminal->type = output_initial; + initial_terminal = create_terminal (output_initial, NULL); initial_terminal->name = xstrdup ("initial_terminal"); initial_terminal->kboard = initial_kboard; initial_terminal->delete_terminal_hook = &delete_initial_terminal; initial_terminal->delete_frame_hook = &initial_free_frame_resources; - /* All other hooks are NULL. */ + /* Other hooks are NULL by default. */ return initial_terminal; } === modified file 'src/w32term.c' --- src/w32term.c 2014-04-16 19:43:46 +0000 +++ src/w32term.c 2014-05-14 13:55:37 +0000 @@ -6272,9 +6272,8 @@ { struct terminal *terminal; - terminal = create_terminal (); + terminal = create_terminal (output_w32, &w32_redisplay_interface); - terminal->type = output_w32; terminal->display_info.w32 = dpyinfo; dpyinfo->terminal = terminal; @@ -6284,11 +6283,8 @@ terminal->ins_del_lines_hook = x_ins_del_lines; terminal->delete_glyphs_hook = x_delete_glyphs; terminal->ring_bell_hook = w32_ring_bell; - terminal->reset_terminal_modes_hook = NULL; - terminal->set_terminal_modes_hook = NULL; terminal->update_begin_hook = x_update_begin; terminal->update_end_hook = x_update_end; - terminal->set_terminal_window_hook = NULL; terminal->read_socket_hook = w32_read_socket; terminal->frame_up_to_date_hook = w32_frame_up_to_date; terminal->mouse_position_hook = w32_mouse_position; @@ -6299,11 +6295,9 @@ terminal->condemn_scroll_bars_hook = w32_condemn_scroll_bars; terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar; terminal->judge_scroll_bars_hook = w32_judge_scroll_bars; - terminal->delete_frame_hook = x_destroy_window; terminal->delete_terminal_hook = x_delete_terminal; - - terminal->rif = &w32_redisplay_interface; + /* Other hooks are NULL by default. */ /* We don't yet support separate terminals on W32, so don't try to share keyboards between virtual terminals that are on the same physical === modified file 'src/xterm.c' --- src/xterm.c 2014-05-13 14:18:54 +0000 +++ src/xterm.c 2014-05-14 13:55:37 +0000 @@ -10526,9 +10526,8 @@ { struct terminal *terminal; - terminal = create_terminal (); + terminal = create_terminal (output_x_window, &x_redisplay_interface); - terminal->type = output_x_window; terminal->display_info.x = dpyinfo; dpyinfo->terminal = terminal; @@ -10539,11 +10538,8 @@ terminal->delete_glyphs_hook = x_delete_glyphs; terminal->ring_bell_hook = XTring_bell; terminal->toggle_invisible_pointer_hook = XTtoggle_invisible_pointer; - terminal->reset_terminal_modes_hook = NULL; - terminal->set_terminal_modes_hook = NULL; terminal->update_begin_hook = x_update_begin; terminal->update_end_hook = x_update_end; - terminal->set_terminal_window_hook = NULL; terminal->read_socket_hook = XTread_socket; terminal->frame_up_to_date_hook = XTframe_up_to_date; terminal->mouse_position_hook = XTmouse_position; @@ -10554,11 +10550,9 @@ terminal->condemn_scroll_bars_hook = XTcondemn_scroll_bars; terminal->redeem_scroll_bar_hook = XTredeem_scroll_bar; terminal->judge_scroll_bars_hook = XTjudge_scroll_bars; - terminal->delete_frame_hook = x_destroy_window; terminal->delete_terminal_hook = x_delete_terminal; - - terminal->rif = &x_redisplay_interface; + /* Other hooks are NULL by default. */ return terminal; } ------------------------------------------------------------ revno: 117102 committer: Katsumi Yamaoka branch nick: trunk timestamp: Wed 2014-05-14 08:50:51 +0000 message: gnus-art.el, mm-uu.el: Misc improvements for displaying MIME parts * gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part): Work for the last MIME part in an article. (gnus-mime-display-single): Suppress excessive newlines between parts. * mm-uu.el (mm-uu-dissect): Assume that separators may be accompanied by leading or trailing newline. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2014-05-12 06:59:30 +0000 +++ lisp/gnus/ChangeLog 2014-05-14 08:50:51 +0000 @@ -1,3 +1,12 @@ +2014-05-14 Katsumi Yamaoka + + * gnus-art.el (gnus-mime-inline-part, gnus-mm-display-part): + Work for the last MIME part in an article. + (gnus-mime-display-single): Suppress excessive newlines between parts. + + * mm-uu.el (mm-uu-dissect): Assume that separators may be accompanied + by leading or trailing newline. + 2014-05-09 Katsumi Yamaoka * gnus-art.el (gnus-mm-display-part): Don't put article out of sight === modified file 'lisp/gnus/gnus-art.el' --- lisp/gnus/gnus-art.el 2014-05-09 09:50:14 +0000 +++ lisp/gnus/gnus-art.el 2014-05-14 08:50:51 +0000 @@ -5316,7 +5316,8 @@ (when (= b (prog1 btn (setq btn (previous-single-property-change - (next-single-property-change btn 'gnus-data) + (or (next-single-property-change btn 'gnus-data) + (point-max)) 'gnus-data)))) (setq b btn)) (if (and (not arg) (mm-handle-undisplayer handle)) @@ -5353,12 +5354,14 @@ (if (featurep 'emacs) (delete-region (point) - (text-property-any (point) (point-max) 'gnus-data nil)) + (or (text-property-any (point) (point-max) 'gnus-data nil) + (point-max))) (let* ((end (text-property-any (point) (point-max) 'gnus-data nil)) (annots (annotations-at end))) (delete-region (point) - ;; FIXME: why isn't this simply `end'? - (if annots (1+ end) end)) + (if end + (if annots (1+ end) end) + (point-max))) (dolist (annot annots) (set-extent-endpoints annot (point) (point))))) (unless (search-backward "\n\n" nil t) @@ -5691,7 +5694,8 @@ (select-window win) (goto-char point))) (setq point (previous-single-property-change - (next-single-property-change point 'gnus-data) + (or (next-single-property-change point 'gnus-data) + (point-max)) 'gnus-data)) (if (mm-handle-displayed-p handle) ;; This will remove the part. @@ -5728,12 +5732,15 @@ (gnus-insert-mime-button handle id (list (mm-handle-displayed-p handle))) (if (featurep 'emacs) (delete-region - (point) (text-property-any (point) (point-max) 'gnus-data nil)) + (point) + (or (text-property-any (point) (point-max) 'gnus-data nil) + (point-max))) (let* ((end (text-property-any (point) (point-max) 'gnus-data nil)) (annots (annotations-at end))) (delete-region (point) - ;; FIXME: why isn't this simply `end'? - (if annots (1+ end) end)) + (if end + (if annots (1+ end) end) + (point-max))) (dolist (annot annots) (set-extent-endpoints annot (point) (point))))) (unless (search-backward "\n\n" nil t) @@ -6036,9 +6043,6 @@ (eq id gnus-mime-buttonized-part-id)) (gnus-insert-mime-button handle id (list (or display (and not-attachment text))))) - (gnus-article-insert-newline) - (when (or display (and text not-attachment)) - (forward-line -1)) (setq beg (point)) (cond (display @@ -6048,12 +6052,18 @@ (set-buffer gnus-summary-buffer) (error)) gnus-newsgroup-ignored-charsets))) - (gnus-bind-safe-url-regexp (mm-display-part handle t))) + (gnus-bind-safe-url-regexp (mm-display-part handle t)))) + ((and text not-attachment) + (mm-display-inline handle))) + (goto-char (point-max)) + (if (string-match "\\`image/" type) + (gnus-article-insert-newline) + (if (prog1 + (= (skip-chars-backward "\n") -1) + (forward-char 1)) + (gnus-article-insert-newline) + (put-text-property (point) (point-max) 'gnus-undeletable t)) (goto-char (point-max))) - ((and text not-attachment) - (gnus-article-insert-newline) - (mm-display-inline handle) - (goto-char (point-max)))) ;; Do highlighting. (save-excursion (save-restriction === modified file 'lisp/gnus/mm-uu.el' --- lisp/gnus/mm-uu.el 2014-01-01 07:43:34 +0000 +++ lisp/gnus/mm-uu.el 2014-05-14 08:50:51 +0000 @@ -673,22 +673,34 @@ (goto-char text-start) (re-search-forward "." start-point t))) (push - (mm-make-handle (mm-uu-copy-to-buffer text-start start-point) - mm-uu-text-plain-type) + (mm-make-handle + (mm-uu-copy-to-buffer + text-start + ;; A start-separator is likely accompanied by + ;; a leading newline. + (if (and (eq (char-before start-point) ?\n) + (eq (char-before (1- start-point)) ?\n)) + (1- start-point) + start-point)) + mm-uu-text-plain-type) result)) (push (funcall (mm-uu-function-extract entry)) result) (goto-char (setq text-start end-point)))) (when result - (if (and (> (point-max) (1+ text-start)) - (save-excursion - (goto-char text-start) - (re-search-forward "." nil t))) - (push - (mm-make-handle (mm-uu-copy-to-buffer text-start (point-max)) - mm-uu-text-plain-type) - result)) + (goto-char text-start) + (when (re-search-forward "." nil t) + (push (mm-make-handle + (mm-uu-copy-to-buffer + ;; An end-separator is likely accompanied by + ;; a trailing newline. + (if (eq (char-after text-start) ?\n) + (1+ text-start) + text-start) + (point-max)) + mm-uu-text-plain-type) + result)) (setq result (cons "multipart/mixed" (nreverse result)))) result))) ------------------------------------------------------------ revno: 117101 committer: Glenn Morris branch nick: trunk timestamp: Tue 2014-05-13 23:35:36 -0700 message: Optimize away some compat-cruft in printing.el * lisp/printing.el (subst-char-in-string, make-temp-file, pr-get-symbol): Optimize on Emacs, which has the relevant functions for ages. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-05-13 20:34:12 +0000 +++ lisp/ChangeLog 2014-05-14 06:35:36 +0000 @@ -1,3 +1,8 @@ +2014-05-14 Glenn Morris + + * printing.el (subst-char-in-string, make-temp-file, pr-get-symbol): + Optimize on Emacs, which has the relevant functions for ages. + 2014-05-13 Stefan Monnier * simple.el (undo-make-selective-list): Obey undo-no-redo. === modified file 'lisp/printing.el' --- lisp/printing.el 2014-05-12 06:59:30 +0000 +++ lisp/printing.el 2014-05-14 06:35:36 +0000 @@ -1038,20 +1038,27 @@ ;; To avoid compilation gripes -(or (fboundp 'subst-char-in-string) ; hacked from subr.el - (defun subst-char-in-string (fromchar tochar string &optional inplace) - "Replace FROMCHAR with TOCHAR in STRING each time it occurs. +;; Emacs has this since at least 21.1. +(when (featurep 'xemacs) + (or (fboundp 'subst-char-in-string) ; hacked from subr.el + (defun subst-char-in-string (fromchar tochar string &optional inplace) + "Replace FROMCHAR with TOCHAR in STRING each time it occurs. Unless optional argument INPLACE is non-nil, return a new string." - (let ((i (length string)) - (newstr (if inplace string (copy-sequence string)))) - (while (> (setq i (1- i)) 0) - (if (eq (aref newstr i) fromchar) - (aset newstr i tochar))) - newstr))) - - -(or (fboundp 'make-temp-file) ; hacked from subr.el - (defun make-temp-file (prefix &optional dir-flag suffix) + (let ((i (length string)) + (newstr (if inplace string (copy-sequence string)))) + (while (> (setq i (1- i)) 0) + (if (eq (aref newstr i) fromchar) + (aset newstr i tochar))) + newstr)))) + + +;; Emacs has this since at least 21.1, but the SUFFIX argument +;; (which this file uses) only since 22.1. So the fboundp test +;; wasn't even correct/adequate. Whatever, no-one is using +;; this file on older Emacs version, so it's irrelevant. +(when (featurep 'xemacs) + (or (fboundp 'make-temp-file) ; hacked from subr.el + (defun make-temp-file (prefix &optional dir-flag suffix) "Create a temporary file. The returned file name (created by appending some random characters at the end of PREFIX, and expanding against `temporary-file-directory' if necessary), @@ -1086,7 +1093,7 @@ nil) file) ;; Reset the umask. - (set-default-file-modes umask))))) + (set-default-file-modes umask)))))) (eval-when-compile @@ -3192,9 +3199,10 @@ (defalias 'pr-get-symbol - (if (fboundp 'easy-menu-intern) ; hacked from easymenu.el - 'easy-menu-intern - (lambda (s) (if (stringp s) (intern s) s)))) + (if (featurep 'emacs) 'easy-menu-intern ; since 22.1 + (if (fboundp 'easy-menu-intern) ; hacked from easymenu.el + 'easy-menu-intern + (lambda (s) (if (stringp s) (intern s) s))))) (defconst pr-menu-spec ------------------------------------------------------------ Use --include-merged or -n0 to see merged revisions.