unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: [PATCH v3] Add xwidget webkit support for macOS Cocoa
Date: Wed, 05 Jun 2019 09:55:24 -0400	[thread overview]
Message-ID: <jwvy32gkvfb.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: 20190605031823.51015-1-pcr910303@icloud.com

Thanks, looks good for the part I can review.
See additional nitpicks in case nobody comes up with more
substantial comments.

> +(defun xwidget-webkit-split-below ()
> +  "Clone current URL into a new widget place in new window below.

Great.

> +(defun xwidget-webkit-split-right ()
> +  "Get the URL of current session, then browse to the URL \
> +in `split-window-right' with a new xwidget webkit session."

You missed this one, tho.

> +   (format "window.scrollBy(0, %d);"
> +           (or n (xwidget-window-inside-pixel-height (selected-window))))))

Great.

> -   "window.scrollBy(0, -50);"))
> +   (cond ((null n)
> +          (format "window.scrollBy(0, %d);"
> +                  (- (xwidget-window-inside-pixel-height (selected-window)))))
> +         (t (format "window.scrollBy(0, %d);" (- n))))))

You missed this one, tho.

> +(defcustom xwidget-webkit-scroll-line-height 50
> +  "Default line height in pixels for scroll xwidget webkit."
> +  :type 'integer
> +  :group 'xwidget)

Those `:group 'xwidget` are redundant since it defaults to the last
`defgroup` in the buffer anyway.

> +            ;; TODO: Response handling other than download.
> +            ((eq xwidget-event-type 'response-callback)
> +             (let ((url  (nth 3 last-input-event))
> +                   (mime-type (nth 4 last-input-event))
> +                   (file-name (nth 5 last-input-event)))
> +               (xwidget-webkit-save-as-file url mime-type file-name)))

BTW, where does the "response-callback" name come from?
According to the above code, this is used in the case of downloads, so
why is it not called "download-callback"?

> +(defun xwidget-webkit-save-as-file (url mime-type &optional file-name)
> +  "For XWIDGET webkit, save URL resource of MIME-TYPE as FILE-NAME."
> +  (let ((save-name (read-file-name
> +                    (format "Save '%s' file as: " mime-type)
> +                    xwidget-webkit-download-dir
> +                    (expand-file-name
> +                     file-name
> +                     xwidget-webkit-download-dir) nil file-name)))

Again, please don't pass `file-name` as INITIAL arg: leave it nil.

> -         `((page     . ,(xwidget-webkit-current-url))
> -           (handler  . (lambda (bmk) (browse-url
> -                                 (bookmark-prop-get bmk 'page)))))))
> -
> +         `((page . ,(xwidget-webkit-current-url))
> +           (handler  . (lambda (bmk)
> +                         (browse-url
> +                          (bookmark-prop-get bmk 'filename)
> +                          xwidget-webkit-bookmark-jump-new-session)
> +                         (switch-to-buffer
> +                          (xwidget-buffer (xwidget-webkit-last-session))))))))

I see you reverted to `page`, which is fine, but then the
(bookmark-prop-get bmk 'filename) needs to be changed back to
(bookmark-prop-get bmk 'page) as well, shouldn't it?

Also, I don't really understand the new code:
- how do we know that `browse-url` will use the xwidget browser rather than
  any other?  I think we should either call `browse-url` and presume it
  can be *any* browser, or call xwidget-webkit-browse-url instead.
- Why do we need the switch-to-buffer?  Why not rely on
  (xwidget-webkit-)browse-url to Do The Right Thing?
- switch-to-buffer fails miserably in configs such as mine
  (separate minibuffer frame and dedicated windows), so better avoid it
  in Elisp and use things like pop-to-buffer or pop-to-buffer-same-window.

> +    ;; Insert invisible url, good default for next `g' to browse url.
> +    (let ((start (point)))
> +      (insert url)
> +      (put-text-property start (+ start (length url)) 'invisible t))
>      (setq xw (xwidget-insert 1 'webkit bufname

Please use `start` rather than 1.


        Stefan




  reply	other threads:[~2019-06-05 13:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-25 13:27 [PATCH] Add xwidget webkit support for macOS Cocoa Sungbin Jo
2019-05-25 17:47 ` Paul Eggert
2019-05-26  2:57   ` 조성빈
2019-05-26  6:02     ` Paul Eggert
2019-05-28 15:07       ` [PATCH v2] " 조성빈
2019-06-02  6:14         ` 조성빈
2019-06-02 14:39           ` Eli Zaretskii
2019-06-03 16:11         ` Alan Third
2019-06-03 17:25           ` Stefan Monnier
2019-06-03 23:36             ` Paul Eggert
2019-06-03 23:51               ` Sungbin Jo
2019-06-04  2:40                 ` Stefan Monnier
2019-06-04  8:33                   ` Andreas Schwab
2019-06-05  3:06                   ` Sungbin Jo
2019-06-05  3:18                   ` [PATCH v3] " Sungbin Jo
2019-06-05 13:55                     ` Stefan Monnier [this message]
2019-06-05 14:34                     ` Eli Zaretskii
2019-06-23 22:38                     ` Alan Third
2019-06-04 16:22                 ` [PATCH v2] " Alan Third

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvy32gkvfb.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).