From 805a39bcc94d143b0e60e5cd894cdad32af376c3 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Mitsuharu Date: Fri, 13 Nov 2015 12:48:09 +0900 Subject: [PATCH 1/2] Remove intern calls and XXX comments from Fx_export_frames * src/xfns.c (Fx_export_frames): Use Qpdf, Qpng, Qpostscript, and Qsvg instead of intern calls. Use "postscript" instead of "ps" for consistency with image types. Remove XXX comments. (syms_of_xfns) : DEFSYM it. --- src/xfns.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/xfns.c b/src/xfns.c index 9071b89acd9..9d90b7ba35f 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -6559,11 +6559,12 @@ present and mapped to the usual X keysyms. */) #ifdef USE_CAIRO DEFUN ("x-export-frames", Fx_export_frames, Sx_export_frames, 0, 2, 0, - doc: /* XXX Experimental. Return image data of FRAMES in TYPE format. + doc: /* Return image data of FRAMES in TYPE format. FRAMES should be nil (the selected frame), a frame, or a list of frames (each of which corresponds to one page). Optional arg TYPE -should be either `pdf' (default), `png', `ps', or `svg'. Supported -types are determined by the compile-time configuration of cairo. */) +should be either `pdf' (default), `png', `postscript', or `svg'. +Supported types are determined by the compile-time configuration of +cairo. */) (Lisp_Object frames, Lisp_Object type) { Lisp_Object result, rest, tmp; @@ -6590,12 +6591,12 @@ types are determined by the compile-time configuration of cairo. */) frames = Fnreverse (tmp); #ifdef CAIRO_HAS_PDF_SURFACE - if (NILP (type) || EQ (type, intern ("pdf"))) /* XXX: Qpdf */ + if (NILP (type) || EQ (type, Qpdf)) surface_type = CAIRO_SURFACE_TYPE_PDF; else #endif #ifdef CAIRO_HAS_PNG_FUNCTIONS - if (EQ (type, intern ("png"))) + if (EQ (type, Qpng)) { if (!NILP (XCDR (frames))) error ("PNG export cannot handle multiple frames."); @@ -6604,12 +6605,12 @@ types are determined by the compile-time configuration of cairo. */) else #endif #ifdef CAIRO_HAS_PS_SURFACE - if (EQ (type, intern ("ps"))) + if (EQ (type, Qpostscript)) surface_type = CAIRO_SURFACE_TYPE_PS; else #endif #ifdef CAIRO_HAS_SVG_SURFACE - if (EQ (type, intern ("svg"))) + if (EQ (type, Qsvg)) { /* For now, we stick to SVG 1.1. */ if (!NILP (XCDR (frames))) @@ -6763,6 +6764,8 @@ syms_of_xfns (void) DEFSYM (Qmono, "mono"); #ifdef USE_CAIRO + DEFSYM (Qpdf, "pdf"); + DEFSYM (Qorientation, "orientation"); DEFSYM (Qtop_margin, "top-margin"); DEFSYM (Qbottom_margin, "bottom-margin"); From 68cdc4bd7a780641a45b53b8fb71431e2da1a058 Mon Sep 17 00:00:00 2001 From: l3thal Date: Fri, 13 Nov 2015 16:34:32 -0500 Subject: [PATCH 2/2] Reconnect asynchronously. --- lisp/erc/erc-backend.el | 49 +++++++++++++++++++++-------------------- lisp/erc/erc.el | 6 ++++- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index ec45dcfcf24..755443f8a94 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -376,7 +376,7 @@ alist." :type '(repeat (cons (string :tag "Target") coding-system))) -(defcustom erc-server-connect-function 'open-network-stream +(defcustom erc-server-connect-function 'erc-open-network-stream "Function used to initiate a connection. It should take same arguments as `open-network-stream' does." :group 'erc-server @@ -505,6 +505,10 @@ The current buffer is given by BUFFER." (memq (process-status erc-server-process) '(run open))))) ;;;; Connecting to a server +(defun erc-open-network-stream (name buffer host service) + "As `open-network-stream', but does non-blocking IO" + (make-network-process :name name :buffer buffer + :host host :service service :nowait t)) (defun erc-server-connect (server port buffer) "Perform the connection and login using the specified SERVER and PORT. @@ -565,10 +569,15 @@ Make sure you are in an ERC buffer when running this." (setq erc-server-last-sent-time 0) (setq erc-server-lines-sent 0) (let ((erc-server-connect-function (or erc-session-connector - 'open-network-stream))) + 'erc-open-network-stream))) (erc-open erc-session-server erc-session-port erc-server-current-nick erc-session-user-full-name t erc-session-password))))) +(defun erc-server-delayed-reconnect (event buffer) + (if (buffer-live-p buffer) + (with-current-buffer buffer + (erc-server-reconnect)))) + (defun erc-server-filter-function (process string) "The process filter for the ERC server." (with-current-buffer (process-buffer process) @@ -615,17 +624,16 @@ EVENT is the message received from the closed connection process." (or erc-server-timed-out (not (string-match "^deleted" event))) ;; open-network-stream-nowait error for connection refused - (not (string-match "^failed with code 111" event))))) + (if (string-match "^failed with code 111" event) 'nonblocking t)))) (defun erc-process-sentinel-2 (event buffer) "Called when `erc-process-sentinel-1' has detected an unexpected disconnect." (if (not (buffer-live-p buffer)) (erc-update-mode-line) (with-current-buffer buffer - (let ((reconnect-p (erc-server-reconnect-p event))) - (erc-display-message nil 'error (current-buffer) - (if reconnect-p 'disconnected - 'disconnected-noreconnect)) + (let ((reconnect-p (erc-server-reconnect-p event)) message delay) + (setq message (if reconnect-p 'disconnected 'disconnected-noreconnect)) + (erc-display-message nil 'error (current-buffer) message) (if (not reconnect-p) ;; terminate, do not reconnect (progn @@ -637,23 +645,16 @@ EVENT is the message received from the closed connection process." ;; reconnect (condition-case err (progn - (setq erc-server-reconnecting nil) - (erc-server-reconnect) - (setq erc-server-reconnect-count 0)) - (error (when (buffer-live-p buffer) - (set-buffer buffer) - (if (integerp erc-server-reconnect-attempts) - (setq erc-server-reconnect-count - (1+ erc-server-reconnect-count)) - (message "%s ... %s" - "Reconnecting until we succeed" - "kill the ERC server buffer to stop")) - (if (numberp erc-server-reconnect-timeout) - (run-at-time erc-server-reconnect-timeout nil - #'erc-process-sentinel-2 - event buffer) - (error (concat "`erc-server-reconnect-timeout'" - " must be a number"))))))))))) + (setq erc-server-reconnecting nil + erc-server-reconnect-count (1+ erc-server-reconnect-count)) + (setq delay erc-server-reconnect-timeout) + (run-at-time delay nil + #'erc-server-delayed-reconnect event buffer)) + (error (unless (integerp erc-server-reconnect-attempts) + (message "%s ... %s" + "Reconnecting until we succeed" + "kill the ERC server buffer to stop")) + (erc-server-delayed-reconnect event buffer)))))))) (defun erc-process-sentinel-1 (event buffer) "Called when `erc-process-sentinel' has decided that we're disconnecting. diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 8e26db1d9d3..d82089f5b05 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -1963,7 +1963,9 @@ Returns the buffer for the given server or channel." (erc-update-modules) (set-buffer buffer) (setq old-point (point)) - (erc-mode) + (let ((old-recon-count erc-server-reconnect-count)) + (erc-mode) + (setq erc-server-reconnect-count old-recon-count)) (setq erc-server-announced-name server-announced-name) (setq erc-server-connected connected-p) ;; connection parameters @@ -2203,6 +2205,7 @@ Arguments are the same as for `erc'." The process will be given the name NAME, its target buffer will be BUFFER. HOST and PORT specify the connection target." (open-network-stream name buffer host port + :nowait t :type 'tls)) ;;; Displaying error messages @@ -4483,6 +4486,7 @@ Set user modes and run `erc-after-connect' hook." (nick (car (erc-response.command-args parsed))) (buffer (process-buffer proc))) (setq erc-server-connected t) + (setq erc-server-reconnect-count 0) (erc-update-mode-line) (erc-set-initial-user-mode nick buffer) (erc-server-setup-periodical-ping buffer)