2015-01-12 13:07:52 -05:00
|
|
|
;;; eww.el --- Emacs Web Wowser -*- lexical-binding:t -*-
|
2013-06-10 11:46:27 +00:00
|
|
|
|
2024-01-02 09:47:10 +08:00
|
|
|
;; Copyright (C) 2013-2024 Free Software Foundation, Inc.
|
2013-06-10 11:46:27 +00:00
|
|
|
|
|
|
|
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
|
|
|
|
;; Keywords: html
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2013-06-10 11:46:27 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2016-11-02 16:18:49 -04:00
|
|
|
(require 'cl-lib)
|
2020-05-08 00:25:38 +01:00
|
|
|
(require 'mm-url)
|
|
|
|
(require 'puny)
|
2013-06-10 11:46:27 +00:00
|
|
|
(require 'shr)
|
2020-05-08 00:25:38 +01:00
|
|
|
(require 'text-property-search)
|
|
|
|
(require 'thingatpt)
|
2013-06-10 11:46:27 +00:00
|
|
|
(require 'url)
|
2014-11-03 21:33:32 +01:00
|
|
|
(require 'url-queue)
|
2022-02-20 16:08:45 +01:00
|
|
|
(require 'url-file)
|
2020-07-29 07:13:56 +02:00
|
|
|
(require 'xdg)
|
2020-05-08 00:25:38 +01:00
|
|
|
(eval-when-compile (require 'subr-x))
|
2013-06-10 11:46:27 +00:00
|
|
|
|
2013-06-16 22:20:55 +00:00
|
|
|
(defgroup eww nil
|
2021-09-14 08:43:18 +02:00
|
|
|
"Emacs Web Wowser."
|
2014-11-16 21:29:40 +01:00
|
|
|
:version "25.1"
|
2014-01-25 20:15:42 +01:00
|
|
|
:link '(custom-manual "(eww) Top")
|
2014-11-16 21:29:40 +01:00
|
|
|
:group 'web
|
2013-06-16 22:20:55 +00:00
|
|
|
:prefix "eww-")
|
|
|
|
|
|
|
|
(defcustom eww-header-line-format "%t: %u"
|
|
|
|
"Header line format.
|
|
|
|
- %t is replaced by the title.
|
|
|
|
- %u is replaced by the URL."
|
2013-06-23 20:22:28 +02:00
|
|
|
:version "24.4"
|
|
|
|
:group 'eww
|
|
|
|
:type 'string)
|
|
|
|
|
|
|
|
(defcustom eww-search-prefix "https://duckduckgo.com/html/?q="
|
2015-03-04 12:34:48 +01:00
|
|
|
"Prefix URL to search engine."
|
2013-06-23 20:22:28 +02:00
|
|
|
:version "24.4"
|
2013-06-16 22:20:55 +00:00
|
|
|
:group 'eww
|
|
|
|
:type 'string)
|
|
|
|
|
2020-11-24 08:22:26 +01:00
|
|
|
(defcustom eww-use-browse-url "\\`mailto:"
|
2021-09-19 16:48:35 +02:00
|
|
|
"EWW will use `browse-url' when following links that match this regexp.
|
2020-11-29 10:54:58 +01:00
|
|
|
The action to be taken can be further customized via
|
2020-11-24 08:22:26 +01:00
|
|
|
`browse-url-handlers'."
|
|
|
|
:version "28.1"
|
|
|
|
:type 'regexp)
|
|
|
|
|
2023-03-29 21:27:09 +03:00
|
|
|
(defcustom eww-default-download-directory "~/Downloads/"
|
|
|
|
"Default directory where `eww' saves downloaded files.
|
|
|
|
Used by `eww--download-directory', which see."
|
2023-03-26 14:58:40 +03:00
|
|
|
:version "29.1"
|
2023-03-25 21:38:48 +08:00
|
|
|
:group 'eww
|
2023-03-26 14:56:57 +03:00
|
|
|
:type 'directory)
|
2023-03-25 21:38:48 +08:00
|
|
|
|
2022-08-04 11:04:51 +02:00
|
|
|
(defun eww--download-directory ()
|
2023-03-26 14:56:57 +03:00
|
|
|
"Return the name of the EWW download directory.
|
2023-03-29 21:28:53 +03:00
|
|
|
The default is specified by `eww-default-download-directory'; however,
|
2023-03-26 14:56:57 +03:00
|
|
|
if that directory doesn't exist and the DOWNLOAD XDG user directory
|
|
|
|
is defined, use the latter instead."
|
2023-03-29 21:28:02 +03:00
|
|
|
(or (and (file-exists-p eww-default-download-directory)
|
2023-03-29 21:27:09 +03:00
|
|
|
eww-default-download-directory)
|
2020-07-29 07:13:56 +02:00
|
|
|
(when-let ((dir (xdg-user-dir "DOWNLOAD")))
|
|
|
|
(file-name-as-directory dir))
|
2023-03-29 21:27:09 +03:00
|
|
|
eww-default-download-directory))
|
2020-07-29 07:13:56 +02:00
|
|
|
|
2022-08-04 11:04:51 +02:00
|
|
|
(defcustom eww-download-directory 'eww--download-directory
|
2020-07-29 07:13:56 +02:00
|
|
|
"Directory where files will downloaded.
|
|
|
|
This should either be a directory name or a function (called with
|
|
|
|
no parameters) that returns a directory name."
|
|
|
|
:version "28.1"
|
2013-06-25 21:50:05 +02:00
|
|
|
:group 'eww
|
2020-07-29 07:13:56 +02:00
|
|
|
:type '(choice directory function))
|
2013-06-25 21:50:05 +02:00
|
|
|
|
2015-02-16 19:01:50 +00:00
|
|
|
;;;###autoload
|
2014-11-23 16:55:03 +01:00
|
|
|
(defcustom eww-suggest-uris
|
|
|
|
'(eww-links-at-point
|
2019-05-13 15:17:00 -04:00
|
|
|
thing-at-point-url-at-point
|
2023-04-13 15:59:54 +00:00
|
|
|
eww-current-url
|
|
|
|
eww-bookmark-urls)
|
2014-11-23 16:55:03 +01:00
|
|
|
"List of functions called to form the list of default URIs for `eww'.
|
|
|
|
Each of the elements is a function returning either a string or a list
|
|
|
|
of strings. The results will be joined into a single list with
|
|
|
|
duplicate entries (if any) removed."
|
2023-11-04 08:09:14 +05:30
|
|
|
:version "30.1"
|
2014-11-23 16:55:03 +01:00
|
|
|
:group 'eww
|
|
|
|
:type 'hook
|
|
|
|
:options '(eww-links-at-point
|
2019-05-13 15:17:00 -04:00
|
|
|
thing-at-point-url-at-point
|
2023-04-13 15:59:54 +00:00
|
|
|
eww-current-url
|
|
|
|
eww-bookmark-urls))
|
2014-11-23 16:55:03 +01:00
|
|
|
|
2014-08-05 20:15:52 +02:00
|
|
|
(defcustom eww-bookmarks-directory user-emacs-directory
|
|
|
|
"Directory where bookmark files will be stored."
|
2014-09-29 14:14:08 -04:00
|
|
|
:version "25.1"
|
2014-08-05 20:15:52 +02:00
|
|
|
:group 'eww
|
2017-01-27 13:09:01 -05:00
|
|
|
:type 'directory)
|
2014-08-05 20:15:52 +02:00
|
|
|
|
2014-11-19 18:21:58 +01:00
|
|
|
(defcustom eww-desktop-remove-duplicates t
|
|
|
|
"Whether to remove duplicates from the history when saving desktop data.
|
|
|
|
If non-nil, repetitive EWW history entries (comprising of the URI, the
|
|
|
|
title, and the point position) will not be saved as part of the Emacs
|
|
|
|
desktop. Otherwise, such entries will be retained."
|
|
|
|
:version "25.1"
|
|
|
|
:group 'eww
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
|
|
(defcustom eww-restore-desktop nil
|
|
|
|
"How to restore EWW buffers on `desktop-restore'.
|
2015-11-17 15:28:50 -08:00
|
|
|
If t or `auto', the buffers will be reloaded automatically.
|
2014-11-19 18:21:58 +01:00
|
|
|
If nil, buffers will require manual reload, and will contain the text
|
|
|
|
specified in `eww-restore-reload-prompt' instead of the actual Web
|
|
|
|
page contents."
|
|
|
|
:version "25.1"
|
|
|
|
:group 'eww
|
|
|
|
:type '(choice (const :tag "Restore all automatically" t)
|
|
|
|
(const :tag "Require manual reload" nil)))
|
|
|
|
|
|
|
|
(defcustom eww-restore-reload-prompt
|
|
|
|
"\n\n *** Use \\[eww-reload] to reload this buffer. ***\n"
|
|
|
|
"The string to put in the buffers not reloaded on `desktop-restore'.
|
|
|
|
This prompt will be used if `eww-restore-desktop' is nil.
|
|
|
|
|
|
|
|
The string will be passed through `substitute-command-keys'."
|
|
|
|
:version "25.1"
|
|
|
|
:group 'eww
|
|
|
|
:type 'string)
|
|
|
|
|
2014-11-19 18:28:19 +01:00
|
|
|
(defcustom eww-history-limit 50
|
|
|
|
"Maximum number of entries to retain in the history."
|
|
|
|
:version "25.1"
|
|
|
|
:group 'eww
|
|
|
|
:type '(choice (const :tag "Unlimited" nil)
|
|
|
|
integer))
|
2014-11-23 16:55:03 +01:00
|
|
|
|
2020-09-13 00:12:33 +02:00
|
|
|
(defcustom eww-retrieve-command nil
|
|
|
|
"Command to retrieve an URL via an external program.
|
2021-09-20 10:16:09 +03:00
|
|
|
If nil, `url-retrieve' is used to download the data.
|
|
|
|
If `sync', `url-retrieve-synchronously' is used.
|
2021-10-21 15:53:35 +02:00
|
|
|
For other non-nil values, this should be a list of strings where
|
|
|
|
the first item is the program, and the rest are the arguments."
|
2020-09-13 00:12:33 +02:00
|
|
|
:version "28.1"
|
|
|
|
:type '(choice (const :tag "Use `url-retrieve'" nil)
|
2021-09-20 10:16:09 +03:00
|
|
|
(const :tag "Use `url-retrieve-synchronously'" sync)
|
2021-10-21 15:53:35 +02:00
|
|
|
(repeat :tag "Command/args" string )))
|
2020-09-13 00:12:33 +02:00
|
|
|
|
2013-12-01 16:44:25 +01:00
|
|
|
(defcustom eww-use-external-browser-for-content-type
|
|
|
|
"\\`\\(video/\\|audio/\\|application/ogg\\)"
|
|
|
|
"Always use external browser for specified content-type."
|
|
|
|
:version "24.4"
|
|
|
|
:group 'eww
|
|
|
|
:type '(choice (const :tag "Never" nil)
|
|
|
|
regexp))
|
|
|
|
|
2019-10-20 01:40:05 +03:00
|
|
|
(defcustom eww-browse-url-new-window-is-tab 'tab-bar
|
|
|
|
"Whether to open up new windows in a tab or a new buffer.
|
|
|
|
If t, then open the URL in a new tab rather than a new buffer if
|
|
|
|
`eww-browse-url' is asked to open it in a new window.
|
|
|
|
If `tab-bar', then open the URL in a new tab only when
|
|
|
|
the tab bar is enabled."
|
|
|
|
:version "27.1"
|
|
|
|
:group 'eww
|
|
|
|
:type '(choice (const :tag "Always open URL in new tab" t)
|
|
|
|
(const :tag "Open new tab when tab bar is enabled" tab-bar)
|
|
|
|
(const :tag "Never open URL in new tab" nil)))
|
|
|
|
|
2024-02-17 20:49:15 -08:00
|
|
|
(defcustom eww-before-browse-history-function #'eww-delete-future-history
|
|
|
|
"A function to call to update history before browsing to a new page.
|
|
|
|
EWW provides the following values for this option:
|
|
|
|
|
|
|
|
* `eww-delete-future-history': Delete any history entries after the
|
|
|
|
currently-shown one. This is the default behavior, and works the same
|
|
|
|
as in most other web browsers.
|
|
|
|
|
|
|
|
* `eww-clone-previous-history': Clone and prepend any history entries up
|
|
|
|
to the currently-shown one. This is like `eww-delete-future-history',
|
|
|
|
except that it preserves the previous contents of the history list at
|
|
|
|
the end.
|
|
|
|
|
|
|
|
* `ignore': Preserve the current history unchanged. This will result in
|
|
|
|
the new page simply being prepended to the existing history list.
|
|
|
|
|
|
|
|
You can also set this to any other function you wish."
|
|
|
|
:version "30.1"
|
|
|
|
:group 'eww
|
|
|
|
:type '(choice (function-item :tag "Delete future history"
|
|
|
|
eww-delete-future-history)
|
|
|
|
(function-item :tag "Clone previous history"
|
|
|
|
eww-clone-previous-history)
|
|
|
|
(function-item :tag "Preserve history"
|
|
|
|
ignore)
|
|
|
|
(function :tag "Custom function")))
|
|
|
|
|
2014-11-13 22:41:55 +01:00
|
|
|
(defcustom eww-after-render-hook nil
|
|
|
|
"A hook called after eww has finished rendering the buffer."
|
|
|
|
:version "25.1"
|
|
|
|
:group 'eww
|
|
|
|
:type 'hook)
|
|
|
|
|
2021-10-15 14:12:32 +02:00
|
|
|
(defcustom eww-auto-rename-buffer nil
|
|
|
|
"Automatically rename EWW buffers once the page is rendered.
|
|
|
|
|
|
|
|
When nil, do not rename the buffer. With a non-nil value
|
|
|
|
determine the renaming scheme, as follows:
|
|
|
|
|
|
|
|
- `title': Use the web page's title.
|
|
|
|
- `url': Use the web page's URL.
|
|
|
|
- a function's symbol: Run a user-defined function that returns a
|
2021-10-18 10:07:03 +03:00
|
|
|
string with which to rename the buffer. Sample of a
|
|
|
|
user-defined function:
|
|
|
|
|
|
|
|
(defun my-eww-rename-buffer ()
|
2022-05-24 13:17:53 +02:00
|
|
|
(when (eq major-mode \\='eww-mode)
|
2021-10-18 10:07:03 +03:00
|
|
|
(when-let ((string (or (plist-get eww-data :title)
|
|
|
|
(plist-get eww-data :url))))
|
|
|
|
(format \"*%s*\" string))))
|
2021-10-15 14:12:32 +02:00
|
|
|
|
|
|
|
The string of `title' and `url' is always truncated to the value
|
|
|
|
of `eww-buffer-name-length'."
|
|
|
|
:version "29.1"
|
|
|
|
:type '(choice
|
|
|
|
(const :tag "Do not rename buffers (default)" nil)
|
|
|
|
(const :tag "Rename buffer to web page title" title)
|
|
|
|
(const :tag "Rename buffer to web page URL" url)
|
|
|
|
(function :tag "A user-defined function to rename the buffer"))
|
|
|
|
:group 'eww)
|
|
|
|
|
|
|
|
(defcustom eww-buffer-name-length 40
|
|
|
|
"Length of renamed buffer name, per `eww-auto-rename-buffer'."
|
|
|
|
:type 'natnum
|
|
|
|
:version "29.1"
|
|
|
|
:group 'eww)
|
|
|
|
|
2013-12-01 16:52:04 +01:00
|
|
|
(defcustom eww-form-checkbox-selected-symbol "[X]"
|
|
|
|
"Symbol used to represent a selected checkbox.
|
|
|
|
See also `eww-form-checkbox-symbol'."
|
|
|
|
:version "24.4"
|
|
|
|
:group 'eww
|
|
|
|
:type '(choice (const "[X]")
|
|
|
|
(const "☒") ; Unicode BALLOT BOX WITH X
|
|
|
|
(const "☑") ; Unicode BALLOT BOX WITH CHECK
|
|
|
|
string))
|
|
|
|
|
|
|
|
(defcustom eww-form-checkbox-symbol "[ ]"
|
|
|
|
"Symbol used to represent a checkbox.
|
|
|
|
See also `eww-form-checkbox-selected-symbol'."
|
|
|
|
:version "24.4"
|
|
|
|
:group 'eww
|
|
|
|
:type '(choice (const "[ ]")
|
|
|
|
(const "☐") ; Unicode BALLOT BOX
|
|
|
|
string))
|
|
|
|
|
2021-11-07 00:45:01 +01:00
|
|
|
(defcustom eww-url-transformers '(eww-remove-tracking)
|
|
|
|
"This is a list of transforming functions applied to an URL before usage.
|
|
|
|
The functions will be called with the URL as the single
|
|
|
|
parameter, and should return the (possibly) transformed URL."
|
|
|
|
:type '(repeat function)
|
|
|
|
:version "29.1")
|
|
|
|
|
2024-03-18 16:52:34 -07:00
|
|
|
(defcustom eww-readable-urls nil
|
|
|
|
"A list of regexps matching URLs to display in readable mode by default.
|
|
|
|
EWW will display matching URLs using `eww-readable' (which see).
|
|
|
|
|
|
|
|
Each element can be one of the following forms: a regular expression in
|
|
|
|
string form or a cons cell of the form (REGEXP . READABILITY). If
|
|
|
|
READABILITY is non-nil, this behaves the same as the string form;
|
|
|
|
otherwise, URLs matching REGEXP will never be displayed in readable mode
|
|
|
|
by default."
|
|
|
|
:type '(repeat (choice (string :tag "Readable URL")
|
|
|
|
(cons :tag "URL and Readability"
|
|
|
|
(string :tag "URL")
|
|
|
|
(radio (const :tag "Readable" t)
|
|
|
|
(const :tag "Non-readable" nil)))))
|
|
|
|
:version "30.1")
|
|
|
|
|
2024-03-17 12:01:59 -07:00
|
|
|
(defcustom eww-readable-adds-to-history t
|
|
|
|
"If non-nil, calling `eww-readable' adds a new entry to the history."
|
|
|
|
:type 'boolean
|
|
|
|
:version "30.1")
|
|
|
|
|
2013-06-19 22:28:04 +00:00
|
|
|
(defface eww-form-submit
|
Bring up the Android operating system and its window system
* .dir-locals.el (c-mode): Add ANDROID_EXPORT noise macro.
* .gitignore: Add new files to ignore.
* Makefile.in: Adjust for Android.
* admin/merge-gnulib: Add new warning.
* configure.ac: Detect Android. Run cross-configuration for
Android when appropriate.
* etc/DEBUG: Document how to debug Emacs on Android.
* java/AndroidManifest.xml:
* java/Makefile.in:
* java/README:
* java/debug.sh:
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity):
* java/org/gnu/emacs/EmacsApplication.java (EmacsApplication):
* java/org/gnu/emacs/EmacsCopyArea.java (EmacsCopyArea):
* java/org/gnu/emacs/EmacsDrawLine.java (EmacsDrawLine):
* java/org/gnu/emacs/EmacsDrawPoint.java (EmacsDrawPoint):
* java/org/gnu/emacs/EmacsDrawRectangle.java
(EmacsDrawRectangle):
* java/org/gnu/emacs/EmacsDrawable.java (EmacsDrawable):
* java/org/gnu/emacs/EmacsFillPolygon.java (EmacsFillPolygon):
* java/org/gnu/emacs/EmacsFillRectangle.java
(EmacsFillRectangle):
* java/org/gnu/emacs/EmacsFontDriver.java (EmacsFontDriver):
* java/org/gnu/emacs/EmacsGC.java (EmacsGC):
* java/org/gnu/emacs/EmacsHandleObject.java (EmacsHandleObject):
* java/org/gnu/emacs/EmacsNative.java (EmacsNative):
* java/org/gnu/emacs/EmacsPaintQueue.java (EmacsPaintQueue):
* java/org/gnu/emacs/EmacsPaintReq.java (EmacsPaintReq):
* java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java
(EmacsSdk7FontDriver):
* java/org/gnu/emacs/EmacsService.java (class Holder<T>)
(EmacsService):
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView):
* java/org/gnu/emacs/EmacsThread.java (EmacsThread):
* java/org/gnu/emacs/EmacsView.java (EmacsView):
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow): New files
and classes.
* lib-src/Makefile.in (srcdir):
* lib/Makefile.in (VPATH):
(HAVE_NATIVE_COMP):
(libgnu_a_SOURCES):
(DEPFLAGS): Configure correctly for cross-compiling.
* lib/faccessat.c:
* lib/fpending.c (__fpending):
* lib/open.c:
* lib/unistd.c (_GL_UNISTD_INLINE): Temporary adjustments to
gnulib.
* lisp/frame.el (display-graphic-p):
(display-screens):
(display-pixel-height):
(display-pixel-width):
(display-mm-height):
(display-mm-width):
(display-backing-store):
(display-save-under):
(display-planes):
(display-color-cells):
(display-visual-class): Adjust for new window system `android'.
* lisp/image/wallpaper.el (x-open-connection): Add declaration.
* lisp/loadup.el (featurep): Load up files for Android.
* lisp/net/eww.el (eww-form-submit, eww-form-file)
(eww-form-checkbox, eww-form-select): Adjust faces for android.
* lisp/term/android-win.el: New file.
* src/Makefile.in: Add new targets emacs.so and android-emacs,
then adjust for cross compilation.
* src/alloc.c (cleanup_vector): Clean up Android font entities
as well.
(garbage_collect): Mark androidterm.
* src/android-emacs.c (main):
* src/android.c (ANDROID_THROW, enum android_fd_table_entry_flags)
(struct android_emacs_service, struct android_emacs_pixmap)
(struct android_graphics_point, struct android_event_container)
(struct android_event_queue, android_run_select_thread)
(android_handle_sigusr1, android_init_events, android_pending)
(android_next_event, android_write_event, android_select)
(android_run_debug_thread, android_user_full_name)
(android_get_asset_name, android_fstat, android_fstatat)
(android_file_access_p, android_hack_asset_fd, android_open)
(android_close, JNICALL, android_init_emacs_service)
(android_init_emacs_pixmap, android_init_graphics_point)
(MAX_HANDLE, struct android_handle_entry, android_alloc_id)
(android_destroy_handle, android_resolve_handle)
(android_resolve_handle2, android_change_window_attributes)
(android_create_window, android_set_window_background)
(android_destroy_window, android_init_android_rect_class)
(android_init_emacs_gc_class, android_create_gc, android_free_gc)
(android_change_gc, android_set_clip_rectangles)
(android_reparent_window, android_lookup_method)
(android_clear_window, android_map_window, android_unmap_window)
(android_resize_window, android_move_window, android_swap_buffers)
(android_get_gc_values, android_set_foreground)
(android_fill_rectangle, android_create_pixmap_from_bitmap_data)
(android_set_clip_mask, android_set_fill_style, android_copy_area)
(android_free_pixmap, android_set_background, android_fill_polygon)
(android_draw_rectangle, android_draw_point, android_draw_line)
(android_create_pixmap, android_set_ts_origin, android_clear_area):
* src/android.h (ANDROID_EXPORT):
* src/androidfns.c (android_display_info_for_name)
(check_android_display_info, check_x_display_info, gamma_correct)
(android_defined_color, android_decode_color)
(android_implicitly_set_name, android_explicitly_set_name)
(android_set_tool_bar_lines, android_change_tool_bar_height)
(android_set_tab_bar_lines, android_change_tab_bar_height)
(android_set_scroll_bar_default_height)
(android_set_scroll_bar_default_width, android_icon_verify)
(android_icon, android_make_gc, android_free_gcs)
(unwind_create_frame, do_unwind_create_frame)
(android_default_font_parameter, android_create_frame_window)
(Fx_create_frame, Fxw_color_defined_p, Fxw_color_values)
(Fxw_display_color_p, Fx_display_grayscale_p)
(Fx_display_pixel_width, Fx_display_pixel_height)
(Fx_display_planes, Fx_display_color_cells, Fx_display_screens)
(Fx_display_mm_width, Fx_display_mm_height)
(Fx_display_backing_store, Fx_display_visual_class)
(Fx_display_monitor_attributes_list, Fx_frame_geometry)
(Fx_frame_list_z_order, Fx_frame_restack)
(Fx_mouse_absolute_pixel_position)
(Fx_set_mouse_absolute_pixel_position, Fandroid_get_connection)
(Fx_display_list, Fx_show_tip, Fx_hide_tip)
(android_set_background_color, android_set_border_color)
(android_set_cursor_color, android_set_cursor_type)
(android_set_foreground_color)
(android_set_child_frame_border_width)
(android_set_internal_border_width, android_set_menu_bar_lines)
(android_set_mouse_color, android_set_title, android_set_alpha)
(android_frame_parm_handlers, syms_of_androidfns):
* src/androidfont.c (struct android_emacs_font_driver)
(struct android_emacs_font_spec, struct android_emacs_font_metrics)
(struct android_emacs_font_object, struct android_integer)
(struct androidfont_info, struct androidfont_entity)
(android_init_font_driver, android_init_font_spec)
(android_init_font_metrics, android_init_integer)
(android_init_font_object, androidfont_get_cache)
(androidfont_from_lisp, androidfont_from_java, androidfont_list)
(androidfont_match, androidfont_draw, androidfont_open_font)
(androidfont_close_font, androidfont_has_char)
(androidfont_encode_char, androidfont_text_extents)
(androidfont_list_family, androidfont_driver)
(syms_of_androidfont_for_pdumper, syms_of_androidfont)
(init_androidfont, android_finalize_font_entity):
* src/androidgui.h (_ANDROID_GUI_H_, struct android_rectangle)
(struct android_point, enum android_gc_function)
(enum android_gc_value_mask, enum android_fill_style)
(enum android_window_value_mask)
(struct android_set_window_attributes, struct android_gc_values)
(struct android_gc, enum android_swap_action, enum android_shape)
(enum android_coord_mode, struct android_swap_info)
(NativeRectangle, struct android_any_event)
(struct android_key_event, struct android_configure_event)
(union android_event):
* src/androidterm.c (android_window_to_frame, android_clear_frame)
(android_ring_bell, android_toggle_invisible_pointer)
(android_update_begin, android_update_end, show_back_buffer)
(android_flush_dirty_back_buffer_on, handle_one_android_event)
(android_read_socket, android_frame_up_to_date)
(android_buffer_flipping_unblocked_hook)
(android_query_frame_background_color, android_parse_color)
(android_alloc_nearest_color, android_query_colors)
(android_mouse_position, android_get_focus_frame)
(android_focus_frame, android_frame_rehighlight)
(android_frame_raise_lower, android_make_frame_visible)
(android_make_frame_invisible)
(android_make_frame_visible_invisible, android_fullscreen_hook)
(android_iconify_frame, android_set_window_size_1)
(android_set_window_size, android_set_offset, android_set_alpha)
(android_new_font, android_bitmap_icon, android_free_pixmap_hook)
(android_free_frame_resources, android_delete_frame)
(android_delete_terminal, android_scroll_run)
(android_after_update_window_line, android_flip_and_flush)
(android_clear_rectangle, android_reset_clip_rectangles)
(android_clip_to_row, android_draw_fringe_bitmap)
(android_set_cursor_gc, android_set_mouse_face_gc)
(android_set_mode_line_face_gc, android_set_glyph_string_gc)
(android_set_glyph_string_clipping)
(android_set_glyph_string_clipping_exactly)
(android_compute_glyph_string_overhangs)
(android_clear_glyph_string_rect)
(android_draw_glyph_string_background, android_fill_triangle)
(android_make_point, android_inside_rect_p, android_clear_point)
(android_draw_relief_rect, android_draw_box_rect)
(HIGHLIGHT_COLOR_DARK_BOOST_LIMIT, android_setup_relief_color)
(android_setup_relief_colors, android_draw_glyph_string_box)
(android_draw_glyph_string_bg_rect, android_draw_image_relief)
(android_draw_image_foreground, android_draw_image_foreground_1)
(android_draw_image_glyph_string)
(android_draw_stretch_glyph_string, android_draw_underwave)
(android_draw_glyph_string_foreground)
(android_draw_composite_glyph_string_foreground)
(android_draw_glyphless_glyph_string_foreground)
(android_draw_glyph_string, android_define_frame_cursor)
(android_clear_frame_area, android_clear_under_internal_border)
(android_draw_hollow_cursor, android_draw_bar_cursor)
(android_draw_window_cursor, android_draw_vertical_window_border)
(android_draw_window_divider, android_redisplay_interface)
(frame_set_mouse_pixel_position, get_keysym_name)
(android_create_terminal, android_term_init, syms_of_androidterm)
(mark_androidterm):
* src/androidterm.h (_ANDROID_TERM_H_, struct android_display_info)
(struct android_output, FRAME_ANDROID_OUTPUT, XSCROLL_BAR): New
files.
* src/dired.c (file_attributes): Do not use openat on Android.
* src/dispextern.h (No_Cursor): Define appropriately on Android.
(struct glyph_string, struct face): Make gc field of type struct
android_gc on Android.
* src/dispnew.c (clear_current_matrices, clear_desired_matrices)
(adjust_frame_glyphs_for_window_redisplay, free_glyphs)
(update_frame, scrolling, char_ins_del_cost, update_frame_line)
(init_display_interactive): Disable text terminal support
completely on Android. Fix non-toolkit menus for non-X systems.
* src/editfns.c (Fuser_full_name): Call android_user_full_name.
* src/emacs.c (android_emacs_init): Make main this on Android.
Prohibit argv sorting from exceeding end of argv.
* src/epaths.in: Add path definitions for Android.
* src/fileio.c (file_access_p): Call android_file_access_p.
(file_name_directory): Avoid using openat on Android.
(Fcopy_file): Adjust to call sys_fstat instead.
(file_directory_p):
(Finsert_file_contents):
(write_region): Likewise.
* src/filelock.c:
* src/fns.c (Flocale_info): Pacify warning on Android.
* src/font.c (font_make_entity_android): New function.
* src/font.h:
* src/frame.c (Fframep):
(Fwindow_system): Handle new window system `android'. Update doc strings.
(Fmake_terminal_frame): Disable on Android.
(gui_display_get_resource): Disable get_string_resource_hook on Android.
(syms_of_frame): New defsym `android'.
* src/frame.h (GCALIGNED_STRUCT): Add new output data for
Android.
(ENUM_BF): Expand enumerator size.
(FRAME_ANDROID_P, FRAME_WINDOW_P, MOUSE_HL_INFO): Add
definitions for Android.
* src/image.c (GET_PIXEL):
(image_create_bitmap_from_file):
(image_create_x_image_and_pixmap_1):
(image_get_x_image):
(slurp_file):
(lookup_rgb_color):
(image_to_emacs_colors):
(image_from_emacs_colors):
(image_pixmap_draw_cross):
(image_disable_image):
(MaskForeground):
(gif_load): Add stubs for Android.
* src/lisp.h:
* src/lread.c (safe_to_load_version, maybe_swap_for_eln1, openp):
* src/pdumper.c (pdumper_load): Call sys_fstat instead of fstat.
* src/process.c (wait_reading_process_output): Use
android_select instead of pselect.
* src/scroll.c: Disable on Android.
* src/sysdep.c (widen_foreground_group, reset_sys_modes)
(init_signals, emacs_fstatat, sys_fstat): New function.
(emacs_open, emacs_open_noquit, emacs_close): Implement
differently on Android.
(close_output_streams): Disable what is not required on Android.
* src/term.c (OUTPUT1_IF, encode_terminal_code, string_cost)
(string_cost_one_line, per_line_cost, calculate_costs)
(struct fkey_table, tty_append_glyph, produce_glyphs)
(tty_capable_p, Fsuspend_tty, Fresume_tty, device, init_tty)
(maybe_fatal, syms_of_term): Disable text terminal support on
Android.
* src/termhooks.h (enum output_method): Add android output
method.
(GCALIGNED_STRUCT, TERMINAL_FONT_CACHE): Define for Android.
* src/terminal.c (Fterminal_live_p): Implement for Android.
* src/verbose.mk.in (AM_V_GLOBALS): Add JAVAC and DX.
* src/xdisp.c (redisplay_internal): Disable text terminals on Android.
(display_menu_bar):
(display_tty_menu_item):
(draw_row_with_mouse_face):
(expose_frame): Make the non toolkit menu bar work on Android.
* src/xfaces.c (GCGraphicsExposures):
(x_create_gc):
(x_free_gc):
(Fx_load_color_file): Define for Android.
* xcompile/Makefile.in (top_srcdir):
(top_builddir):
* xcompile/README:
* xcompile/langinfo.h (nl_langinfo): New files.
2022-12-31 18:04:18 +08:00
|
|
|
'((((type x w32 ns haiku pgtk android) (class color)) ; Like default mode line
|
2013-06-19 22:28:04 +00:00
|
|
|
:box (:line-width 2 :style released-button)
|
|
|
|
:background "#808080" :foreground "black"))
|
|
|
|
"Face for eww buffer buttons."
|
|
|
|
:version "24.4"
|
|
|
|
:group 'eww)
|
|
|
|
|
2014-11-10 22:33:55 +01:00
|
|
|
(defface eww-form-file
|
Bring up the Android operating system and its window system
* .dir-locals.el (c-mode): Add ANDROID_EXPORT noise macro.
* .gitignore: Add new files to ignore.
* Makefile.in: Adjust for Android.
* admin/merge-gnulib: Add new warning.
* configure.ac: Detect Android. Run cross-configuration for
Android when appropriate.
* etc/DEBUG: Document how to debug Emacs on Android.
* java/AndroidManifest.xml:
* java/Makefile.in:
* java/README:
* java/debug.sh:
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity):
* java/org/gnu/emacs/EmacsApplication.java (EmacsApplication):
* java/org/gnu/emacs/EmacsCopyArea.java (EmacsCopyArea):
* java/org/gnu/emacs/EmacsDrawLine.java (EmacsDrawLine):
* java/org/gnu/emacs/EmacsDrawPoint.java (EmacsDrawPoint):
* java/org/gnu/emacs/EmacsDrawRectangle.java
(EmacsDrawRectangle):
* java/org/gnu/emacs/EmacsDrawable.java (EmacsDrawable):
* java/org/gnu/emacs/EmacsFillPolygon.java (EmacsFillPolygon):
* java/org/gnu/emacs/EmacsFillRectangle.java
(EmacsFillRectangle):
* java/org/gnu/emacs/EmacsFontDriver.java (EmacsFontDriver):
* java/org/gnu/emacs/EmacsGC.java (EmacsGC):
* java/org/gnu/emacs/EmacsHandleObject.java (EmacsHandleObject):
* java/org/gnu/emacs/EmacsNative.java (EmacsNative):
* java/org/gnu/emacs/EmacsPaintQueue.java (EmacsPaintQueue):
* java/org/gnu/emacs/EmacsPaintReq.java (EmacsPaintReq):
* java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java
(EmacsSdk7FontDriver):
* java/org/gnu/emacs/EmacsService.java (class Holder<T>)
(EmacsService):
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView):
* java/org/gnu/emacs/EmacsThread.java (EmacsThread):
* java/org/gnu/emacs/EmacsView.java (EmacsView):
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow): New files
and classes.
* lib-src/Makefile.in (srcdir):
* lib/Makefile.in (VPATH):
(HAVE_NATIVE_COMP):
(libgnu_a_SOURCES):
(DEPFLAGS): Configure correctly for cross-compiling.
* lib/faccessat.c:
* lib/fpending.c (__fpending):
* lib/open.c:
* lib/unistd.c (_GL_UNISTD_INLINE): Temporary adjustments to
gnulib.
* lisp/frame.el (display-graphic-p):
(display-screens):
(display-pixel-height):
(display-pixel-width):
(display-mm-height):
(display-mm-width):
(display-backing-store):
(display-save-under):
(display-planes):
(display-color-cells):
(display-visual-class): Adjust for new window system `android'.
* lisp/image/wallpaper.el (x-open-connection): Add declaration.
* lisp/loadup.el (featurep): Load up files for Android.
* lisp/net/eww.el (eww-form-submit, eww-form-file)
(eww-form-checkbox, eww-form-select): Adjust faces for android.
* lisp/term/android-win.el: New file.
* src/Makefile.in: Add new targets emacs.so and android-emacs,
then adjust for cross compilation.
* src/alloc.c (cleanup_vector): Clean up Android font entities
as well.
(garbage_collect): Mark androidterm.
* src/android-emacs.c (main):
* src/android.c (ANDROID_THROW, enum android_fd_table_entry_flags)
(struct android_emacs_service, struct android_emacs_pixmap)
(struct android_graphics_point, struct android_event_container)
(struct android_event_queue, android_run_select_thread)
(android_handle_sigusr1, android_init_events, android_pending)
(android_next_event, android_write_event, android_select)
(android_run_debug_thread, android_user_full_name)
(android_get_asset_name, android_fstat, android_fstatat)
(android_file_access_p, android_hack_asset_fd, android_open)
(android_close, JNICALL, android_init_emacs_service)
(android_init_emacs_pixmap, android_init_graphics_point)
(MAX_HANDLE, struct android_handle_entry, android_alloc_id)
(android_destroy_handle, android_resolve_handle)
(android_resolve_handle2, android_change_window_attributes)
(android_create_window, android_set_window_background)
(android_destroy_window, android_init_android_rect_class)
(android_init_emacs_gc_class, android_create_gc, android_free_gc)
(android_change_gc, android_set_clip_rectangles)
(android_reparent_window, android_lookup_method)
(android_clear_window, android_map_window, android_unmap_window)
(android_resize_window, android_move_window, android_swap_buffers)
(android_get_gc_values, android_set_foreground)
(android_fill_rectangle, android_create_pixmap_from_bitmap_data)
(android_set_clip_mask, android_set_fill_style, android_copy_area)
(android_free_pixmap, android_set_background, android_fill_polygon)
(android_draw_rectangle, android_draw_point, android_draw_line)
(android_create_pixmap, android_set_ts_origin, android_clear_area):
* src/android.h (ANDROID_EXPORT):
* src/androidfns.c (android_display_info_for_name)
(check_android_display_info, check_x_display_info, gamma_correct)
(android_defined_color, android_decode_color)
(android_implicitly_set_name, android_explicitly_set_name)
(android_set_tool_bar_lines, android_change_tool_bar_height)
(android_set_tab_bar_lines, android_change_tab_bar_height)
(android_set_scroll_bar_default_height)
(android_set_scroll_bar_default_width, android_icon_verify)
(android_icon, android_make_gc, android_free_gcs)
(unwind_create_frame, do_unwind_create_frame)
(android_default_font_parameter, android_create_frame_window)
(Fx_create_frame, Fxw_color_defined_p, Fxw_color_values)
(Fxw_display_color_p, Fx_display_grayscale_p)
(Fx_display_pixel_width, Fx_display_pixel_height)
(Fx_display_planes, Fx_display_color_cells, Fx_display_screens)
(Fx_display_mm_width, Fx_display_mm_height)
(Fx_display_backing_store, Fx_display_visual_class)
(Fx_display_monitor_attributes_list, Fx_frame_geometry)
(Fx_frame_list_z_order, Fx_frame_restack)
(Fx_mouse_absolute_pixel_position)
(Fx_set_mouse_absolute_pixel_position, Fandroid_get_connection)
(Fx_display_list, Fx_show_tip, Fx_hide_tip)
(android_set_background_color, android_set_border_color)
(android_set_cursor_color, android_set_cursor_type)
(android_set_foreground_color)
(android_set_child_frame_border_width)
(android_set_internal_border_width, android_set_menu_bar_lines)
(android_set_mouse_color, android_set_title, android_set_alpha)
(android_frame_parm_handlers, syms_of_androidfns):
* src/androidfont.c (struct android_emacs_font_driver)
(struct android_emacs_font_spec, struct android_emacs_font_metrics)
(struct android_emacs_font_object, struct android_integer)
(struct androidfont_info, struct androidfont_entity)
(android_init_font_driver, android_init_font_spec)
(android_init_font_metrics, android_init_integer)
(android_init_font_object, androidfont_get_cache)
(androidfont_from_lisp, androidfont_from_java, androidfont_list)
(androidfont_match, androidfont_draw, androidfont_open_font)
(androidfont_close_font, androidfont_has_char)
(androidfont_encode_char, androidfont_text_extents)
(androidfont_list_family, androidfont_driver)
(syms_of_androidfont_for_pdumper, syms_of_androidfont)
(init_androidfont, android_finalize_font_entity):
* src/androidgui.h (_ANDROID_GUI_H_, struct android_rectangle)
(struct android_point, enum android_gc_function)
(enum android_gc_value_mask, enum android_fill_style)
(enum android_window_value_mask)
(struct android_set_window_attributes, struct android_gc_values)
(struct android_gc, enum android_swap_action, enum android_shape)
(enum android_coord_mode, struct android_swap_info)
(NativeRectangle, struct android_any_event)
(struct android_key_event, struct android_configure_event)
(union android_event):
* src/androidterm.c (android_window_to_frame, android_clear_frame)
(android_ring_bell, android_toggle_invisible_pointer)
(android_update_begin, android_update_end, show_back_buffer)
(android_flush_dirty_back_buffer_on, handle_one_android_event)
(android_read_socket, android_frame_up_to_date)
(android_buffer_flipping_unblocked_hook)
(android_query_frame_background_color, android_parse_color)
(android_alloc_nearest_color, android_query_colors)
(android_mouse_position, android_get_focus_frame)
(android_focus_frame, android_frame_rehighlight)
(android_frame_raise_lower, android_make_frame_visible)
(android_make_frame_invisible)
(android_make_frame_visible_invisible, android_fullscreen_hook)
(android_iconify_frame, android_set_window_size_1)
(android_set_window_size, android_set_offset, android_set_alpha)
(android_new_font, android_bitmap_icon, android_free_pixmap_hook)
(android_free_frame_resources, android_delete_frame)
(android_delete_terminal, android_scroll_run)
(android_after_update_window_line, android_flip_and_flush)
(android_clear_rectangle, android_reset_clip_rectangles)
(android_clip_to_row, android_draw_fringe_bitmap)
(android_set_cursor_gc, android_set_mouse_face_gc)
(android_set_mode_line_face_gc, android_set_glyph_string_gc)
(android_set_glyph_string_clipping)
(android_set_glyph_string_clipping_exactly)
(android_compute_glyph_string_overhangs)
(android_clear_glyph_string_rect)
(android_draw_glyph_string_background, android_fill_triangle)
(android_make_point, android_inside_rect_p, android_clear_point)
(android_draw_relief_rect, android_draw_box_rect)
(HIGHLIGHT_COLOR_DARK_BOOST_LIMIT, android_setup_relief_color)
(android_setup_relief_colors, android_draw_glyph_string_box)
(android_draw_glyph_string_bg_rect, android_draw_image_relief)
(android_draw_image_foreground, android_draw_image_foreground_1)
(android_draw_image_glyph_string)
(android_draw_stretch_glyph_string, android_draw_underwave)
(android_draw_glyph_string_foreground)
(android_draw_composite_glyph_string_foreground)
(android_draw_glyphless_glyph_string_foreground)
(android_draw_glyph_string, android_define_frame_cursor)
(android_clear_frame_area, android_clear_under_internal_border)
(android_draw_hollow_cursor, android_draw_bar_cursor)
(android_draw_window_cursor, android_draw_vertical_window_border)
(android_draw_window_divider, android_redisplay_interface)
(frame_set_mouse_pixel_position, get_keysym_name)
(android_create_terminal, android_term_init, syms_of_androidterm)
(mark_androidterm):
* src/androidterm.h (_ANDROID_TERM_H_, struct android_display_info)
(struct android_output, FRAME_ANDROID_OUTPUT, XSCROLL_BAR): New
files.
* src/dired.c (file_attributes): Do not use openat on Android.
* src/dispextern.h (No_Cursor): Define appropriately on Android.
(struct glyph_string, struct face): Make gc field of type struct
android_gc on Android.
* src/dispnew.c (clear_current_matrices, clear_desired_matrices)
(adjust_frame_glyphs_for_window_redisplay, free_glyphs)
(update_frame, scrolling, char_ins_del_cost, update_frame_line)
(init_display_interactive): Disable text terminal support
completely on Android. Fix non-toolkit menus for non-X systems.
* src/editfns.c (Fuser_full_name): Call android_user_full_name.
* src/emacs.c (android_emacs_init): Make main this on Android.
Prohibit argv sorting from exceeding end of argv.
* src/epaths.in: Add path definitions for Android.
* src/fileio.c (file_access_p): Call android_file_access_p.
(file_name_directory): Avoid using openat on Android.
(Fcopy_file): Adjust to call sys_fstat instead.
(file_directory_p):
(Finsert_file_contents):
(write_region): Likewise.
* src/filelock.c:
* src/fns.c (Flocale_info): Pacify warning on Android.
* src/font.c (font_make_entity_android): New function.
* src/font.h:
* src/frame.c (Fframep):
(Fwindow_system): Handle new window system `android'. Update doc strings.
(Fmake_terminal_frame): Disable on Android.
(gui_display_get_resource): Disable get_string_resource_hook on Android.
(syms_of_frame): New defsym `android'.
* src/frame.h (GCALIGNED_STRUCT): Add new output data for
Android.
(ENUM_BF): Expand enumerator size.
(FRAME_ANDROID_P, FRAME_WINDOW_P, MOUSE_HL_INFO): Add
definitions for Android.
* src/image.c (GET_PIXEL):
(image_create_bitmap_from_file):
(image_create_x_image_and_pixmap_1):
(image_get_x_image):
(slurp_file):
(lookup_rgb_color):
(image_to_emacs_colors):
(image_from_emacs_colors):
(image_pixmap_draw_cross):
(image_disable_image):
(MaskForeground):
(gif_load): Add stubs for Android.
* src/lisp.h:
* src/lread.c (safe_to_load_version, maybe_swap_for_eln1, openp):
* src/pdumper.c (pdumper_load): Call sys_fstat instead of fstat.
* src/process.c (wait_reading_process_output): Use
android_select instead of pselect.
* src/scroll.c: Disable on Android.
* src/sysdep.c (widen_foreground_group, reset_sys_modes)
(init_signals, emacs_fstatat, sys_fstat): New function.
(emacs_open, emacs_open_noquit, emacs_close): Implement
differently on Android.
(close_output_streams): Disable what is not required on Android.
* src/term.c (OUTPUT1_IF, encode_terminal_code, string_cost)
(string_cost_one_line, per_line_cost, calculate_costs)
(struct fkey_table, tty_append_glyph, produce_glyphs)
(tty_capable_p, Fsuspend_tty, Fresume_tty, device, init_tty)
(maybe_fatal, syms_of_term): Disable text terminal support on
Android.
* src/termhooks.h (enum output_method): Add android output
method.
(GCALIGNED_STRUCT, TERMINAL_FONT_CACHE): Define for Android.
* src/terminal.c (Fterminal_live_p): Implement for Android.
* src/verbose.mk.in (AM_V_GLOBALS): Add JAVAC and DX.
* src/xdisp.c (redisplay_internal): Disable text terminals on Android.
(display_menu_bar):
(display_tty_menu_item):
(draw_row_with_mouse_face):
(expose_frame): Make the non toolkit menu bar work on Android.
* src/xfaces.c (GCGraphicsExposures):
(x_create_gc):
(x_free_gc):
(Fx_load_color_file): Define for Android.
* xcompile/Makefile.in (top_srcdir):
(top_builddir):
* xcompile/README:
* xcompile/langinfo.h (nl_langinfo): New files.
2022-12-31 18:04:18 +08:00
|
|
|
'((((type x w32 ns haiku pgtk android) (class color)) ; Like default mode line
|
2014-11-10 22:33:55 +01:00
|
|
|
:box (:line-width 2 :style released-button)
|
|
|
|
:background "#808080" :foreground "black"))
|
|
|
|
"Face for eww buffer buttons."
|
2014-11-13 14:10:05 +01:00
|
|
|
:version "25.1"
|
2014-11-12 21:13:19 -08:00
|
|
|
:group 'eww)
|
2014-11-10 22:33:55 +01:00
|
|
|
|
2013-06-19 22:28:04 +00:00
|
|
|
(defface eww-form-checkbox
|
Bring up the Android operating system and its window system
* .dir-locals.el (c-mode): Add ANDROID_EXPORT noise macro.
* .gitignore: Add new files to ignore.
* Makefile.in: Adjust for Android.
* admin/merge-gnulib: Add new warning.
* configure.ac: Detect Android. Run cross-configuration for
Android when appropriate.
* etc/DEBUG: Document how to debug Emacs on Android.
* java/AndroidManifest.xml:
* java/Makefile.in:
* java/README:
* java/debug.sh:
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity):
* java/org/gnu/emacs/EmacsApplication.java (EmacsApplication):
* java/org/gnu/emacs/EmacsCopyArea.java (EmacsCopyArea):
* java/org/gnu/emacs/EmacsDrawLine.java (EmacsDrawLine):
* java/org/gnu/emacs/EmacsDrawPoint.java (EmacsDrawPoint):
* java/org/gnu/emacs/EmacsDrawRectangle.java
(EmacsDrawRectangle):
* java/org/gnu/emacs/EmacsDrawable.java (EmacsDrawable):
* java/org/gnu/emacs/EmacsFillPolygon.java (EmacsFillPolygon):
* java/org/gnu/emacs/EmacsFillRectangle.java
(EmacsFillRectangle):
* java/org/gnu/emacs/EmacsFontDriver.java (EmacsFontDriver):
* java/org/gnu/emacs/EmacsGC.java (EmacsGC):
* java/org/gnu/emacs/EmacsHandleObject.java (EmacsHandleObject):
* java/org/gnu/emacs/EmacsNative.java (EmacsNative):
* java/org/gnu/emacs/EmacsPaintQueue.java (EmacsPaintQueue):
* java/org/gnu/emacs/EmacsPaintReq.java (EmacsPaintReq):
* java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java
(EmacsSdk7FontDriver):
* java/org/gnu/emacs/EmacsService.java (class Holder<T>)
(EmacsService):
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView):
* java/org/gnu/emacs/EmacsThread.java (EmacsThread):
* java/org/gnu/emacs/EmacsView.java (EmacsView):
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow): New files
and classes.
* lib-src/Makefile.in (srcdir):
* lib/Makefile.in (VPATH):
(HAVE_NATIVE_COMP):
(libgnu_a_SOURCES):
(DEPFLAGS): Configure correctly for cross-compiling.
* lib/faccessat.c:
* lib/fpending.c (__fpending):
* lib/open.c:
* lib/unistd.c (_GL_UNISTD_INLINE): Temporary adjustments to
gnulib.
* lisp/frame.el (display-graphic-p):
(display-screens):
(display-pixel-height):
(display-pixel-width):
(display-mm-height):
(display-mm-width):
(display-backing-store):
(display-save-under):
(display-planes):
(display-color-cells):
(display-visual-class): Adjust for new window system `android'.
* lisp/image/wallpaper.el (x-open-connection): Add declaration.
* lisp/loadup.el (featurep): Load up files for Android.
* lisp/net/eww.el (eww-form-submit, eww-form-file)
(eww-form-checkbox, eww-form-select): Adjust faces for android.
* lisp/term/android-win.el: New file.
* src/Makefile.in: Add new targets emacs.so and android-emacs,
then adjust for cross compilation.
* src/alloc.c (cleanup_vector): Clean up Android font entities
as well.
(garbage_collect): Mark androidterm.
* src/android-emacs.c (main):
* src/android.c (ANDROID_THROW, enum android_fd_table_entry_flags)
(struct android_emacs_service, struct android_emacs_pixmap)
(struct android_graphics_point, struct android_event_container)
(struct android_event_queue, android_run_select_thread)
(android_handle_sigusr1, android_init_events, android_pending)
(android_next_event, android_write_event, android_select)
(android_run_debug_thread, android_user_full_name)
(android_get_asset_name, android_fstat, android_fstatat)
(android_file_access_p, android_hack_asset_fd, android_open)
(android_close, JNICALL, android_init_emacs_service)
(android_init_emacs_pixmap, android_init_graphics_point)
(MAX_HANDLE, struct android_handle_entry, android_alloc_id)
(android_destroy_handle, android_resolve_handle)
(android_resolve_handle2, android_change_window_attributes)
(android_create_window, android_set_window_background)
(android_destroy_window, android_init_android_rect_class)
(android_init_emacs_gc_class, android_create_gc, android_free_gc)
(android_change_gc, android_set_clip_rectangles)
(android_reparent_window, android_lookup_method)
(android_clear_window, android_map_window, android_unmap_window)
(android_resize_window, android_move_window, android_swap_buffers)
(android_get_gc_values, android_set_foreground)
(android_fill_rectangle, android_create_pixmap_from_bitmap_data)
(android_set_clip_mask, android_set_fill_style, android_copy_area)
(android_free_pixmap, android_set_background, android_fill_polygon)
(android_draw_rectangle, android_draw_point, android_draw_line)
(android_create_pixmap, android_set_ts_origin, android_clear_area):
* src/android.h (ANDROID_EXPORT):
* src/androidfns.c (android_display_info_for_name)
(check_android_display_info, check_x_display_info, gamma_correct)
(android_defined_color, android_decode_color)
(android_implicitly_set_name, android_explicitly_set_name)
(android_set_tool_bar_lines, android_change_tool_bar_height)
(android_set_tab_bar_lines, android_change_tab_bar_height)
(android_set_scroll_bar_default_height)
(android_set_scroll_bar_default_width, android_icon_verify)
(android_icon, android_make_gc, android_free_gcs)
(unwind_create_frame, do_unwind_create_frame)
(android_default_font_parameter, android_create_frame_window)
(Fx_create_frame, Fxw_color_defined_p, Fxw_color_values)
(Fxw_display_color_p, Fx_display_grayscale_p)
(Fx_display_pixel_width, Fx_display_pixel_height)
(Fx_display_planes, Fx_display_color_cells, Fx_display_screens)
(Fx_display_mm_width, Fx_display_mm_height)
(Fx_display_backing_store, Fx_display_visual_class)
(Fx_display_monitor_attributes_list, Fx_frame_geometry)
(Fx_frame_list_z_order, Fx_frame_restack)
(Fx_mouse_absolute_pixel_position)
(Fx_set_mouse_absolute_pixel_position, Fandroid_get_connection)
(Fx_display_list, Fx_show_tip, Fx_hide_tip)
(android_set_background_color, android_set_border_color)
(android_set_cursor_color, android_set_cursor_type)
(android_set_foreground_color)
(android_set_child_frame_border_width)
(android_set_internal_border_width, android_set_menu_bar_lines)
(android_set_mouse_color, android_set_title, android_set_alpha)
(android_frame_parm_handlers, syms_of_androidfns):
* src/androidfont.c (struct android_emacs_font_driver)
(struct android_emacs_font_spec, struct android_emacs_font_metrics)
(struct android_emacs_font_object, struct android_integer)
(struct androidfont_info, struct androidfont_entity)
(android_init_font_driver, android_init_font_spec)
(android_init_font_metrics, android_init_integer)
(android_init_font_object, androidfont_get_cache)
(androidfont_from_lisp, androidfont_from_java, androidfont_list)
(androidfont_match, androidfont_draw, androidfont_open_font)
(androidfont_close_font, androidfont_has_char)
(androidfont_encode_char, androidfont_text_extents)
(androidfont_list_family, androidfont_driver)
(syms_of_androidfont_for_pdumper, syms_of_androidfont)
(init_androidfont, android_finalize_font_entity):
* src/androidgui.h (_ANDROID_GUI_H_, struct android_rectangle)
(struct android_point, enum android_gc_function)
(enum android_gc_value_mask, enum android_fill_style)
(enum android_window_value_mask)
(struct android_set_window_attributes, struct android_gc_values)
(struct android_gc, enum android_swap_action, enum android_shape)
(enum android_coord_mode, struct android_swap_info)
(NativeRectangle, struct android_any_event)
(struct android_key_event, struct android_configure_event)
(union android_event):
* src/androidterm.c (android_window_to_frame, android_clear_frame)
(android_ring_bell, android_toggle_invisible_pointer)
(android_update_begin, android_update_end, show_back_buffer)
(android_flush_dirty_back_buffer_on, handle_one_android_event)
(android_read_socket, android_frame_up_to_date)
(android_buffer_flipping_unblocked_hook)
(android_query_frame_background_color, android_parse_color)
(android_alloc_nearest_color, android_query_colors)
(android_mouse_position, android_get_focus_frame)
(android_focus_frame, android_frame_rehighlight)
(android_frame_raise_lower, android_make_frame_visible)
(android_make_frame_invisible)
(android_make_frame_visible_invisible, android_fullscreen_hook)
(android_iconify_frame, android_set_window_size_1)
(android_set_window_size, android_set_offset, android_set_alpha)
(android_new_font, android_bitmap_icon, android_free_pixmap_hook)
(android_free_frame_resources, android_delete_frame)
(android_delete_terminal, android_scroll_run)
(android_after_update_window_line, android_flip_and_flush)
(android_clear_rectangle, android_reset_clip_rectangles)
(android_clip_to_row, android_draw_fringe_bitmap)
(android_set_cursor_gc, android_set_mouse_face_gc)
(android_set_mode_line_face_gc, android_set_glyph_string_gc)
(android_set_glyph_string_clipping)
(android_set_glyph_string_clipping_exactly)
(android_compute_glyph_string_overhangs)
(android_clear_glyph_string_rect)
(android_draw_glyph_string_background, android_fill_triangle)
(android_make_point, android_inside_rect_p, android_clear_point)
(android_draw_relief_rect, android_draw_box_rect)
(HIGHLIGHT_COLOR_DARK_BOOST_LIMIT, android_setup_relief_color)
(android_setup_relief_colors, android_draw_glyph_string_box)
(android_draw_glyph_string_bg_rect, android_draw_image_relief)
(android_draw_image_foreground, android_draw_image_foreground_1)
(android_draw_image_glyph_string)
(android_draw_stretch_glyph_string, android_draw_underwave)
(android_draw_glyph_string_foreground)
(android_draw_composite_glyph_string_foreground)
(android_draw_glyphless_glyph_string_foreground)
(android_draw_glyph_string, android_define_frame_cursor)
(android_clear_frame_area, android_clear_under_internal_border)
(android_draw_hollow_cursor, android_draw_bar_cursor)
(android_draw_window_cursor, android_draw_vertical_window_border)
(android_draw_window_divider, android_redisplay_interface)
(frame_set_mouse_pixel_position, get_keysym_name)
(android_create_terminal, android_term_init, syms_of_androidterm)
(mark_androidterm):
* src/androidterm.h (_ANDROID_TERM_H_, struct android_display_info)
(struct android_output, FRAME_ANDROID_OUTPUT, XSCROLL_BAR): New
files.
* src/dired.c (file_attributes): Do not use openat on Android.
* src/dispextern.h (No_Cursor): Define appropriately on Android.
(struct glyph_string, struct face): Make gc field of type struct
android_gc on Android.
* src/dispnew.c (clear_current_matrices, clear_desired_matrices)
(adjust_frame_glyphs_for_window_redisplay, free_glyphs)
(update_frame, scrolling, char_ins_del_cost, update_frame_line)
(init_display_interactive): Disable text terminal support
completely on Android. Fix non-toolkit menus for non-X systems.
* src/editfns.c (Fuser_full_name): Call android_user_full_name.
* src/emacs.c (android_emacs_init): Make main this on Android.
Prohibit argv sorting from exceeding end of argv.
* src/epaths.in: Add path definitions for Android.
* src/fileio.c (file_access_p): Call android_file_access_p.
(file_name_directory): Avoid using openat on Android.
(Fcopy_file): Adjust to call sys_fstat instead.
(file_directory_p):
(Finsert_file_contents):
(write_region): Likewise.
* src/filelock.c:
* src/fns.c (Flocale_info): Pacify warning on Android.
* src/font.c (font_make_entity_android): New function.
* src/font.h:
* src/frame.c (Fframep):
(Fwindow_system): Handle new window system `android'. Update doc strings.
(Fmake_terminal_frame): Disable on Android.
(gui_display_get_resource): Disable get_string_resource_hook on Android.
(syms_of_frame): New defsym `android'.
* src/frame.h (GCALIGNED_STRUCT): Add new output data for
Android.
(ENUM_BF): Expand enumerator size.
(FRAME_ANDROID_P, FRAME_WINDOW_P, MOUSE_HL_INFO): Add
definitions for Android.
* src/image.c (GET_PIXEL):
(image_create_bitmap_from_file):
(image_create_x_image_and_pixmap_1):
(image_get_x_image):
(slurp_file):
(lookup_rgb_color):
(image_to_emacs_colors):
(image_from_emacs_colors):
(image_pixmap_draw_cross):
(image_disable_image):
(MaskForeground):
(gif_load): Add stubs for Android.
* src/lisp.h:
* src/lread.c (safe_to_load_version, maybe_swap_for_eln1, openp):
* src/pdumper.c (pdumper_load): Call sys_fstat instead of fstat.
* src/process.c (wait_reading_process_output): Use
android_select instead of pselect.
* src/scroll.c: Disable on Android.
* src/sysdep.c (widen_foreground_group, reset_sys_modes)
(init_signals, emacs_fstatat, sys_fstat): New function.
(emacs_open, emacs_open_noquit, emacs_close): Implement
differently on Android.
(close_output_streams): Disable what is not required on Android.
* src/term.c (OUTPUT1_IF, encode_terminal_code, string_cost)
(string_cost_one_line, per_line_cost, calculate_costs)
(struct fkey_table, tty_append_glyph, produce_glyphs)
(tty_capable_p, Fsuspend_tty, Fresume_tty, device, init_tty)
(maybe_fatal, syms_of_term): Disable text terminal support on
Android.
* src/termhooks.h (enum output_method): Add android output
method.
(GCALIGNED_STRUCT, TERMINAL_FONT_CACHE): Define for Android.
* src/terminal.c (Fterminal_live_p): Implement for Android.
* src/verbose.mk.in (AM_V_GLOBALS): Add JAVAC and DX.
* src/xdisp.c (redisplay_internal): Disable text terminals on Android.
(display_menu_bar):
(display_tty_menu_item):
(draw_row_with_mouse_face):
(expose_frame): Make the non toolkit menu bar work on Android.
* src/xfaces.c (GCGraphicsExposures):
(x_create_gc):
(x_free_gc):
(Fx_load_color_file): Define for Android.
* xcompile/Makefile.in (top_srcdir):
(top_builddir):
* xcompile/README:
* xcompile/langinfo.h (nl_langinfo): New files.
2022-12-31 18:04:18 +08:00
|
|
|
'((((type x w32 ns haiku pgtk android) (class color)) ; Like default mode line
|
2013-06-19 22:28:04 +00:00
|
|
|
:box (:line-width 2 :style released-button)
|
|
|
|
:background "lightgrey" :foreground "black"))
|
|
|
|
"Face for eww buffer buttons."
|
|
|
|
:version "24.4"
|
|
|
|
:group 'eww)
|
|
|
|
|
|
|
|
(defface eww-form-select
|
Bring up the Android operating system and its window system
* .dir-locals.el (c-mode): Add ANDROID_EXPORT noise macro.
* .gitignore: Add new files to ignore.
* Makefile.in: Adjust for Android.
* admin/merge-gnulib: Add new warning.
* configure.ac: Detect Android. Run cross-configuration for
Android when appropriate.
* etc/DEBUG: Document how to debug Emacs on Android.
* java/AndroidManifest.xml:
* java/Makefile.in:
* java/README:
* java/debug.sh:
* java/org/gnu/emacs/EmacsActivity.java (EmacsActivity):
* java/org/gnu/emacs/EmacsApplication.java (EmacsApplication):
* java/org/gnu/emacs/EmacsCopyArea.java (EmacsCopyArea):
* java/org/gnu/emacs/EmacsDrawLine.java (EmacsDrawLine):
* java/org/gnu/emacs/EmacsDrawPoint.java (EmacsDrawPoint):
* java/org/gnu/emacs/EmacsDrawRectangle.java
(EmacsDrawRectangle):
* java/org/gnu/emacs/EmacsDrawable.java (EmacsDrawable):
* java/org/gnu/emacs/EmacsFillPolygon.java (EmacsFillPolygon):
* java/org/gnu/emacs/EmacsFillRectangle.java
(EmacsFillRectangle):
* java/org/gnu/emacs/EmacsFontDriver.java (EmacsFontDriver):
* java/org/gnu/emacs/EmacsGC.java (EmacsGC):
* java/org/gnu/emacs/EmacsHandleObject.java (EmacsHandleObject):
* java/org/gnu/emacs/EmacsNative.java (EmacsNative):
* java/org/gnu/emacs/EmacsPaintQueue.java (EmacsPaintQueue):
* java/org/gnu/emacs/EmacsPaintReq.java (EmacsPaintReq):
* java/org/gnu/emacs/EmacsPixmap.java (EmacsPixmap):
* java/org/gnu/emacs/EmacsSdk7FontDriver.java
(EmacsSdk7FontDriver):
* java/org/gnu/emacs/EmacsService.java (class Holder<T>)
(EmacsService):
* java/org/gnu/emacs/EmacsSurfaceView.java (EmacsSurfaceView):
* java/org/gnu/emacs/EmacsThread.java (EmacsThread):
* java/org/gnu/emacs/EmacsView.java (EmacsView):
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow): New files
and classes.
* lib-src/Makefile.in (srcdir):
* lib/Makefile.in (VPATH):
(HAVE_NATIVE_COMP):
(libgnu_a_SOURCES):
(DEPFLAGS): Configure correctly for cross-compiling.
* lib/faccessat.c:
* lib/fpending.c (__fpending):
* lib/open.c:
* lib/unistd.c (_GL_UNISTD_INLINE): Temporary adjustments to
gnulib.
* lisp/frame.el (display-graphic-p):
(display-screens):
(display-pixel-height):
(display-pixel-width):
(display-mm-height):
(display-mm-width):
(display-backing-store):
(display-save-under):
(display-planes):
(display-color-cells):
(display-visual-class): Adjust for new window system `android'.
* lisp/image/wallpaper.el (x-open-connection): Add declaration.
* lisp/loadup.el (featurep): Load up files for Android.
* lisp/net/eww.el (eww-form-submit, eww-form-file)
(eww-form-checkbox, eww-form-select): Adjust faces for android.
* lisp/term/android-win.el: New file.
* src/Makefile.in: Add new targets emacs.so and android-emacs,
then adjust for cross compilation.
* src/alloc.c (cleanup_vector): Clean up Android font entities
as well.
(garbage_collect): Mark androidterm.
* src/android-emacs.c (main):
* src/android.c (ANDROID_THROW, enum android_fd_table_entry_flags)
(struct android_emacs_service, struct android_emacs_pixmap)
(struct android_graphics_point, struct android_event_container)
(struct android_event_queue, android_run_select_thread)
(android_handle_sigusr1, android_init_events, android_pending)
(android_next_event, android_write_event, android_select)
(android_run_debug_thread, android_user_full_name)
(android_get_asset_name, android_fstat, android_fstatat)
(android_file_access_p, android_hack_asset_fd, android_open)
(android_close, JNICALL, android_init_emacs_service)
(android_init_emacs_pixmap, android_init_graphics_point)
(MAX_HANDLE, struct android_handle_entry, android_alloc_id)
(android_destroy_handle, android_resolve_handle)
(android_resolve_handle2, android_change_window_attributes)
(android_create_window, android_set_window_background)
(android_destroy_window, android_init_android_rect_class)
(android_init_emacs_gc_class, android_create_gc, android_free_gc)
(android_change_gc, android_set_clip_rectangles)
(android_reparent_window, android_lookup_method)
(android_clear_window, android_map_window, android_unmap_window)
(android_resize_window, android_move_window, android_swap_buffers)
(android_get_gc_values, android_set_foreground)
(android_fill_rectangle, android_create_pixmap_from_bitmap_data)
(android_set_clip_mask, android_set_fill_style, android_copy_area)
(android_free_pixmap, android_set_background, android_fill_polygon)
(android_draw_rectangle, android_draw_point, android_draw_line)
(android_create_pixmap, android_set_ts_origin, android_clear_area):
* src/android.h (ANDROID_EXPORT):
* src/androidfns.c (android_display_info_for_name)
(check_android_display_info, check_x_display_info, gamma_correct)
(android_defined_color, android_decode_color)
(android_implicitly_set_name, android_explicitly_set_name)
(android_set_tool_bar_lines, android_change_tool_bar_height)
(android_set_tab_bar_lines, android_change_tab_bar_height)
(android_set_scroll_bar_default_height)
(android_set_scroll_bar_default_width, android_icon_verify)
(android_icon, android_make_gc, android_free_gcs)
(unwind_create_frame, do_unwind_create_frame)
(android_default_font_parameter, android_create_frame_window)
(Fx_create_frame, Fxw_color_defined_p, Fxw_color_values)
(Fxw_display_color_p, Fx_display_grayscale_p)
(Fx_display_pixel_width, Fx_display_pixel_height)
(Fx_display_planes, Fx_display_color_cells, Fx_display_screens)
(Fx_display_mm_width, Fx_display_mm_height)
(Fx_display_backing_store, Fx_display_visual_class)
(Fx_display_monitor_attributes_list, Fx_frame_geometry)
(Fx_frame_list_z_order, Fx_frame_restack)
(Fx_mouse_absolute_pixel_position)
(Fx_set_mouse_absolute_pixel_position, Fandroid_get_connection)
(Fx_display_list, Fx_show_tip, Fx_hide_tip)
(android_set_background_color, android_set_border_color)
(android_set_cursor_color, android_set_cursor_type)
(android_set_foreground_color)
(android_set_child_frame_border_width)
(android_set_internal_border_width, android_set_menu_bar_lines)
(android_set_mouse_color, android_set_title, android_set_alpha)
(android_frame_parm_handlers, syms_of_androidfns):
* src/androidfont.c (struct android_emacs_font_driver)
(struct android_emacs_font_spec, struct android_emacs_font_metrics)
(struct android_emacs_font_object, struct android_integer)
(struct androidfont_info, struct androidfont_entity)
(android_init_font_driver, android_init_font_spec)
(android_init_font_metrics, android_init_integer)
(android_init_font_object, androidfont_get_cache)
(androidfont_from_lisp, androidfont_from_java, androidfont_list)
(androidfont_match, androidfont_draw, androidfont_open_font)
(androidfont_close_font, androidfont_has_char)
(androidfont_encode_char, androidfont_text_extents)
(androidfont_list_family, androidfont_driver)
(syms_of_androidfont_for_pdumper, syms_of_androidfont)
(init_androidfont, android_finalize_font_entity):
* src/androidgui.h (_ANDROID_GUI_H_, struct android_rectangle)
(struct android_point, enum android_gc_function)
(enum android_gc_value_mask, enum android_fill_style)
(enum android_window_value_mask)
(struct android_set_window_attributes, struct android_gc_values)
(struct android_gc, enum android_swap_action, enum android_shape)
(enum android_coord_mode, struct android_swap_info)
(NativeRectangle, struct android_any_event)
(struct android_key_event, struct android_configure_event)
(union android_event):
* src/androidterm.c (android_window_to_frame, android_clear_frame)
(android_ring_bell, android_toggle_invisible_pointer)
(android_update_begin, android_update_end, show_back_buffer)
(android_flush_dirty_back_buffer_on, handle_one_android_event)
(android_read_socket, android_frame_up_to_date)
(android_buffer_flipping_unblocked_hook)
(android_query_frame_background_color, android_parse_color)
(android_alloc_nearest_color, android_query_colors)
(android_mouse_position, android_get_focus_frame)
(android_focus_frame, android_frame_rehighlight)
(android_frame_raise_lower, android_make_frame_visible)
(android_make_frame_invisible)
(android_make_frame_visible_invisible, android_fullscreen_hook)
(android_iconify_frame, android_set_window_size_1)
(android_set_window_size, android_set_offset, android_set_alpha)
(android_new_font, android_bitmap_icon, android_free_pixmap_hook)
(android_free_frame_resources, android_delete_frame)
(android_delete_terminal, android_scroll_run)
(android_after_update_window_line, android_flip_and_flush)
(android_clear_rectangle, android_reset_clip_rectangles)
(android_clip_to_row, android_draw_fringe_bitmap)
(android_set_cursor_gc, android_set_mouse_face_gc)
(android_set_mode_line_face_gc, android_set_glyph_string_gc)
(android_set_glyph_string_clipping)
(android_set_glyph_string_clipping_exactly)
(android_compute_glyph_string_overhangs)
(android_clear_glyph_string_rect)
(android_draw_glyph_string_background, android_fill_triangle)
(android_make_point, android_inside_rect_p, android_clear_point)
(android_draw_relief_rect, android_draw_box_rect)
(HIGHLIGHT_COLOR_DARK_BOOST_LIMIT, android_setup_relief_color)
(android_setup_relief_colors, android_draw_glyph_string_box)
(android_draw_glyph_string_bg_rect, android_draw_image_relief)
(android_draw_image_foreground, android_draw_image_foreground_1)
(android_draw_image_glyph_string)
(android_draw_stretch_glyph_string, android_draw_underwave)
(android_draw_glyph_string_foreground)
(android_draw_composite_glyph_string_foreground)
(android_draw_glyphless_glyph_string_foreground)
(android_draw_glyph_string, android_define_frame_cursor)
(android_clear_frame_area, android_clear_under_internal_border)
(android_draw_hollow_cursor, android_draw_bar_cursor)
(android_draw_window_cursor, android_draw_vertical_window_border)
(android_draw_window_divider, android_redisplay_interface)
(frame_set_mouse_pixel_position, get_keysym_name)
(android_create_terminal, android_term_init, syms_of_androidterm)
(mark_androidterm):
* src/androidterm.h (_ANDROID_TERM_H_, struct android_display_info)
(struct android_output, FRAME_ANDROID_OUTPUT, XSCROLL_BAR): New
files.
* src/dired.c (file_attributes): Do not use openat on Android.
* src/dispextern.h (No_Cursor): Define appropriately on Android.
(struct glyph_string, struct face): Make gc field of type struct
android_gc on Android.
* src/dispnew.c (clear_current_matrices, clear_desired_matrices)
(adjust_frame_glyphs_for_window_redisplay, free_glyphs)
(update_frame, scrolling, char_ins_del_cost, update_frame_line)
(init_display_interactive): Disable text terminal support
completely on Android. Fix non-toolkit menus for non-X systems.
* src/editfns.c (Fuser_full_name): Call android_user_full_name.
* src/emacs.c (android_emacs_init): Make main this on Android.
Prohibit argv sorting from exceeding end of argv.
* src/epaths.in: Add path definitions for Android.
* src/fileio.c (file_access_p): Call android_file_access_p.
(file_name_directory): Avoid using openat on Android.
(Fcopy_file): Adjust to call sys_fstat instead.
(file_directory_p):
(Finsert_file_contents):
(write_region): Likewise.
* src/filelock.c:
* src/fns.c (Flocale_info): Pacify warning on Android.
* src/font.c (font_make_entity_android): New function.
* src/font.h:
* src/frame.c (Fframep):
(Fwindow_system): Handle new window system `android'. Update doc strings.
(Fmake_terminal_frame): Disable on Android.
(gui_display_get_resource): Disable get_string_resource_hook on Android.
(syms_of_frame): New defsym `android'.
* src/frame.h (GCALIGNED_STRUCT): Add new output data for
Android.
(ENUM_BF): Expand enumerator size.
(FRAME_ANDROID_P, FRAME_WINDOW_P, MOUSE_HL_INFO): Add
definitions for Android.
* src/image.c (GET_PIXEL):
(image_create_bitmap_from_file):
(image_create_x_image_and_pixmap_1):
(image_get_x_image):
(slurp_file):
(lookup_rgb_color):
(image_to_emacs_colors):
(image_from_emacs_colors):
(image_pixmap_draw_cross):
(image_disable_image):
(MaskForeground):
(gif_load): Add stubs for Android.
* src/lisp.h:
* src/lread.c (safe_to_load_version, maybe_swap_for_eln1, openp):
* src/pdumper.c (pdumper_load): Call sys_fstat instead of fstat.
* src/process.c (wait_reading_process_output): Use
android_select instead of pselect.
* src/scroll.c: Disable on Android.
* src/sysdep.c (widen_foreground_group, reset_sys_modes)
(init_signals, emacs_fstatat, sys_fstat): New function.
(emacs_open, emacs_open_noquit, emacs_close): Implement
differently on Android.
(close_output_streams): Disable what is not required on Android.
* src/term.c (OUTPUT1_IF, encode_terminal_code, string_cost)
(string_cost_one_line, per_line_cost, calculate_costs)
(struct fkey_table, tty_append_glyph, produce_glyphs)
(tty_capable_p, Fsuspend_tty, Fresume_tty, device, init_tty)
(maybe_fatal, syms_of_term): Disable text terminal support on
Android.
* src/termhooks.h (enum output_method): Add android output
method.
(GCALIGNED_STRUCT, TERMINAL_FONT_CACHE): Define for Android.
* src/terminal.c (Fterminal_live_p): Implement for Android.
* src/verbose.mk.in (AM_V_GLOBALS): Add JAVAC and DX.
* src/xdisp.c (redisplay_internal): Disable text terminals on Android.
(display_menu_bar):
(display_tty_menu_item):
(draw_row_with_mouse_face):
(expose_frame): Make the non toolkit menu bar work on Android.
* src/xfaces.c (GCGraphicsExposures):
(x_create_gc):
(x_free_gc):
(Fx_load_color_file): Define for Android.
* xcompile/Makefile.in (top_srcdir):
(top_builddir):
* xcompile/README:
* xcompile/langinfo.h (nl_langinfo): New files.
2022-12-31 18:04:18 +08:00
|
|
|
'((((type x w32 ns haiku pgtk android) (class color)) ; Like default mode line
|
2013-06-17 22:06:27 +00:00
|
|
|
:box (:line-width 2 :style released-button)
|
|
|
|
:background "lightgrey" :foreground "black"))
|
|
|
|
"Face for eww buffer buttons."
|
|
|
|
:version "24.4"
|
|
|
|
:group 'eww)
|
|
|
|
|
2013-06-19 22:28:04 +00:00
|
|
|
(defface eww-form-text
|
2018-04-17 21:42:04 +02:00
|
|
|
'((t :background "#505050"
|
|
|
|
:foreground "white"
|
|
|
|
:box (:line-width 1)))
|
2013-06-19 22:28:04 +00:00
|
|
|
"Face for eww text inputs."
|
|
|
|
:version "24.4"
|
|
|
|
:group 'eww)
|
|
|
|
|
2013-12-25 16:33:16 +01:00
|
|
|
(defface eww-form-textarea
|
2018-04-17 21:42:04 +02:00
|
|
|
'((t :background "#C0C0C0"
|
|
|
|
:foreground "black"
|
|
|
|
:box (:line-width 1)))
|
2013-12-25 16:33:16 +01:00
|
|
|
"Face for eww textarea inputs."
|
|
|
|
:version "24.4"
|
|
|
|
:group 'eww)
|
|
|
|
|
2014-12-09 04:21:57 +01:00
|
|
|
(defface eww-invalid-certificate
|
|
|
|
'((default :weight bold)
|
|
|
|
(((class color)) :foreground "red"))
|
|
|
|
"Face for web pages with invalid certificates."
|
|
|
|
:version "25.1"
|
|
|
|
:group 'eww)
|
|
|
|
|
|
|
|
(defface eww-valid-certificate
|
|
|
|
'((default :weight bold)
|
|
|
|
(((class color)) :foreground "ForestGreen"))
|
|
|
|
"Face for web pages with valid certificates."
|
|
|
|
:version "25.1"
|
|
|
|
:group 'eww)
|
|
|
|
|
2014-11-10 21:22:59 +01:00
|
|
|
(defvar eww-data nil)
|
2013-06-10 11:46:27 +00:00
|
|
|
(defvar eww-history nil)
|
2024-02-17 20:49:15 -08:00
|
|
|
(defvar eww-history-position 0
|
|
|
|
"The 1-indexed position in `eww-history'.
|
|
|
|
If zero, EWW is at the newest page, which isn't yet present in
|
|
|
|
`eww-history'.")
|
2018-04-13 15:22:30 +02:00
|
|
|
(defvar eww-prompt-history nil)
|
2013-06-10 11:46:27 +00:00
|
|
|
|
2013-11-21 11:41:35 -05:00
|
|
|
(defvar eww-local-regex "localhost"
|
|
|
|
"When this regex is found in the URL, it's not a keyword but an address.")
|
|
|
|
|
2019-05-13 14:06:16 -04:00
|
|
|
(defvar eww-accept-content-types
|
|
|
|
"text/html, text/plain, text/sgml, text/css, application/xhtml+xml, */*;q=0.01"
|
2022-04-22 16:17:22 +02:00
|
|
|
"Value used for the HTTP \"Accept\" header.")
|
2019-05-13 14:06:16 -04:00
|
|
|
|
2021-10-05 10:34:37 +02:00
|
|
|
(defvar-keymap eww-link-keymap
|
|
|
|
:parent shr-map
|
2022-09-28 12:59:04 +02:00
|
|
|
"RET" #'eww-follow-link
|
|
|
|
"<mouse-2>" #'eww-follow-link)
|
2018-04-14 00:17:36 +02:00
|
|
|
|
2021-10-05 10:34:37 +02:00
|
|
|
(defvar-keymap eww-image-link-keymap
|
2023-04-15 12:35:24 +02:00
|
|
|
:parent shr-image-map
|
2021-11-16 08:18:30 +01:00
|
|
|
"RET" #'eww-follow-link)
|
2013-12-01 15:45:02 +01:00
|
|
|
|
2023-04-12 17:56:01 +00:00
|
|
|
(defvar-keymap eww-minibuffer-url-keymap
|
|
|
|
:doc "Keymap used in the minibuffer prompt for URLs or keywords."
|
|
|
|
:parent minibuffer-local-completion-map
|
|
|
|
"SPC" #'self-insert-command
|
|
|
|
"?" #'self-insert-command)
|
|
|
|
|
2014-11-23 16:55:03 +01:00
|
|
|
(defun eww-suggested-uris nil
|
|
|
|
"Return the list of URIs to suggest at the `eww' prompt.
|
|
|
|
This list can be customized via `eww-suggest-uris'."
|
2024-02-08 18:23:00 +01:00
|
|
|
(let ((obseen (obarray-make 42))
|
2014-11-23 16:55:03 +01:00
|
|
|
(uris nil))
|
|
|
|
(dolist (fun eww-suggest-uris)
|
|
|
|
(let ((ret (funcall fun)))
|
|
|
|
(dolist (uri (if (stringp ret) (list ret) ret))
|
|
|
|
(when (and uri (not (intern-soft uri obseen)))
|
|
|
|
(intern uri obseen)
|
|
|
|
(push uri uris)))))
|
|
|
|
(nreverse uris)))
|
|
|
|
|
2020-08-09 13:05:37 +02:00
|
|
|
;;;###autoload
|
|
|
|
(defun eww-browse ()
|
|
|
|
"Function to be run to parse command line URLs.
|
|
|
|
This is meant to be used for MIME handlers or command line use.
|
|
|
|
|
|
|
|
Setting the handler for \"text/x-uri;\" to
|
|
|
|
\"emacs -f eww-browse %u\" will then start up Emacs and call eww
|
|
|
|
to browse the url.
|
|
|
|
|
|
|
|
This can also be used on the command line directly:
|
|
|
|
|
|
|
|
emacs -f eww-browse https://gnu.org
|
|
|
|
|
|
|
|
will start Emacs and browse the GNU web site."
|
|
|
|
(interactive)
|
2022-08-04 14:20:58 +02:00
|
|
|
(unless command-line-args-left
|
|
|
|
(user-error "No URL given"))
|
2020-08-09 13:05:37 +02:00
|
|
|
(eww (pop command-line-args-left)))
|
|
|
|
|
|
|
|
|
2013-06-11 03:09:59 +00:00
|
|
|
;;;###autoload
|
2021-11-06 00:17:18 +01:00
|
|
|
(defun eww (url &optional new-buffer buffer)
|
2013-06-23 20:22:28 +02:00
|
|
|
"Fetch URL and render the page.
|
|
|
|
If the input doesn't look like an URL or a domain name, the
|
2019-02-09 17:41:31 +03:00
|
|
|
word(s) will be searched for via `eww-search-prefix'.
|
|
|
|
|
2021-11-06 00:17:18 +01:00
|
|
|
If NEW-BUFFER is non-nil (interactively, the prefix arg), use a
|
|
|
|
new buffer instead of reusing the default EWW buffer.
|
2020-07-18 18:02:43 +02:00
|
|
|
|
|
|
|
If BUFFER, the data to be rendered is in that buffer. In that
|
|
|
|
case, this function doesn't actually fetch URL. BUFFER will be
|
2022-07-09 17:46:59 +02:00
|
|
|
killed after rendering.
|
|
|
|
|
|
|
|
For more information, see Info node `(eww) Top'."
|
2014-11-23 16:55:03 +01:00
|
|
|
(interactive
|
2023-04-12 17:56:01 +00:00
|
|
|
(let ((uris (eww-suggested-uris))
|
|
|
|
(minibuffer-local-completion-map eww-minibuffer-url-keymap))
|
|
|
|
(list (completing-read (format-prompt "Enter URL or keywords"
|
|
|
|
(and uris (car uris)))
|
2023-04-13 15:59:54 +00:00
|
|
|
(seq-uniq (append eww-prompt-history uris))
|
|
|
|
nil nil nil 'eww-prompt-history uris)
|
2021-11-06 00:17:18 +01:00
|
|
|
current-prefix-arg)))
|
2017-01-24 22:40:57 +01:00
|
|
|
(setq url (eww--dwim-expand-url url))
|
|
|
|
(pop-to-buffer-same-window
|
2019-02-09 17:41:31 +03:00
|
|
|
(cond
|
2021-11-06 00:17:18 +01:00
|
|
|
(new-buffer
|
2019-02-09 17:41:31 +03:00
|
|
|
(generate-new-buffer "*eww*"))
|
|
|
|
((eq major-mode 'eww-mode)
|
|
|
|
(current-buffer))
|
|
|
|
(t
|
|
|
|
(get-buffer-create "*eww*"))))
|
2017-01-24 22:40:57 +01:00
|
|
|
(eww-setup-buffer)
|
2024-02-17 20:49:15 -08:00
|
|
|
(eww--before-browse)
|
2017-01-24 22:40:57 +01:00
|
|
|
;; Check whether the domain only uses "Highly Restricted" Unicode
|
|
|
|
;; IDNA characters. If not, transform to punycode to indicate that
|
|
|
|
;; there may be funny business going on.
|
|
|
|
(let ((parsed (url-generic-parse-url url)))
|
2017-12-23 21:38:36 +01:00
|
|
|
(when (url-host parsed)
|
|
|
|
(unless (puny-highly-restrictive-domain-p (url-host parsed))
|
2018-04-15 22:20:28 +02:00
|
|
|
(setf (url-host parsed) (puny-encode-domain (url-host parsed)))))
|
|
|
|
;; When the URL is on the form "http://a/../../../g", chop off all
|
|
|
|
;; the leading "/.."s.
|
|
|
|
(when (url-filename parsed)
|
|
|
|
(while (string-match "\\`/[.][.]/" (url-filename parsed))
|
|
|
|
(setf (url-filename parsed) (substring (url-filename parsed) 3))))
|
|
|
|
(setq url (url-recreate-url parsed)))
|
2021-11-07 00:45:01 +01:00
|
|
|
(setq url (eww--transform-url url))
|
2017-01-24 22:40:57 +01:00
|
|
|
(plist-put eww-data :url url)
|
|
|
|
(plist-put eww-data :title "")
|
2021-10-15 14:12:32 +02:00
|
|
|
(eww--after-page-change)
|
2017-01-24 22:40:57 +01:00
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(insert (format "Loading %s..." url))
|
|
|
|
(goto-char (point-min)))
|
2019-05-13 14:06:16 -04:00
|
|
|
(let ((url-mime-accept-string eww-accept-content-types))
|
2020-07-18 18:02:43 +02:00
|
|
|
(if buffer
|
|
|
|
(let ((eww-buffer (current-buffer)))
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(eww-render nil url nil eww-buffer)))
|
2020-09-13 00:12:33 +02:00
|
|
|
(eww-retrieve url #'eww-render
|
2020-07-18 18:02:43 +02:00
|
|
|
(list url nil (current-buffer))))))
|
2017-01-24 22:40:57 +01:00
|
|
|
|
2020-09-13 00:12:33 +02:00
|
|
|
(defun eww-retrieve (url callback cbargs)
|
2021-09-20 10:16:09 +03:00
|
|
|
(cond
|
|
|
|
((null eww-retrieve-command)
|
2024-03-17 12:01:59 -07:00
|
|
|
(url-retrieve url callback cbargs))
|
2021-09-20 10:16:09 +03:00
|
|
|
((eq eww-retrieve-command 'sync)
|
2022-09-26 13:20:59 +02:00
|
|
|
(let ((data-buffer (url-retrieve-synchronously url)))
|
2021-09-20 10:16:09 +03:00
|
|
|
(with-current-buffer data-buffer
|
2024-03-17 12:01:59 -07:00
|
|
|
(apply callback nil cbargs))))
|
2021-09-20 10:16:09 +03:00
|
|
|
(t
|
2020-09-13 01:02:00 +02:00
|
|
|
(let ((buffer (generate-new-buffer " *eww retrieve*"))
|
|
|
|
(error-buffer (generate-new-buffer " *eww error*")))
|
2020-09-13 00:12:33 +02:00
|
|
|
(with-current-buffer buffer
|
|
|
|
(set-buffer-multibyte nil)
|
|
|
|
(make-process
|
|
|
|
:name "*eww fetch*"
|
|
|
|
:buffer (current-buffer)
|
2020-09-13 01:02:00 +02:00
|
|
|
:stderr error-buffer
|
2020-09-13 00:12:33 +02:00
|
|
|
:command (append eww-retrieve-command (list url))
|
|
|
|
:sentinel (lambda (process _)
|
|
|
|
(unless (process-live-p process)
|
2020-09-13 01:02:00 +02:00
|
|
|
(when (buffer-live-p error-buffer)
|
|
|
|
(when (get-buffer-process error-buffer)
|
|
|
|
(delete-process (get-buffer-process error-buffer) ))
|
|
|
|
(kill-buffer error-buffer))
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(goto-char (point-min))
|
|
|
|
(insert "Content-type: text/html; charset=utf-8\n\n")
|
2021-09-20 10:16:09 +03:00
|
|
|
(apply #'funcall callback nil cbargs)))))))))))
|
2020-09-13 00:12:33 +02:00
|
|
|
|
2020-05-06 18:02:32 +01:00
|
|
|
(function-put 'eww 'browse-url-browser-kind 'internal)
|
2020-05-07 13:02:13 +02:00
|
|
|
|
2017-01-24 22:40:57 +01:00
|
|
|
(defun eww--dwim-expand-url (url)
|
2014-11-04 11:31:33 -05:00
|
|
|
(setq url (string-trim url))
|
2014-11-02 16:06:52 -05:00
|
|
|
(cond ((string-match-p "\\`file:/" url))
|
2014-11-13 17:59:35 +01:00
|
|
|
;; Don't mangle file: URLs at all.
|
2013-12-22 17:40:35 -05:00
|
|
|
((string-match-p "\\`ftp://" url)
|
2015-03-04 12:34:48 +01:00
|
|
|
(user-error "FTP is not supported"))
|
2013-12-22 17:40:35 -05:00
|
|
|
(t
|
2015-01-11 15:58:10 +01:00
|
|
|
;; Anything that starts with something that vaguely looks
|
|
|
|
;; like a protocol designator is interpreted as a full URL.
|
|
|
|
(if (or (string-match "\\`[A-Za-z]+:" url)
|
2015-01-10 16:20:44 +01:00
|
|
|
;; Also try to match "naked" URLs like
|
|
|
|
;; en.wikipedia.org/wiki/Free software
|
2015-01-10 16:41:49 +01:00
|
|
|
(string-match "\\`[A-Za-z_]+\\.[A-Za-z._]+/" url)
|
2015-01-10 16:01:43 +01:00
|
|
|
(and (= (length (split-string url)) 1)
|
2015-09-17 16:08:20 -07:00
|
|
|
(or (and (not (string-match-p "\\`[\"'].*[\"']\\'" url))
|
2015-01-10 16:01:43 +01:00
|
|
|
(> (length (split-string url "[.:]")) 1))
|
|
|
|
(string-match eww-local-regex url))))
|
2013-12-22 17:40:35 -05:00
|
|
|
(progn
|
|
|
|
(unless (string-match-p "\\`[a-zA-Z][-a-zA-Z0-9+.]*://" url)
|
|
|
|
(setq url (concat "http://" url)))
|
2015-01-10 16:20:44 +01:00
|
|
|
;; Some sites do not redirect final /
|
2013-12-22 17:40:35 -05:00
|
|
|
(when (string= (url-filename (url-generic-parse-url url)) "")
|
|
|
|
(setq url (concat url "/"))))
|
|
|
|
(setq url (concat eww-search-prefix
|
2017-09-03 20:42:01 -04:00
|
|
|
(mapconcat
|
|
|
|
#'url-hexify-string (split-string url) "+"))))))
|
2017-01-24 22:40:57 +01:00
|
|
|
url)
|
2013-06-10 11:46:27 +00:00
|
|
|
|
2019-09-14 16:07:34 +02:00
|
|
|
(defun eww--preprocess-html (start end)
|
|
|
|
"Translate all < characters that do not look like start of tags into <."
|
|
|
|
(save-excursion
|
|
|
|
(save-restriction
|
|
|
|
(narrow-to-region start end)
|
|
|
|
(goto-char start)
|
|
|
|
(let ((case-fold-search t))
|
2020-11-02 23:24:20 +01:00
|
|
|
(while (re-search-forward "<[^0-9a-z!?/]" nil t)
|
2019-09-14 16:07:34 +02:00
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
(delete-region (point) (1+ (point)))
|
|
|
|
(insert "<"))))))
|
|
|
|
|
2013-12-17 23:17:05 +02:00
|
|
|
;;;###autoload (defalias 'browse-web 'eww)
|
|
|
|
|
Merge changes made in Gnus master
2013-06-18 Teodor Zlatanov <tzz@lifelogs.com>
* auth-source.el (auth-source-netrc-parse-entries): Remove debugging.
2013-06-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-make-table-1): Implement <td rowspan>.
(shr-table-horizontal-line): Allow nil as a value, and change the default.
(shr-insert-table-ruler): Respect the nil value.
2013-06-18 Tom Tromey <tromey@barimba>
* net/eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
New defvars.
(eww-open-file): New defun.
(eww-render): Initialize new variables.
(eww-display-html): Handle "link" and "a".
(eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
(eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
(eww-back-url): Rename from eww-previous-url.
(eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New defuns.
2013-06-18 22:38:34 +00:00
|
|
|
;;;###autoload
|
2023-01-14 11:48:55 +02:00
|
|
|
(defun eww-open-file (file &optional new-buffer)
|
|
|
|
"Render FILE using EWW.
|
|
|
|
If NEW-BUFFER is non-nil (interactively, the prefix arg), use a
|
|
|
|
new buffer instead of reusing the default EWW buffer."
|
|
|
|
(interactive "fFile: \nP")
|
2022-02-20 16:08:45 +01:00
|
|
|
(let ((url-allow-non-local-files t))
|
|
|
|
(eww (concat "file://"
|
|
|
|
(and (memq system-type '(windows-nt ms-dos))
|
|
|
|
"/")
|
2023-01-14 11:48:55 +02:00
|
|
|
(expand-file-name file))
|
|
|
|
new-buffer)))
|
2022-02-20 15:52:10 +01:00
|
|
|
|
|
|
|
(defun eww--file-buffer (file)
|
|
|
|
(with-current-buffer (generate-new-buffer " *eww file*")
|
|
|
|
(set-buffer-multibyte nil)
|
|
|
|
(insert "Content-type: " (or (mailcap-extension-to-mime
|
|
|
|
(url-file-extension file))
|
|
|
|
"application/octet-stream")
|
|
|
|
"\n\n")
|
|
|
|
(insert-file-contents file)
|
|
|
|
(current-buffer)))
|
Merge changes made in Gnus master
2013-06-18 Teodor Zlatanov <tzz@lifelogs.com>
* auth-source.el (auth-source-netrc-parse-entries): Remove debugging.
2013-06-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-make-table-1): Implement <td rowspan>.
(shr-table-horizontal-line): Allow nil as a value, and change the default.
(shr-insert-table-ruler): Respect the nil value.
2013-06-18 Tom Tromey <tromey@barimba>
* net/eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
New defvars.
(eww-open-file): New defun.
(eww-render): Initialize new variables.
(eww-display-html): Handle "link" and "a".
(eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
(eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
(eww-back-url): Rename from eww-previous-url.
(eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New defuns.
2013-06-18 22:38:34 +00:00
|
|
|
|
2014-11-14 04:46:11 +01:00
|
|
|
;;;###autoload
|
2017-07-02 21:18:47 +02:00
|
|
|
(defun eww-search-words ()
|
2020-09-29 18:07:44 +03:00
|
|
|
"Search the web for the text in the region.
|
2017-07-02 21:18:47 +02:00
|
|
|
If region is active (and not whitespace), search the web for
|
2020-09-29 18:07:44 +03:00
|
|
|
the text between region beginning and end. Else, prompt the
|
|
|
|
user for a search string. See the variable `eww-search-prefix'
|
|
|
|
for the search engine used."
|
2017-07-02 21:18:47 +02:00
|
|
|
(interactive)
|
|
|
|
(if (use-region-p)
|
|
|
|
(let ((region-string (buffer-substring (region-beginning) (region-end))))
|
|
|
|
(if (not (string-match-p "\\`[ \n\t\r\v\f]*\\'" region-string))
|
|
|
|
(eww region-string)
|
2020-05-06 18:02:32 +01:00
|
|
|
(call-interactively #'eww)))
|
|
|
|
(call-interactively #'eww)))
|
2014-11-14 04:46:11 +01:00
|
|
|
|
2023-08-16 01:00:07 +00:00
|
|
|
(defun eww--open-url-in-new-buffer (url)
|
|
|
|
"Open the URL in a new EWW buffer."
|
2023-08-20 11:48:03 +03:00
|
|
|
;; Clone is useful to keep history, but we
|
|
|
|
;; should not clone from a non-eww buffer.
|
2023-08-16 01:00:07 +00:00
|
|
|
(with-current-buffer
|
|
|
|
(if (eq major-mode 'eww-mode) (clone-buffer)
|
|
|
|
(generate-new-buffer "*eww*"))
|
|
|
|
(unless (equal url (eww-current-url))
|
|
|
|
(eww-mode)
|
|
|
|
(eww (if (consp url) (car url) url)))))
|
|
|
|
|
|
|
|
(defun eww-open-in-new-buffer (&optional no-select url)
|
2023-08-20 11:48:03 +03:00
|
|
|
"Fetch URL (interactively, the link at point) into a new EWW buffer.
|
2023-08-16 01:00:07 +00:00
|
|
|
|
2023-08-20 11:48:03 +03:00
|
|
|
NO-SELECT non-nil means do not make the new buffer the current buffer."
|
2023-08-16 01:00:07 +00:00
|
|
|
(interactive "P")
|
|
|
|
(if-let ((url (or url (eww-suggested-uris))))
|
|
|
|
(if (or (eq eww-browse-url-new-window-is-tab t)
|
|
|
|
(and (eq eww-browse-url-new-window-is-tab 'tab-bar)
|
|
|
|
tab-bar-mode))
|
|
|
|
(let ((tab-bar-new-tab-choice t))
|
|
|
|
(tab-new)
|
|
|
|
(eww--open-url-in-new-buffer url)
|
|
|
|
(when no-select
|
2023-08-27 19:39:22 +03:00
|
|
|
(tab-bar-switch-to-recent-tab)))
|
2023-08-16 01:00:07 +00:00
|
|
|
(if no-select
|
|
|
|
(save-window-excursion (eww--open-url-in-new-buffer url))
|
|
|
|
(eww--open-url-in-new-buffer url)))
|
|
|
|
(user-error "No link at point")))
|
2016-11-02 15:58:28 -04:00
|
|
|
|
2015-03-05 23:26:34 +01:00
|
|
|
(defun eww-html-p (content-type)
|
|
|
|
"Return non-nil if CONTENT-TYPE designates an HTML content type.
|
|
|
|
Currently this means either text/html or application/xhtml+xml."
|
|
|
|
(member content-type '("text/html"
|
|
|
|
"application/xhtml+xml")))
|
|
|
|
|
2021-10-15 14:12:32 +02:00
|
|
|
(defun eww--rename-buffer ()
|
|
|
|
"Rename the current EWW buffer.
|
|
|
|
The renaming scheme is performed in accordance with
|
|
|
|
`eww-auto-rename-buffer'."
|
|
|
|
(let ((rename-string)
|
|
|
|
(formatter
|
|
|
|
(lambda (string)
|
|
|
|
(format "*%s # eww*" (truncate-string-to-width
|
|
|
|
string eww-buffer-name-length))))
|
|
|
|
(site-title (plist-get eww-data :title))
|
|
|
|
(site-url (plist-get eww-data :url)))
|
|
|
|
(cond ((null eww-auto-rename-buffer))
|
|
|
|
((eq eww-auto-rename-buffer 'url)
|
|
|
|
(setq rename-string (funcall formatter site-url)))
|
|
|
|
((functionp eww-auto-rename-buffer)
|
|
|
|
(setq rename-string (funcall eww-auto-rename-buffer)))
|
|
|
|
(t (setq rename-string
|
|
|
|
(funcall formatter (if (or (equal site-title "")
|
|
|
|
(null site-title))
|
|
|
|
"Untitled"
|
|
|
|
site-title)))))
|
|
|
|
(when rename-string
|
|
|
|
(rename-buffer rename-string t))))
|
|
|
|
|
2014-11-23 16:30:40 +01:00
|
|
|
(defun eww-render (status url &optional point buffer encode)
|
2013-06-10 11:46:27 +00:00
|
|
|
(let* ((headers (eww-parse-headers))
|
|
|
|
(content-type
|
|
|
|
(mail-header-parse-content-type
|
2016-01-24 17:50:27 +01:00
|
|
|
(if (zerop (length (cdr (assoc "content-type" headers))))
|
|
|
|
"text/plain"
|
|
|
|
(cdr (assoc "content-type" headers)))))
|
2013-06-10 11:46:27 +00:00
|
|
|
(charset (intern
|
|
|
|
(downcase
|
|
|
|
(or (cdr (assq 'charset (cdr content-type)))
|
2015-03-05 23:26:34 +01:00
|
|
|
(eww-detect-charset (eww-html-p (car content-type)))
|
2014-11-23 16:30:40 +01:00
|
|
|
"utf-8"))))
|
2015-12-22 18:57:51 +02:00
|
|
|
(data-buffer (current-buffer))
|
2018-04-13 14:55:55 +02:00
|
|
|
(shr-target-id (url-target (url-generic-parse-url url)))
|
2015-12-22 18:57:51 +02:00
|
|
|
last-coding-system-used)
|
2018-04-13 14:55:55 +02:00
|
|
|
(let ((redirect (plist-get status :redirect)))
|
|
|
|
(when redirect
|
|
|
|
(setq url redirect)))
|
2023-09-08 15:11:10 +03:00
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
(with-current-buffer buffer
|
|
|
|
;; Save the https peer status.
|
|
|
|
(plist-put eww-data :peer (plist-get status :peer))
|
|
|
|
;; Make buffer listings more informative.
|
|
|
|
(setq list-buffers-directory url)
|
|
|
|
;; Let the URL library have a handle to the current URL for
|
|
|
|
;; referer purposes.
|
|
|
|
(setq url-current-lastloc (url-generic-parse-url url)))
|
|
|
|
(unwind-protect
|
|
|
|
(progn
|
|
|
|
(cond
|
|
|
|
((and eww-use-external-browser-for-content-type
|
|
|
|
(string-match-p eww-use-external-browser-for-content-type
|
|
|
|
(car content-type)))
|
|
|
|
(erase-buffer)
|
|
|
|
(insert "<title>Unsupported content type</title>")
|
|
|
|
(insert (format "<h1>Content-type %s is unsupported</h1>"
|
|
|
|
(car content-type)))
|
|
|
|
(insert (format "<a href=%S>Direct link to the document</a>"
|
|
|
|
url))
|
|
|
|
(goto-char (point-min))
|
2024-03-17 12:01:59 -07:00
|
|
|
(eww-display-html (or encode charset) url nil point buffer))
|
2023-09-08 15:11:10 +03:00
|
|
|
((eww-html-p (car content-type))
|
2024-03-17 12:01:59 -07:00
|
|
|
(eww-display-html (or encode charset) url nil point buffer))
|
2023-09-08 15:11:10 +03:00
|
|
|
((equal (car content-type) "application/pdf")
|
|
|
|
(eww-display-pdf))
|
|
|
|
((string-match-p "\\`image/" (car content-type))
|
|
|
|
(eww-display-image buffer))
|
|
|
|
(t
|
|
|
|
(eww-display-raw buffer (or encode charset 'utf-8))))
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(plist-put eww-data :url url)
|
|
|
|
(eww--after-page-change)
|
|
|
|
(and last-coding-system-used
|
|
|
|
(set-buffer-file-coding-system last-coding-system-used))
|
2023-10-24 23:35:44 +02:00
|
|
|
(unless shr-fill-text
|
|
|
|
(visual-line-mode))
|
2023-09-08 15:11:10 +03:00
|
|
|
(run-hooks 'eww-after-render-hook)
|
|
|
|
;; Enable undo again so that undo works in text input
|
|
|
|
;; boxes.
|
|
|
|
(setq buffer-undo-list nil)))
|
|
|
|
(kill-buffer data-buffer)))
|
|
|
|
(unless (buffer-live-p buffer)
|
2013-06-10 11:46:27 +00:00
|
|
|
(kill-buffer data-buffer))))
|
|
|
|
|
|
|
|
(defun eww-parse-headers ()
|
|
|
|
(let ((headers nil))
|
2013-06-13 06:07:43 +00:00
|
|
|
(goto-char (point-min))
|
2013-06-10 11:46:27 +00:00
|
|
|
(while (and (not (eobp))
|
|
|
|
(not (eolp)))
|
|
|
|
(when (looking-at "\\([^:]+\\): *\\(.*\\)")
|
|
|
|
(push (cons (downcase (match-string 1))
|
|
|
|
(match-string 2))
|
|
|
|
headers))
|
|
|
|
(forward-line 1))
|
|
|
|
(unless (eobp)
|
|
|
|
(forward-line 1))
|
|
|
|
headers))
|
|
|
|
|
2013-06-18 09:29:20 +00:00
|
|
|
(defun eww-detect-charset (html-p)
|
|
|
|
(let ((case-fold-search t)
|
|
|
|
(pt (point)))
|
|
|
|
(or (and html-p
|
|
|
|
(re-search-forward
|
2013-06-24 15:42:07 +02:00
|
|
|
"<meta[\t\n\r ]+[^>]*charset=\"?\\([^\t\n\r \"/>]+\\)[\\\"'.*]" nil t)
|
2013-06-18 09:29:20 +00:00
|
|
|
(goto-char pt)
|
|
|
|
(match-string 1))
|
|
|
|
(and (looking-at
|
|
|
|
"[\t\n\r ]*<\\?xml[\t\n\r ]+[^>]*encoding=\"\\([^\"]+\\)")
|
|
|
|
(match-string 1)))))
|
|
|
|
|
2013-09-17 21:48:55 -07:00
|
|
|
(declare-function libxml-parse-html-region "xml.c"
|
2015-04-30 20:06:15 -04:00
|
|
|
(start end &optional base-url discard-comments))
|
2013-09-17 21:48:55 -07:00
|
|
|
|
2024-03-17 12:01:59 -07:00
|
|
|
(defun eww--parse-html-region (start end &optional coding-system)
|
|
|
|
"Parse the HTML between START and END, returning the DOM as an S-expression.
|
|
|
|
Use CODING-SYSTEM to decode the region; if nil, decode as UTF-8.
|
|
|
|
|
|
|
|
This replaces the region with the preprocessed HTML."
|
|
|
|
(setq coding-system (or coding-system 'utf-8))
|
|
|
|
(with-restriction start end
|
|
|
|
(condition-case nil
|
|
|
|
(decode-coding-region (point-min) (point-max) coding-system)
|
|
|
|
(coding-system-error nil))
|
|
|
|
;; Remove CRLF and replace NUL with � before parsing.
|
|
|
|
(while (re-search-forward "\\(\r$\\)\\|\0" nil t)
|
|
|
|
(replace-match (if (match-beginning 1) "" "�") t t))
|
|
|
|
(eww--preprocess-html (point-min) (point-max))
|
|
|
|
(libxml-parse-html-region (point-min) (point-max))))
|
|
|
|
|
|
|
|
(defsubst eww-document-base (url dom)
|
|
|
|
`(base ((href . ,url)) ,dom))
|
|
|
|
|
|
|
|
(defun eww-display-document (document &optional point buffer)
|
2014-11-23 17:22:41 +01:00
|
|
|
(unless (fboundp 'libxml-parse-html-region)
|
|
|
|
(error "This function requires Emacs to be compiled with libxml2"))
|
2024-03-17 12:01:59 -07:00
|
|
|
(setq buffer (or buffer (current-buffer)))
|
2014-11-23 17:22:41 +01:00
|
|
|
(unless (buffer-live-p buffer)
|
|
|
|
(error "Buffer %s doesn't exist" buffer))
|
2014-11-03 20:39:08 +01:00
|
|
|
;; There should be a better way to abort loading images
|
|
|
|
;; asynchronously.
|
|
|
|
(setq url-queue nil)
|
2024-03-17 12:01:59 -07:00
|
|
|
(let ((url (when (eq (car document) 'base)
|
|
|
|
(alist-get 'href (cadr document)))))
|
|
|
|
(unless url
|
|
|
|
(error "Document is missing base URL"))
|
2014-11-23 17:22:41 +01:00
|
|
|
(with-current-buffer buffer
|
2016-03-01 10:33:05 +11:00
|
|
|
(setq bidi-paragraph-direction nil)
|
2014-11-23 17:22:41 +01:00
|
|
|
(plist-put eww-data :dom document)
|
|
|
|
(let ((inhibit-read-only t)
|
2014-11-27 21:26:49 +01:00
|
|
|
(inhibit-modification-hooks t)
|
2020-04-22 11:42:17 +01:00
|
|
|
;; Possibly set by the caller, e.g., `eww-render' which
|
|
|
|
;; preserves the old URL #target before chasing redirects.
|
|
|
|
(shr-target-id (or shr-target-id
|
|
|
|
(url-target (url-generic-parse-url url))))
|
2014-11-23 17:22:41 +01:00
|
|
|
(shr-external-rendering-functions
|
2015-12-24 17:34:31 +01:00
|
|
|
(append
|
|
|
|
shr-external-rendering-functions
|
|
|
|
'((title . eww-tag-title)
|
|
|
|
(form . eww-tag-form)
|
|
|
|
(input . eww-tag-input)
|
2015-12-25 21:44:57 +01:00
|
|
|
(button . eww-form-submit)
|
2015-12-24 17:34:31 +01:00
|
|
|
(textarea . eww-tag-textarea)
|
|
|
|
(select . eww-tag-select)
|
|
|
|
(link . eww-tag-link)
|
2015-12-25 18:18:42 +01:00
|
|
|
(meta . eww-tag-meta)
|
2015-12-24 17:34:31 +01:00
|
|
|
(a . eww-tag-a)))))
|
2014-11-23 17:22:41 +01:00
|
|
|
(erase-buffer)
|
2021-10-25 17:10:34 +02:00
|
|
|
(with-delayed-message (2 "Rendering HTML...")
|
2021-10-24 22:21:04 +02:00
|
|
|
(shr-insert-document document))
|
2014-11-23 17:22:41 +01:00
|
|
|
(cond
|
|
|
|
(point
|
|
|
|
(goto-char point))
|
|
|
|
(shr-target-id
|
|
|
|
(goto-char (point-min))
|
2020-05-08 00:25:38 +01:00
|
|
|
(let ((match (text-property-search-forward
|
2021-12-19 13:44:21 +01:00
|
|
|
'shr-target-id shr-target-id #'member)))
|
2020-05-08 00:25:38 +01:00
|
|
|
(when match
|
|
|
|
(goto-char (prop-match-beginning match)))))
|
2014-11-23 17:22:41 +01:00
|
|
|
(t
|
|
|
|
(goto-char (point-min))
|
|
|
|
;; Don't leave point inside forms, because the normal eww
|
|
|
|
;; commands aren't available there.
|
|
|
|
(while (and (not (eobp))
|
|
|
|
(get-text-property (point) 'eww-form))
|
|
|
|
(forward-line 1)))))
|
2014-12-01 18:55:54 +01:00
|
|
|
(eww-size-text-inputs))))
|
2013-06-10 11:46:27 +00:00
|
|
|
|
2024-03-17 12:01:59 -07:00
|
|
|
(defun eww-display-html (charset url &optional document point buffer)
|
|
|
|
(let ((source (buffer-substring (point) (point-max))))
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(plist-put eww-data :source source)))
|
2024-03-18 16:52:34 -07:00
|
|
|
(unless document
|
|
|
|
(let ((dom (eww--parse-html-region (point) (point-max) charset)))
|
|
|
|
(when (eww-default-readable-p url)
|
|
|
|
(eww-score-readability dom)
|
|
|
|
(setq dom (eww-highest-readability dom))
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(plist-put eww-data :readable t)))
|
|
|
|
(setq document (eww-document-base url dom))))
|
|
|
|
(eww-display-document document point buffer))
|
2024-03-17 12:01:59 -07:00
|
|
|
|
2014-11-26 19:41:13 +01:00
|
|
|
(defun eww-handle-link (dom)
|
|
|
|
(let* ((rel (dom-attr dom 'rel))
|
|
|
|
(href (dom-attr dom 'href))
|
|
|
|
(where (assoc
|
|
|
|
;; The text associated with :rel is case-insensitive.
|
|
|
|
(if rel (downcase rel))
|
|
|
|
'(("next" . :next)
|
|
|
|
;; Texinfo uses "previous", but HTML specifies
|
|
|
|
;; "prev", so recognize both.
|
|
|
|
("previous" . :previous)
|
|
|
|
("prev" . :previous)
|
|
|
|
;; HTML specifies "start" but also "contents",
|
|
|
|
;; and Gtk seems to use "home". Recognize
|
|
|
|
;; them all; but store them in different
|
|
|
|
;; variables so that we can readily choose the
|
|
|
|
;; "best" one.
|
|
|
|
("start" . :start)
|
|
|
|
("home" . :home)
|
|
|
|
("contents" . :contents)
|
2014-12-28 14:54:46 +01:00
|
|
|
("up" . :up)))))
|
2021-09-13 10:03:24 +02:00
|
|
|
(when (and href where)
|
|
|
|
(when (memq (cdr where) '(:next :previous))
|
|
|
|
;; Multi-page isearch support.
|
|
|
|
(setq-local multi-isearch-next-buffer-function
|
|
|
|
#'eww-isearch-next-buffer))
|
|
|
|
(plist-put eww-data (cdr where) href))))
|
Merge changes made in Gnus master
2013-06-18 Teodor Zlatanov <tzz@lifelogs.com>
* auth-source.el (auth-source-netrc-parse-entries): Remove debugging.
2013-06-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-make-table-1): Implement <td rowspan>.
(shr-table-horizontal-line): Allow nil as a value, and change the default.
(shr-insert-table-ruler): Respect the nil value.
2013-06-18 Tom Tromey <tromey@barimba>
* net/eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
New defvars.
(eww-open-file): New defun.
(eww-render): Initialize new variables.
(eww-display-html): Handle "link" and "a".
(eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
(eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
(eww-back-url): Rename from eww-previous-url.
(eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New defuns.
2013-06-18 22:38:34 +00:00
|
|
|
|
2015-12-25 18:18:42 +01:00
|
|
|
(defvar eww-redirect-level 1)
|
|
|
|
|
|
|
|
(defun eww-tag-meta (dom)
|
|
|
|
(when (and (cl-equalp (dom-attr dom 'http-equiv) "refresh")
|
|
|
|
(< eww-redirect-level 5))
|
2017-09-12 13:08:47 -04:00
|
|
|
(when-let* ((refresh (dom-attr dom 'content)))
|
2015-12-25 18:18:42 +01:00
|
|
|
(when (or (string-match "^\\([0-9]+\\) *;.*url=\"\\([^\"]+\\)\"" refresh)
|
2017-01-15 19:02:47 -05:00
|
|
|
(string-match "^\\([0-9]+\\) *;.*url='\\([^']+\\)'" refresh)
|
2015-12-25 18:18:42 +01:00
|
|
|
(string-match "^\\([0-9]+\\) *;.*url=\\([^ ]+\\)" refresh))
|
|
|
|
(let ((timeout (match-string 1 refresh))
|
|
|
|
(url (match-string 2 refresh))
|
|
|
|
(eww-redirect-level (1+ eww-redirect-level)))
|
|
|
|
(if (equal timeout "0")
|
|
|
|
(eww (shr-expand-url url))
|
|
|
|
(eww-tag-a
|
|
|
|
(dom-node 'a `((href . ,(shr-expand-url url)))
|
|
|
|
(format "Auto refresh in %s second%s disabled"
|
|
|
|
timeout
|
|
|
|
(if (equal timeout "1")
|
|
|
|
""
|
|
|
|
"s"))))))))))
|
|
|
|
|
2014-11-26 19:41:13 +01:00
|
|
|
(defun eww-tag-link (dom)
|
|
|
|
(eww-handle-link dom)
|
|
|
|
(shr-generic dom))
|
Merge changes made in Gnus master
2013-06-18 Teodor Zlatanov <tzz@lifelogs.com>
* auth-source.el (auth-source-netrc-parse-entries): Remove debugging.
2013-06-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-make-table-1): Implement <td rowspan>.
(shr-table-horizontal-line): Allow nil as a value, and change the default.
(shr-insert-table-ruler): Respect the nil value.
2013-06-18 Tom Tromey <tromey@barimba>
* net/eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
New defvars.
(eww-open-file): New defun.
(eww-render): Initialize new variables.
(eww-display-html): Handle "link" and "a".
(eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
(eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
(eww-back-url): Rename from eww-previous-url.
(eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New defuns.
2013-06-18 22:38:34 +00:00
|
|
|
|
2014-11-26 19:41:13 +01:00
|
|
|
(defun eww-tag-a (dom)
|
|
|
|
(eww-handle-link dom)
|
2013-12-01 15:12:44 +01:00
|
|
|
(let ((start (point)))
|
2014-11-26 19:41:13 +01:00
|
|
|
(shr-tag-a dom)
|
2020-10-22 20:07:24 +02:00
|
|
|
(if (dom-attr dom 'href)
|
|
|
|
(put-text-property start (point)
|
|
|
|
'keymap
|
|
|
|
(if (mm-images-in-region-p start (point))
|
|
|
|
eww-image-link-keymap
|
|
|
|
eww-link-keymap)))))
|
Merge changes made in Gnus master
2013-06-18 Teodor Zlatanov <tzz@lifelogs.com>
* auth-source.el (auth-source-netrc-parse-entries): Remove debugging.
2013-06-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-make-table-1): Implement <td rowspan>.
(shr-table-horizontal-line): Allow nil as a value, and change the default.
(shr-insert-table-ruler): Respect the nil value.
2013-06-18 Tom Tromey <tromey@barimba>
* net/eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
New defvars.
(eww-open-file): New defun.
(eww-render): Initialize new variables.
(eww-display-html): Handle "link" and "a".
(eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
(eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
(eww-back-url): Rename from eww-previous-url.
(eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New defuns.
2013-06-18 22:38:34 +00:00
|
|
|
|
2020-09-07 02:26:02 +02:00
|
|
|
(defun eww--limit-string-pixelwise (string pixels)
|
|
|
|
(if (not pixels)
|
|
|
|
string
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert string)
|
|
|
|
(if (< (eww--pixel-column) pixels)
|
|
|
|
string
|
|
|
|
;; Iterate to find appropriate length.
|
|
|
|
(while (and (> (eww--pixel-column) pixels)
|
|
|
|
(not (bobp)))
|
|
|
|
(forward-char -1))
|
|
|
|
;; Return at least one character.
|
|
|
|
(buffer-substring (point-min) (max (point)
|
|
|
|
(1+ (point-min))))))))
|
|
|
|
|
|
|
|
(defun eww--pixel-column ()
|
|
|
|
(if (not (get-buffer-window (current-buffer)))
|
|
|
|
(save-window-excursion
|
|
|
|
;; Avoid errors if the selected window is a dedicated one,
|
|
|
|
;; and they just want to insert a document into it.
|
|
|
|
(set-window-dedicated-p nil nil)
|
|
|
|
(set-window-buffer nil (current-buffer))
|
|
|
|
(car (window-text-pixel-size nil (line-beginning-position) (point))))
|
|
|
|
(car (window-text-pixel-size nil (line-beginning-position) (point)))))
|
|
|
|
|
2013-06-16 22:20:55 +00:00
|
|
|
(defun eww-update-header-line-format ()
|
2014-12-09 04:21:57 +01:00
|
|
|
(setq header-line-format
|
|
|
|
(and eww-header-line-format
|
2020-09-13 17:06:35 +02:00
|
|
|
(let ((peer (plist-get eww-data :peer))
|
2020-09-13 18:51:44 +02:00
|
|
|
(url (plist-get eww-data :url))
|
2020-09-13 17:06:35 +02:00
|
|
|
(title (propertize
|
|
|
|
(if (zerop (length (plist-get eww-data :title)))
|
|
|
|
"[untitled]"
|
|
|
|
(plist-get eww-data :title))
|
|
|
|
'face 'variable-pitch)))
|
|
|
|
;; This connection is https.
|
2020-09-07 02:26:02 +02:00
|
|
|
(when peer
|
|
|
|
(add-face-text-property 0 (length title)
|
|
|
|
(if (plist-get peer :warnings)
|
|
|
|
'eww-invalid-certificate
|
|
|
|
'eww-valid-certificate)
|
|
|
|
t title))
|
2020-08-18 12:31:22 +02:00
|
|
|
;; Limit the length of the title so that the host name
|
|
|
|
;; of the URL is always visible.
|
|
|
|
(when url
|
2020-09-13 18:51:44 +02:00
|
|
|
(setq url (propertize url 'face 'variable-pitch))
|
2020-08-18 12:31:22 +02:00
|
|
|
(let* ((parsed (url-generic-parse-url url))
|
2022-06-17 13:48:53 +02:00
|
|
|
(host-length (string-pixel-width
|
2020-09-13 18:51:44 +02:00
|
|
|
(propertize
|
|
|
|
(format "%s://%s" (url-type parsed)
|
|
|
|
(url-host parsed))
|
|
|
|
'face 'variable-pitch)))
|
2020-09-07 02:26:02 +02:00
|
|
|
(width (window-width nil t)))
|
2020-08-18 12:31:22 +02:00
|
|
|
(cond
|
|
|
|
;; The host bit is wider than the window, so nix
|
|
|
|
;; the title.
|
2022-06-17 13:48:53 +02:00
|
|
|
((> (+ host-length (string-pixel-width "xxxxx")) width)
|
2020-08-18 12:31:22 +02:00
|
|
|
(setq title ""))
|
|
|
|
;; Trim the title.
|
2022-06-17 13:48:53 +02:00
|
|
|
((> (+ (string-pixel-width (concat title "xx"))
|
2020-09-07 02:26:02 +02:00
|
|
|
host-length)
|
|
|
|
width)
|
|
|
|
(setq title
|
|
|
|
(concat
|
|
|
|
(eww--limit-string-pixelwise
|
|
|
|
title (- width host-length
|
2022-06-17 13:48:53 +02:00
|
|
|
(string-pixel-width
|
2020-09-07 02:26:02 +02:00
|
|
|
(propertize "...: " 'face
|
|
|
|
'variable-pitch))))
|
|
|
|
(propertize "..." 'face 'variable-pitch)))))))
|
Use string-replace instead of replace-regexp-in-string
`string-replace` is easier to understand, less error-prone, much
faster, and results in shorter Lisp and byte code. Use it where
applicable and obviously safe (erring on the conservative side).
* admin/authors.el (authors-scan-change-log):
* lisp/autoinsert.el (auto-insert-alist):
* lisp/calc/calc-prog.el (calc-edit-macro-combine-alg-ent)
(calc-edit-macro-combine-ext-command)
(calc-edit-macro-combine-var-name):
* lisp/calc/calc-units.el (math-make-unit-string):
* lisp/calendar/cal-html.el (cal-html-comment):
* lisp/calendar/cal-tex.el (cal-tex-comment):
* lisp/calendar/icalendar.el (icalendar--convert-string-for-export)
(icalendar--convert-string-for-import):
* lisp/calendar/iso8601.el (iso8601--concat-regexps)
(iso8601--full-time-match, iso8601--combined-match):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/todo-mode.el (todo-filter-items-filename):
* lisp/cedet/cedet-files.el (cedet-directory-name-to-file-name)
(cedet-file-name-to-directory-name):
* lisp/comint.el (comint-watch-for-password-prompt):
* lisp/dired-aux.el (dired-do-chmod):
* lisp/dired-x.el (dired-man):
* lisp/dired.el (dired-insert-directory, dired-goto-file-1):
* lisp/emacs-lisp/comp.el (comp-c-func-name):
* lisp/emacs-lisp/re-builder.el (reb-copy):
* lisp/erc/erc-dcc.el (erc-dcc-unquote-filename):
* lisp/erc/erc.el (erc-quit-reason-zippy, erc-part-reason-zippy)
(erc-update-mode-line-buffer, erc-message-english-PART):
* lisp/files.el (make-backup-file-name-1, files--transform-file-name)
(read-file-modes):
* lisp/fringe.el (fringe-mode):
* lisp/gnus/gnus-art.el (gnus-button-handle-info-url):
* lisp/gnus/gnus-group.el (gnus-group-completing-read):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-ical):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-search.el (gnus-search-query-parse-date)
(gnus-search-transform-expression, gnus-search-run-search):
* lisp/gnus/gnus-start.el (gnus-dribble-enter):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-mode-string-quote):
* lisp/gnus/message.el (message-put-addresses-in-ecomplete)
(message-parse-mailto-url, message-mailto-1):
* lisp/gnus/mml-sec.el (mml-secure-epg-sign):
* lisp/gnus/mml-smime.el (mml-smime-epg-verify):
* lisp/gnus/mml2015.el (mml2015-epg-verify):
* lisp/gnus/nnmaildir.el (nnmaildir--system-name)
(nnmaildir-request-list, nnmaildir-retrieve-groups)
(nnmaildir-request-group, nnmaildir-retrieve-headers):
* lisp/gnus/nnrss.el (nnrss-node-text):
* lisp/gnus/spam-report.el (spam-report-gmane-internal)
(spam-report-user-mail-address):
* lisp/ibuffer.el (name):
* lisp/image-dired.el (image-dired-pngnq-thumb)
(image-dired-pngcrush-thumb, image-dired-optipng-thumb)
(image-dired-create-thumb-1):
* lisp/info.el (Info-set-mode-line):
* lisp/international/mule-cmds.el (describe-language-environment):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rfc2368.el (rfc2368-parse-mailto-url):
* lisp/mail/rmail.el (rmail-insert-inbox-text)
(rmail-simplified-subject-regexp):
* lisp/mail/rmailout.el (rmail-output-body-to-file):
* lisp/mail/undigest.el (rmail-digest-rfc1153):
* lisp/man.el (Man-default-man-entry):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc--debug):
* lisp/net/browse-url.el (browse-url-mail):
* lisp/net/eww.el (eww-update-header-line-format):
* lisp/net/newst-backend.el (newsticker-save-item):
* lisp/net/rcirc.el (rcirc-sentinel):
* lisp/net/soap-client.el (soap-decode-date-time):
* lisp/nxml/rng-cmpct.el (rng-c-literal-2-re):
* lisp/nxml/xmltok.el (let*):
* lisp/obsolete/nnir.el (nnir-run-swish-e, nnir-run-hyrex)
(nnir-run-find-grep):
* lisp/play/dunnet.el (dun-doassign):
* lisp/play/handwrite.el (handwrite):
* lisp/proced.el (proced-format-args):
* lisp/profiler.el (profiler-report-header-line-format):
* lisp/progmodes/gdb-mi.el (gdb-mi-quote):
* lisp/progmodes/make-mode.el (makefile-bsdmake-rule-action-regex)
(makefile-make-font-lock-keywords):
* lisp/progmodes/prolog.el (prolog-guess-fill-prefix):
* lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes):
* lisp/progmodes/sql.el (sql-remove-tabs-filter, sql-str-literal):
* lisp/progmodes/which-func.el (which-func-current):
* lisp/replace.el (query-replace-read-from)
(occur-engine, replace-quote):
* lisp/select.el (xselect--encode-string):
* lisp/ses.el (ses-export-tab):
* lisp/subr.el (shell-quote-argument):
* lisp/term/pc-win.el (msdos-show-help):
* lisp/term/w32-win.el (w32--set-selection):
* lisp/term/xterm.el (gui-backend-set-selection):
* lisp/textmodes/picture.el (picture-tab-search):
* lisp/thumbs.el (thumbs-call-setroot-command):
* lisp/tooltip.el (tooltip-show-help-non-mode):
* lisp/transient.el (transient-format-key):
* lisp/url/url-mailto.el (url-mailto):
* lisp/vc/log-edit.el (log-edit-changelog-ours-p):
* lisp/vc/vc-bzr.el (vc-bzr-status):
* lisp/vc/vc-hg.el (vc-hg--glob-to-pcre):
* lisp/vc/vc-svn.el (vc-svn-after-dir-status):
* lisp/xdg.el (xdg-desktop-strings):
* test/lisp/electric-tests.el (defun):
* test/lisp/term-tests.el (term-simple-lines):
* test/lisp/time-stamp-tests.el (formatz-mod-del-colons):
* test/lisp/wdired-tests.el (wdired-test-bug32173-01)
(wdired-test-unfinished-edit-01):
* test/src/json-tests.el (json-parse-with-custom-null-and-false-objects):
Use `string-replace` instead of `replace-regexp-in-string`.
2021-08-08 18:58:46 +02:00
|
|
|
(string-replace
|
2014-12-09 04:21:57 +01:00
|
|
|
"%" "%%"
|
|
|
|
(format-spec
|
|
|
|
eww-header-line-format
|
2020-08-18 12:31:22 +02:00
|
|
|
`((?u . ,(or url ""))
|
2014-12-09 04:21:57 +01:00
|
|
|
(?t . ,title))))))))
|
2013-06-16 22:20:55 +00:00
|
|
|
|
2024-02-17 20:49:15 -08:00
|
|
|
(defun eww--before-browse ()
|
|
|
|
(funcall eww-before-browse-history-function)
|
|
|
|
(setq eww-history-position 0
|
|
|
|
eww-data (list :title "")))
|
|
|
|
|
2021-10-15 14:12:32 +02:00
|
|
|
(defun eww--after-page-change ()
|
|
|
|
(eww-update-header-line-format)
|
|
|
|
(eww--rename-buffer))
|
|
|
|
|
2014-11-26 19:41:13 +01:00
|
|
|
(defun eww-tag-title (dom)
|
2014-11-26 22:08:44 +01:00
|
|
|
(plist-put eww-data :title
|
|
|
|
(replace-regexp-in-string
|
|
|
|
"^ \\| $" ""
|
|
|
|
(replace-regexp-in-string "[ \t\r\n]+" " " (dom-text dom))))
|
2021-10-15 14:12:32 +02:00
|
|
|
(eww--after-page-change))
|
2013-06-16 22:20:55 +00:00
|
|
|
|
2014-11-23 17:22:41 +01:00
|
|
|
(defun eww-display-raw (buffer &optional encode)
|
2013-06-10 11:46:27 +00:00
|
|
|
(let ((data (buffer-substring (point) (point-max))))
|
2014-11-23 17:22:41 +01:00
|
|
|
(unless (buffer-live-p buffer)
|
|
|
|
(error "Buffer %s doesn't exist" buffer))
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(erase-buffer)
|
|
|
|
(insert data)
|
2015-12-22 18:57:51 +02:00
|
|
|
(condition-case nil
|
|
|
|
(decode-coding-region (point-min) (1+ (length data)) encode)
|
|
|
|
(coding-system-error nil)))
|
2014-11-23 17:22:41 +01:00
|
|
|
(goto-char (point-min)))))
|
|
|
|
|
|
|
|
(defun eww-display-image (buffer)
|
2013-08-13 20:09:50 +02:00
|
|
|
(let ((data (shr-parse-image-data)))
|
2014-11-23 17:22:41 +01:00
|
|
|
(unless (buffer-live-p buffer)
|
|
|
|
(error "Buffer %s doesn't exist" buffer))
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(erase-buffer)
|
|
|
|
(shr-put-image data nil))
|
|
|
|
(goto-char (point-min)))))
|
2013-06-10 11:46:27 +00:00
|
|
|
|
2014-12-05 16:51:51 +01:00
|
|
|
(declare-function mailcap-view-mime "mailcap" (type))
|
2014-11-03 20:39:08 +01:00
|
|
|
(defun eww-display-pdf ()
|
2020-11-03 22:54:34 +00:00
|
|
|
(let ((buf (current-buffer))
|
|
|
|
(pos (point)))
|
|
|
|
(with-current-buffer (get-buffer-create "*eww pdf*")
|
2020-11-05 21:06:39 +00:00
|
|
|
(let ((inhibit-read-only t))
|
2020-11-03 22:54:34 +00:00
|
|
|
(erase-buffer)
|
2020-11-05 21:06:39 +00:00
|
|
|
(set-buffer-multibyte nil)
|
2020-11-03 22:54:34 +00:00
|
|
|
(insert-buffer-substring buf pos)
|
|
|
|
(mailcap-view-mime "application/pdf"))
|
|
|
|
(if (zerop (buffer-size))
|
|
|
|
;; Buffer contents passed to shell command via temporary file.
|
|
|
|
(kill-buffer)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(pop-to-buffer-same-window (current-buffer))))))
|
2014-11-03 20:39:08 +01:00
|
|
|
|
2014-11-27 17:06:26 +01:00
|
|
|
(defun eww-setup-buffer ()
|
2015-12-25 07:56:08 +01:00
|
|
|
(when (or (plist-get eww-data :url)
|
|
|
|
(plist-get eww-data :dom))
|
|
|
|
(eww-save-history))
|
2013-06-10 11:46:27 +00:00
|
|
|
(let ((inhibit-read-only t))
|
2013-06-26 00:24:43 +02:00
|
|
|
(remove-overlays)
|
2013-06-10 11:46:27 +00:00
|
|
|
(erase-buffer))
|
2016-03-01 10:33:05 +11:00
|
|
|
(setq bidi-paragraph-direction nil)
|
2021-09-13 10:03:24 +02:00
|
|
|
;; May be set later if there's a next/prev link.
|
|
|
|
(setq-local multi-isearch-next-buffer-function nil)
|
2013-06-26 00:24:43 +02:00
|
|
|
(unless (eq major-mode 'eww-mode)
|
2022-09-13 14:31:59 +02:00
|
|
|
(eww-mode))
|
|
|
|
(buffer-disable-undo))
|
2013-06-10 11:46:27 +00:00
|
|
|
|
2014-11-23 16:55:03 +01:00
|
|
|
(defun eww-current-url nil
|
|
|
|
"Return URI of the Web page the current EWW buffer is visiting."
|
|
|
|
(plist-get eww-data :url))
|
|
|
|
|
2015-01-12 13:07:52 -05:00
|
|
|
(defun eww-links-at-point ()
|
2014-11-23 16:55:03 +01:00
|
|
|
"Return list of URIs, if any, linked at point."
|
2022-07-03 15:29:44 +02:00
|
|
|
(seq-filter #'stringp
|
|
|
|
(list (get-text-property (point) 'shr-url)
|
|
|
|
(get-text-property (point) 'image-url))))
|
2014-11-23 16:55:03 +01:00
|
|
|
|
2013-12-05 11:04:53 -05:00
|
|
|
(defun eww-view-source ()
|
2014-11-03 01:01:20 +01:00
|
|
|
"View the HTML source code of the current page."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2013-12-05 11:04:53 -05:00
|
|
|
(let ((buf (get-buffer-create "*eww-source*"))
|
2014-11-10 21:22:59 +01:00
|
|
|
(source (plist-get eww-data :source)))
|
2013-12-05 11:04:53 -05:00
|
|
|
(with-current-buffer buf
|
2014-11-13 17:02:07 +01:00
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(delete-region (point-min) (point-max))
|
|
|
|
(insert (or source "no source"))
|
|
|
|
(goto-char (point-min))
|
2015-10-23 12:23:23 +03:00
|
|
|
;; Decode the source and set the buffer's encoding according
|
|
|
|
;; to what the HTML source specifies in its 'charset' header,
|
|
|
|
;; if any.
|
|
|
|
(let ((cs (find-auto-coding "" (point-max))))
|
|
|
|
(when (consp cs)
|
|
|
|
(setq cs (car cs))
|
|
|
|
(when (coding-system-p cs)
|
|
|
|
(decode-coding-region (point-min) (point-max) cs)
|
|
|
|
(setq buffer-file-coding-system last-coding-system-used))))
|
2017-03-23 11:34:27 -06:00
|
|
|
(cond
|
|
|
|
((fboundp 'mhtml-mode)
|
|
|
|
(mhtml-mode))
|
|
|
|
((fboundp 'html-mode)
|
|
|
|
(html-mode)))))
|
2013-12-05 11:04:53 -05:00
|
|
|
(view-buffer buf)))
|
|
|
|
|
2016-02-28 14:52:56 +10:30
|
|
|
(defun eww-toggle-paragraph-direction ()
|
2016-03-01 11:31:37 +11:00
|
|
|
"Cycle the paragraph direction between left-to-right, right-to-left and auto."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2016-02-28 14:52:56 +10:30
|
|
|
(setq bidi-paragraph-direction
|
2016-03-01 11:31:37 +11:00
|
|
|
(cond ((eq bidi-paragraph-direction 'left-to-right)
|
|
|
|
nil)
|
|
|
|
((eq bidi-paragraph-direction 'right-to-left)
|
|
|
|
'left-to-right)
|
|
|
|
(t
|
|
|
|
'right-to-left)))
|
|
|
|
(message "The paragraph direction is now %s"
|
|
|
|
(if (null bidi-paragraph-direction)
|
|
|
|
"automatic"
|
|
|
|
bidi-paragraph-direction)))
|
2016-02-28 14:52:56 +10:30
|
|
|
|
2024-03-17 12:01:59 -07:00
|
|
|
(defun eww-readable (&optional arg)
|
|
|
|
"Toggle display of only the main \"readable\" parts of the current web page.
|
2014-11-03 01:01:20 +01:00
|
|
|
This command uses heuristics to find the parts of the web page that
|
2024-03-17 12:01:59 -07:00
|
|
|
contain the main textual portion, leaving out navigation menus and the
|
|
|
|
like.
|
|
|
|
|
|
|
|
If called interactively, toggle the display of the readable parts. If
|
|
|
|
the prefix argument is positive, display the readable parts, and if it
|
|
|
|
is zero or negative, display the full page.
|
|
|
|
|
|
|
|
If called from Lisp, toggle the display of the readable parts if ARG is
|
|
|
|
`toggle'. Display the readable parts if ARG is nil, omitted, or is a
|
|
|
|
positive number. Display the full page if ARG is a negative number.
|
|
|
|
|
|
|
|
When `eww-readable-adds-to-history' is non-nil, calling this function
|
|
|
|
adds a new entry to `eww-history'."
|
|
|
|
(interactive (list (if current-prefix-arg
|
|
|
|
(prefix-numeric-value current-prefix-arg)
|
|
|
|
'toggle))
|
|
|
|
eww-mode)
|
2014-11-10 21:34:43 +01:00
|
|
|
(let* ((old-data eww-data)
|
2024-03-17 12:01:59 -07:00
|
|
|
(make-readable (cond
|
|
|
|
((eq arg 'toggle)
|
|
|
|
(not (plist-get old-data :readable)))
|
|
|
|
((and (numberp arg) (< arg 1))
|
|
|
|
nil)
|
|
|
|
(t t)))
|
|
|
|
(dom (with-temp-buffer
|
2014-11-26 19:41:13 +01:00
|
|
|
(insert (plist-get old-data :source))
|
2024-03-17 12:01:59 -07:00
|
|
|
(eww--parse-html-region (point-min) (point-max))))
|
2016-02-09 13:51:45 +11:00
|
|
|
(base (plist-get eww-data :url)))
|
2024-03-17 12:01:59 -07:00
|
|
|
(when make-readable
|
|
|
|
(eww-score-readability dom)
|
|
|
|
(setq dom (eww-highest-readability dom)))
|
|
|
|
(when eww-readable-adds-to-history
|
|
|
|
(eww-save-history)
|
|
|
|
(eww--before-browse)
|
|
|
|
(dolist (elem '(:source :url :title :next :previous :up :peer))
|
|
|
|
(plist-put eww-data elem (plist-get old-data elem))))
|
|
|
|
(eww-display-document (eww-document-base base dom))
|
|
|
|
(plist-put eww-data :readable make-readable)
|
2021-10-15 14:12:32 +02:00
|
|
|
(eww--after-page-change)))
|
2014-11-03 01:01:20 +01:00
|
|
|
|
|
|
|
(defun eww-score-readability (node)
|
|
|
|
(let ((score -1))
|
|
|
|
(cond
|
2014-11-26 19:41:13 +01:00
|
|
|
((memq (dom-tag node) '(script head comment))
|
2014-11-03 01:01:20 +01:00
|
|
|
(setq score -2))
|
2014-11-26 19:41:13 +01:00
|
|
|
((eq (dom-tag node) 'meta)
|
2014-11-03 01:01:20 +01:00
|
|
|
(setq score -1))
|
2014-11-26 19:41:13 +01:00
|
|
|
((eq (dom-tag node) 'img)
|
2014-11-03 01:16:21 +01:00
|
|
|
(setq score 2))
|
2014-11-26 19:41:13 +01:00
|
|
|
((eq (dom-tag node) 'a)
|
|
|
|
(setq score (- (length (split-string (dom-text node))))))
|
2014-11-03 01:01:20 +01:00
|
|
|
(t
|
2014-11-26 19:41:13 +01:00
|
|
|
(dolist (elem (dom-children node))
|
2016-05-05 19:41:11 +02:00
|
|
|
(cond
|
|
|
|
((stringp elem)
|
|
|
|
(setq score (+ score (length (split-string elem)))))
|
|
|
|
((consp elem)
|
2014-11-03 01:01:20 +01:00
|
|
|
(setq score (+ score
|
|
|
|
(or (cdr (assoc :eww-readability-score (cdr elem)))
|
2016-05-05 19:41:11 +02:00
|
|
|
(eww-score-readability elem)))))))))
|
2014-11-03 01:01:20 +01:00
|
|
|
;; Cache the score of the node to avoid recomputing all the time.
|
2014-11-26 19:41:13 +01:00
|
|
|
(dom-set-attribute node :eww-readability-score score)
|
2014-11-03 01:01:20 +01:00
|
|
|
score))
|
|
|
|
|
|
|
|
(defun eww-highest-readability (node)
|
|
|
|
(let ((result node)
|
|
|
|
highest)
|
2014-11-26 22:08:44 +01:00
|
|
|
(dolist (elem (dom-non-text-children node))
|
|
|
|
(when (> (or (dom-attr
|
|
|
|
(setq highest (eww-highest-readability elem))
|
|
|
|
:eww-readability-score)
|
|
|
|
most-negative-fixnum)
|
|
|
|
(or (dom-attr result :eww-readability-score)
|
|
|
|
most-negative-fixnum))
|
2018-04-13 00:13:17 +02:00
|
|
|
;; We set a lower bound to how long we accept that the
|
|
|
|
;; readable portion of the page is going to be.
|
|
|
|
(when (> (length (split-string (dom-texts highest))) 100)
|
|
|
|
(setq result highest))))
|
2014-11-03 01:01:20 +01:00
|
|
|
result))
|
|
|
|
|
2024-03-18 16:52:34 -07:00
|
|
|
(defun eww-default-readable-p (url)
|
|
|
|
"Return non-nil if URL should be displayed in readable mode by default.
|
|
|
|
This consults the entries in `eww-readable-urls' (which see)."
|
|
|
|
(catch 'found
|
|
|
|
(let (result)
|
|
|
|
(dolist (regexp eww-readable-urls)
|
|
|
|
(if (consp regexp)
|
|
|
|
(setq result (cdr regexp)
|
|
|
|
regexp (car regexp))
|
|
|
|
(setq result t))
|
|
|
|
(when (string-match regexp url)
|
|
|
|
(throw 'found result))))))
|
|
|
|
|
2021-10-05 10:34:37 +02:00
|
|
|
(defvar-keymap eww-mode-map
|
2021-10-04 10:15:04 +02:00
|
|
|
"g" #'eww-reload ;FIXME: revert-buffer-function instead!
|
|
|
|
"G" #'eww
|
2021-11-16 08:18:30 +01:00
|
|
|
"M-RET" #'eww-open-in-new-buffer
|
|
|
|
"TAB" #'shr-next-link
|
|
|
|
"C-M-i" #'shr-previous-link
|
|
|
|
"<backtab>" #'shr-previous-link
|
|
|
|
"<delete>" #'scroll-down-command
|
2021-10-04 10:15:04 +02:00
|
|
|
"l" #'eww-back-url
|
|
|
|
"r" #'eww-forward-url
|
|
|
|
"n" #'eww-next-url
|
|
|
|
"p" #'eww-previous-url
|
|
|
|
"u" #'eww-up-url
|
|
|
|
"t" #'eww-top-url
|
|
|
|
"&" #'eww-browse-with-external-browser
|
|
|
|
"d" #'eww-download
|
|
|
|
"w" #'eww-copy-page-url
|
2023-06-17 13:48:51 +03:00
|
|
|
"A" #'eww-copy-alternate-url
|
2021-10-04 10:15:04 +02:00
|
|
|
"C" #'url-cookie-list
|
|
|
|
"v" #'eww-view-source
|
|
|
|
"R" #'eww-readable
|
|
|
|
"H" #'eww-list-histories
|
|
|
|
"E" #'eww-set-character-encoding
|
|
|
|
"s" #'eww-switch-to-buffer
|
|
|
|
"S" #'eww-list-buffers
|
|
|
|
"F" #'eww-toggle-fonts
|
|
|
|
"D" #'eww-toggle-paragraph-direction
|
2021-11-16 08:18:30 +01:00
|
|
|
"M-C" #'eww-toggle-colors
|
|
|
|
"M-I" #'eww-toggle-images
|
2021-10-04 10:15:04 +02:00
|
|
|
|
|
|
|
"b" #'eww-add-bookmark
|
|
|
|
"B" #'eww-list-bookmarks
|
2021-11-16 08:18:30 +01:00
|
|
|
"M-n" #'eww-next-bookmark
|
|
|
|
"M-p" #'eww-previous-bookmark
|
2021-10-04 10:15:04 +02:00
|
|
|
|
2021-11-16 08:18:30 +01:00
|
|
|
"<mouse-8>" #'eww-back-url
|
|
|
|
"<mouse-9>" #'eww-forward-url
|
2021-11-09 18:07:30 +01:00
|
|
|
|
2021-10-04 10:15:04 +02:00
|
|
|
:menu '("Eww"
|
|
|
|
["Exit" quit-window t]
|
|
|
|
["Close browser" quit-window t]
|
|
|
|
["Reload" eww-reload t]
|
|
|
|
["Follow URL in new buffer" eww-open-in-new-buffer]
|
|
|
|
["Back to previous page" eww-back-url
|
2024-02-17 20:49:15 -08:00
|
|
|
:active (< eww-history-position (length eww-history))]
|
2021-10-04 10:15:04 +02:00
|
|
|
["Forward to next page" eww-forward-url
|
2024-02-17 20:49:15 -08:00
|
|
|
:active (> eww-history-position 1)]
|
2021-10-04 10:15:04 +02:00
|
|
|
["Browse with external browser" eww-browse-with-external-browser t]
|
|
|
|
["Download" eww-download t]
|
|
|
|
["View page source" eww-view-source]
|
|
|
|
["Copy page URL" eww-copy-page-url t]
|
|
|
|
["List histories" eww-list-histories t]
|
|
|
|
["Switch to buffer" eww-switch-to-buffer t]
|
|
|
|
["List buffers" eww-list-buffers t]
|
|
|
|
["Add bookmark" eww-add-bookmark t]
|
|
|
|
["List bookmarks" eww-list-bookmarks t]
|
|
|
|
["List cookies" url-cookie-list t]
|
|
|
|
["Toggle fonts" eww-toggle-fonts t]
|
|
|
|
["Toggle colors" eww-toggle-colors t]
|
|
|
|
["Toggle images" eww-toggle-images t]
|
|
|
|
["Character Encoding" eww-set-character-encoding]
|
|
|
|
["Toggle Paragraph Direction" eww-toggle-paragraph-direction]))
|
2013-06-10 11:46:27 +00:00
|
|
|
|
2021-09-12 20:11:52 +03:00
|
|
|
(defun eww-context-menu (menu click)
|
2021-09-15 19:00:56 +03:00
|
|
|
"Populate MENU with eww commands at CLICK."
|
2021-07-27 23:48:07 +03:00
|
|
|
(define-key menu [eww-separator] menu-bar-separator)
|
2021-07-21 23:34:59 +03:00
|
|
|
(let ((easy-menu (make-sparse-keymap "Eww")))
|
|
|
|
(easy-menu-define nil easy-menu nil
|
2013-08-28 21:17:10 -04:00
|
|
|
'("Eww"
|
2021-07-21 23:34:59 +03:00
|
|
|
["Back to previous page" eww-back-url
|
2024-02-17 20:49:15 -08:00
|
|
|
:active (< eww-history-position (length eww-history))]
|
2013-06-26 15:07:24 +02:00
|
|
|
["Forward to next page" eww-forward-url
|
2024-02-17 20:49:15 -08:00
|
|
|
:active (> eww-history-position 1)]
|
2021-07-21 23:34:59 +03:00
|
|
|
["Reload" eww-reload t]))
|
|
|
|
(dolist (item (reverse (lookup-key easy-menu [menu-bar eww])))
|
|
|
|
(when (consp item)
|
|
|
|
(define-key menu (vector (car item)) (cdr item)))))
|
|
|
|
|
2021-09-12 20:11:52 +03:00
|
|
|
(when (or (mouse-posn-property (event-start click) 'shr-url)
|
|
|
|
(mouse-posn-property (event-start click) 'image-url))
|
2021-07-21 23:34:59 +03:00
|
|
|
(define-key menu [shr-mouse-browse-url-new-window]
|
|
|
|
`(menu-item "Follow URL in new window" ,(if browse-url-new-window-flag
|
|
|
|
'shr-mouse-browse-url
|
|
|
|
'shr-mouse-browse-url-new-window)
|
|
|
|
:help "Browse the URL under the mouse cursor in a new window"))
|
|
|
|
(define-key menu [shr-mouse-browse-url]
|
|
|
|
`(menu-item "Follow URL" ,(if browse-url-new-window-flag
|
|
|
|
'shr-mouse-browse-url-new-window
|
|
|
|
'shr-mouse-browse-url)
|
|
|
|
:help "Browse the URL under the mouse cursor")))
|
|
|
|
|
|
|
|
menu)
|
2013-06-10 11:46:27 +00:00
|
|
|
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(defvar eww-tool-bar-map
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
(dolist (tool-bar-item
|
2014-11-02 16:02:10 -05:00
|
|
|
'((quit-window . "close")
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(eww-reload . "refresh")
|
|
|
|
(eww-back-url . "left-arrow")
|
|
|
|
(eww-forward-url . "right-arrow")
|
|
|
|
(eww-view-source . "show")
|
|
|
|
(eww-copy-page-url . "copy")
|
|
|
|
(eww-add-bookmark . "bookmark_add"))) ;; ...
|
|
|
|
(tool-bar-local-item-from-menu
|
|
|
|
(car tool-bar-item) (cdr tool-bar-item) map eww-mode-map))
|
|
|
|
map)
|
|
|
|
"Tool bar for `eww-mode'.")
|
|
|
|
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
(declare-function set-text-conversion-style "textconv.c")
|
|
|
|
|
|
|
|
(defun eww-check-text-conversion ()
|
|
|
|
"Check if point is within a field and toggle text conversion.
|
2024-04-29 15:32:12 +03:00
|
|
|
Set `text-conversion-style' to the value `action' if it isn't
|
|
|
|
already and point is within the prompt field, or if
|
2024-07-08 14:10:46 +02:00
|
|
|
`text-conversion-style' is nil, so as to guarantee that
|
2024-04-29 15:32:12 +03:00
|
|
|
the input method functions properly for the purpose of typing
|
2024-04-30 13:21:59 +08:00
|
|
|
within text input fields."
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
(when (and (eq major-mode 'eww-mode)
|
|
|
|
(fboundp 'set-text-conversion-style))
|
|
|
|
(if (eq (car-safe (get-text-property (point) 'field))
|
|
|
|
:eww-form)
|
|
|
|
(unless (eq text-conversion-style 'action)
|
|
|
|
(set-text-conversion-style 'action))
|
|
|
|
(unless (not text-conversion-style)
|
|
|
|
(set-text-conversion-style nil)))))
|
|
|
|
|
2015-02-16 18:55:02 +00:00
|
|
|
;; Autoload cookie needed by desktop.el.
|
|
|
|
;;;###autoload
|
2015-01-12 13:07:52 -05:00
|
|
|
(define-derived-mode eww-mode special-mode "eww"
|
2021-09-29 01:37:26 +02:00
|
|
|
"Mode for browsing the web.
|
|
|
|
|
|
|
|
\\{eww-mode-map}"
|
2021-02-14 14:08:56 +01:00
|
|
|
:interactive nil
|
2014-11-10 21:22:59 +01:00
|
|
|
(setq-local eww-data (list :title ""))
|
2015-01-12 13:07:52 -05:00
|
|
|
(setq-local browse-url-browser-function #'eww-browse-url)
|
|
|
|
(add-hook 'after-change-functions #'eww-process-text-input nil t)
|
2021-07-21 23:34:59 +03:00
|
|
|
(add-hook 'context-menu-functions 'eww-context-menu 5 t)
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(setq-local eww-history nil)
|
|
|
|
(setq-local eww-history-position 0)
|
|
|
|
(when (boundp 'tool-bar-map)
|
2015-01-12 13:07:52 -05:00
|
|
|
(setq-local tool-bar-map eww-tool-bar-map))
|
2014-11-19 18:21:58 +01:00
|
|
|
;; desktop support
|
2015-01-12 13:07:52 -05:00
|
|
|
(setq-local desktop-save-buffer #'eww-desktop-misc-data)
|
2015-12-28 21:02:43 +01:00
|
|
|
(setq truncate-lines t)
|
2024-04-28 21:19:53 -07:00
|
|
|
;; thingatpt support
|
2021-01-23 20:39:45 +01:00
|
|
|
(setq-local thing-at-point-provider-alist
|
2024-04-28 21:19:53 -07:00
|
|
|
(cons '(url . eww--url-at-point)
|
|
|
|
thing-at-point-provider-alist))
|
|
|
|
(setq-local forward-thing-provider-alist
|
|
|
|
(cons '(url . eww--forward-url)
|
|
|
|
forward-thing-provider-alist))
|
|
|
|
(setq-local bounds-of-thing-at-point-provider-alist
|
|
|
|
(cons '(url . eww--bounds-of-url-at-point)
|
|
|
|
bounds-of-thing-at-point-provider-alist))
|
2021-09-29 03:24:10 +02:00
|
|
|
(setq-local bookmark-make-record-function #'eww-bookmark-make-record)
|
2014-11-27 17:52:08 +01:00
|
|
|
(buffer-disable-undo)
|
2022-09-14 15:16:27 +02:00
|
|
|
(setq-local shr-url-transformer #'eww--transform-url)
|
2022-09-26 13:53:10 +02:00
|
|
|
;; Also rescale images when rescaling the text.
|
|
|
|
(add-hook 'text-scale-mode-hook #'eww--rescale-images nil t)
|
2023-10-24 23:35:44 +02:00
|
|
|
(setq-local outline-search-function 'shr-outline-search
|
|
|
|
outline-level 'shr-outline-level)
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
(add-hook 'post-command-hook #'eww-check-text-conversion nil t)
|
2024-04-30 13:21:59 +08:00
|
|
|
(setq buffer-read-only t)
|
|
|
|
;; Insertion at the first character of a field should inherit the
|
|
|
|
;; field's face, form and field, not the previous character's.
|
|
|
|
(setq text-property-default-nonsticky '((face . t) (eww-form . t)
|
|
|
|
(field . t))))
|
2013-06-10 11:46:27 +00:00
|
|
|
|
2024-05-14 20:42:11 +03:00
|
|
|
(declare-function imagep "image.c")
|
2022-09-26 13:53:10 +02:00
|
|
|
(defvar text-scale-mode)
|
|
|
|
(defvar text-scale-mode-amount)
|
|
|
|
(defun eww--rescale-images ()
|
|
|
|
(let ((scaling (if text-scale-mode
|
|
|
|
(+ 1 (* text-scale-mode-amount 0.1))
|
2022-09-28 13:27:05 +02:00
|
|
|
1)))
|
2022-09-26 13:53:10 +02:00
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
2022-09-28 13:27:05 +02:00
|
|
|
(while-let ((match (text-property-search-forward
|
|
|
|
'display nil (lambda (_ value) (imagep value)))))
|
2024-06-23 16:59:00 -07:00
|
|
|
(let* ((image (prop-match-value match))
|
|
|
|
(original-scale (or (image-property image :original-scale)
|
|
|
|
(setf (image-property image :original-scale)
|
|
|
|
(or (image-property image :scale)
|
|
|
|
'default)))))
|
|
|
|
(when (eq original-scale 'default)
|
|
|
|
(setq original-scale (image-compute-scaling-factor
|
|
|
|
image-scaling-factor)))
|
2022-09-28 13:27:05 +02:00
|
|
|
(setf (image-property image :scale)
|
2024-06-23 16:59:00 -07:00
|
|
|
(* original-scale scaling)))))))
|
2022-09-26 13:53:10 +02:00
|
|
|
|
2021-01-23 20:39:45 +01:00
|
|
|
(defun eww--url-at-point ()
|
|
|
|
"`thing-at-point' provider function."
|
2024-05-20 12:45:13 -07:00
|
|
|
(thing-at-point-for-char-property 'shr-url))
|
2024-04-28 21:19:53 -07:00
|
|
|
|
2024-05-20 12:37:22 -07:00
|
|
|
(defun eww--forward-url (backward)
|
2024-04-28 21:19:53 -07:00
|
|
|
"`forward-thing' provider function."
|
2024-05-20 12:45:13 -07:00
|
|
|
(forward-thing-for-char-property 'shr-url backward))
|
2024-04-28 21:19:53 -07:00
|
|
|
|
|
|
|
(defun eww--bounds-of-url-at-point ()
|
|
|
|
"`bounds-of-thing-at-point' provider function."
|
2024-05-20 12:45:13 -07:00
|
|
|
(bounds-of-thing-at-point-for-char-property 'shr-url))
|
2021-01-23 20:39:45 +01:00
|
|
|
|
2013-06-28 09:54:42 +02:00
|
|
|
;;;###autoload
|
2014-11-23 18:30:17 +01:00
|
|
|
(defun eww-browse-url (url &optional new-window)
|
2019-10-07 00:08:10 +03:00
|
|
|
"Ask the EWW browser to load URL.
|
|
|
|
|
|
|
|
Interactively, if the variable `browse-url-new-window-flag' is non-nil,
|
|
|
|
loads the document in a new buffer tab on the window tab-line. A non-nil
|
|
|
|
prefix argument reverses the effect of `browse-url-new-window-flag'.
|
|
|
|
|
|
|
|
If `tab-bar-mode' is enabled, then whenever a document would
|
|
|
|
otherwise be loaded in a new buffer, it is loaded in a new tab
|
2019-10-20 01:40:05 +03:00
|
|
|
in the tab-bar on an existing frame. See more options in
|
|
|
|
`eww-browse-url-new-window-is-tab'.
|
2019-10-07 00:08:10 +03:00
|
|
|
|
|
|
|
Non-interactively, this uses the optional second argument NEW-WINDOW
|
|
|
|
instead of `browse-url-new-window-flag'."
|
2016-02-02 15:43:35 +11:00
|
|
|
(when new-window
|
2019-10-20 01:40:05 +03:00
|
|
|
(when (or (eq eww-browse-url-new-window-is-tab t)
|
|
|
|
(and (eq eww-browse-url-new-window-is-tab 'tab-bar)
|
|
|
|
tab-bar-mode))
|
2019-10-07 00:08:10 +03:00
|
|
|
(let ((tab-bar-new-tab-choice t))
|
|
|
|
(tab-new)))
|
2017-01-24 22:40:57 +01:00
|
|
|
(pop-to-buffer-same-window
|
|
|
|
(generate-new-buffer
|
|
|
|
(format "*eww-%s*" (url-host (url-generic-parse-url
|
|
|
|
(eww--dwim-expand-url url))))))
|
2016-02-02 15:43:35 +11:00
|
|
|
(eww-mode))
|
2022-02-20 16:08:45 +01:00
|
|
|
(let ((url-allow-non-local-files t))
|
|
|
|
(eww url)))
|
2013-06-10 11:46:27 +00:00
|
|
|
|
2022-07-07 14:43:46 +02:00
|
|
|
(function-put 'eww-browse-url 'browse-url-browser-kind 'internal)
|
|
|
|
|
Merge changes made in Gnus master
2013-06-18 Teodor Zlatanov <tzz@lifelogs.com>
* auth-source.el (auth-source-netrc-parse-entries): Remove debugging.
2013-06-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-make-table-1): Implement <td rowspan>.
(shr-table-horizontal-line): Allow nil as a value, and change the default.
(shr-insert-table-ruler): Respect the nil value.
2013-06-18 Tom Tromey <tromey@barimba>
* net/eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
New defvars.
(eww-open-file): New defun.
(eww-render): Initialize new variables.
(eww-display-html): Handle "link" and "a".
(eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
(eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
(eww-back-url): Rename from eww-previous-url.
(eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New defuns.
2013-06-18 22:38:34 +00:00
|
|
|
(defun eww-back-url ()
|
2013-06-10 11:46:27 +00:00
|
|
|
"Go to the previously displayed page."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2013-06-25 17:39:13 +02:00
|
|
|
(when (>= eww-history-position (length eww-history))
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(user-error "No previous page"))
|
2024-02-17 20:49:15 -08:00
|
|
|
(if (eww-save-history)
|
|
|
|
;; We were at the latest page (which was just added to the
|
|
|
|
;; history), so go back two entries.
|
|
|
|
(setq eww-history-position 2)
|
|
|
|
(setq eww-history-position (1+ eww-history-position)))
|
2013-06-26 00:24:43 +02:00
|
|
|
(eww-restore-history (elt eww-history (1- eww-history-position))))
|
2013-06-25 17:39:13 +02:00
|
|
|
|
|
|
|
(defun eww-forward-url ()
|
|
|
|
"Go to the next displayed page."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2024-02-17 20:49:15 -08:00
|
|
|
(when (<= eww-history-position 1)
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(user-error "No next page"))
|
2013-06-26 00:24:43 +02:00
|
|
|
(eww-save-history)
|
2024-02-17 20:49:15 -08:00
|
|
|
(setq eww-history-position (1- eww-history-position))
|
2013-06-26 00:24:43 +02:00
|
|
|
(eww-restore-history (elt eww-history (1- eww-history-position))))
|
2013-06-25 17:39:13 +02:00
|
|
|
|
|
|
|
(defun eww-restore-history (elem)
|
2014-11-19 18:21:58 +01:00
|
|
|
(let ((inhibit-read-only t)
|
2014-11-27 21:26:49 +01:00
|
|
|
(inhibit-modification-hooks t)
|
2014-11-19 18:21:58 +01:00
|
|
|
(text (plist-get elem :text)))
|
2014-11-10 21:22:59 +01:00
|
|
|
(setq eww-data elem)
|
2014-11-19 18:21:58 +01:00
|
|
|
(if (null text)
|
|
|
|
(eww-reload) ; FIXME: restore :point?
|
|
|
|
(erase-buffer)
|
|
|
|
(insert text)
|
|
|
|
(goto-char (plist-get elem :point))
|
2017-01-26 18:32:48 +01:00
|
|
|
;; Make buffer listings more informative.
|
|
|
|
(setq list-buffers-directory (plist-get elem :url))
|
2021-10-15 14:12:32 +02:00
|
|
|
(eww--after-page-change))))
|
2013-06-10 11:46:27 +00:00
|
|
|
|
Merge changes made in Gnus master
2013-06-18 Teodor Zlatanov <tzz@lifelogs.com>
* auth-source.el (auth-source-netrc-parse-entries): Remove debugging.
2013-06-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-make-table-1): Implement <td rowspan>.
(shr-table-horizontal-line): Allow nil as a value, and change the default.
(shr-insert-table-ruler): Respect the nil value.
2013-06-18 Tom Tromey <tromey@barimba>
* net/eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
New defvars.
(eww-open-file): New defun.
(eww-render): Initialize new variables.
(eww-display-html): Handle "link" and "a".
(eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
(eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
(eww-back-url): Rename from eww-previous-url.
(eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New defuns.
2013-06-18 22:38:34 +00:00
|
|
|
(defun eww-next-url ()
|
|
|
|
"Go to the page marked `next'.
|
|
|
|
A page is marked `next' if rel=\"next\" appears in a <link>
|
|
|
|
or <a> tag."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2014-11-10 21:30:30 +01:00
|
|
|
(if (plist-get eww-data :next)
|
|
|
|
(eww-browse-url (shr-expand-url (plist-get eww-data :next)
|
|
|
|
(plist-get eww-data :url)))
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(user-error "No `next' on this page")))
|
Merge changes made in Gnus master
2013-06-18 Teodor Zlatanov <tzz@lifelogs.com>
* auth-source.el (auth-source-netrc-parse-entries): Remove debugging.
2013-06-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-make-table-1): Implement <td rowspan>.
(shr-table-horizontal-line): Allow nil as a value, and change the default.
(shr-insert-table-ruler): Respect the nil value.
2013-06-18 Tom Tromey <tromey@barimba>
* net/eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
New defvars.
(eww-open-file): New defun.
(eww-render): Initialize new variables.
(eww-display-html): Handle "link" and "a".
(eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
(eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
(eww-back-url): Rename from eww-previous-url.
(eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New defuns.
2013-06-18 22:38:34 +00:00
|
|
|
|
|
|
|
(defun eww-previous-url ()
|
|
|
|
"Go to the page marked `previous'.
|
|
|
|
A page is marked `previous' if rel=\"previous\" appears in a <link>
|
|
|
|
or <a> tag."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2014-11-10 21:30:30 +01:00
|
|
|
(if (plist-get eww-data :previous)
|
|
|
|
(eww-browse-url (shr-expand-url (plist-get eww-data :previous)
|
2014-11-10 21:22:59 +01:00
|
|
|
(plist-get eww-data :url)))
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(user-error "No `previous' on this page")))
|
Merge changes made in Gnus master
2013-06-18 Teodor Zlatanov <tzz@lifelogs.com>
* auth-source.el (auth-source-netrc-parse-entries): Remove debugging.
2013-06-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-make-table-1): Implement <td rowspan>.
(shr-table-horizontal-line): Allow nil as a value, and change the default.
(shr-insert-table-ruler): Respect the nil value.
2013-06-18 Tom Tromey <tromey@barimba>
* net/eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
New defvars.
(eww-open-file): New defun.
(eww-render): Initialize new variables.
(eww-display-html): Handle "link" and "a".
(eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
(eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
(eww-back-url): Rename from eww-previous-url.
(eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New defuns.
2013-06-18 22:38:34 +00:00
|
|
|
|
|
|
|
(defun eww-up-url ()
|
|
|
|
"Go to the page marked `up'.
|
|
|
|
A page is marked `up' if rel=\"up\" appears in a <link>
|
|
|
|
or <a> tag."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2014-11-10 21:30:30 +01:00
|
|
|
(if (plist-get eww-data :up)
|
|
|
|
(eww-browse-url (shr-expand-url (plist-get eww-data :up)
|
|
|
|
(plist-get eww-data :url)))
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(user-error "No `up' on this page")))
|
Merge changes made in Gnus master
2013-06-18 Teodor Zlatanov <tzz@lifelogs.com>
* auth-source.el (auth-source-netrc-parse-entries): Remove debugging.
2013-06-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-make-table-1): Implement <td rowspan>.
(shr-table-horizontal-line): Allow nil as a value, and change the default.
(shr-insert-table-ruler): Respect the nil value.
2013-06-18 Tom Tromey <tromey@barimba>
* net/eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
New defvars.
(eww-open-file): New defun.
(eww-render): Initialize new variables.
(eww-display-html): Handle "link" and "a".
(eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
(eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
(eww-back-url): Rename from eww-previous-url.
(eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New defuns.
2013-06-18 22:38:34 +00:00
|
|
|
|
|
|
|
(defun eww-top-url ()
|
|
|
|
"Go to the page marked `top'.
|
2013-06-19 22:28:04 +00:00
|
|
|
A page is marked `top' if rel=\"start\", rel=\"home\", or rel=\"contents\"
|
|
|
|
appears in a <link> or <a> tag."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2014-11-10 21:30:30 +01:00
|
|
|
(let ((best-url (or (plist-get eww-data :start)
|
|
|
|
(plist-get eww-data :contents)
|
|
|
|
(plist-get eww-data :home))))
|
2013-06-19 22:28:04 +00:00
|
|
|
(if best-url
|
2014-11-10 21:22:59 +01:00
|
|
|
(eww-browse-url (shr-expand-url best-url (plist-get eww-data :url)))
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(user-error "No `top' for this page"))))
|
Merge changes made in Gnus master
2013-06-18 Teodor Zlatanov <tzz@lifelogs.com>
* auth-source.el (auth-source-netrc-parse-entries): Remove debugging.
2013-06-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/shr.el (shr-make-table-1): Implement <td rowspan>.
(shr-table-horizontal-line): Allow nil as a value, and change the default.
(shr-insert-table-ruler): Respect the nil value.
2013-06-18 Tom Tromey <tromey@barimba>
* net/eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
New defvars.
(eww-open-file): New defun.
(eww-render): Initialize new variables.
(eww-display-html): Handle "link" and "a".
(eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
(eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
(eww-back-url): Rename from eww-previous-url.
(eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New defuns.
2013-06-18 22:38:34 +00:00
|
|
|
|
2014-12-07 20:49:16 +01:00
|
|
|
(defun eww-reload (&optional local encode)
|
|
|
|
"Reload the current page.
|
2017-03-11 17:43:35 +02:00
|
|
|
If LOCAL is non-nil (interactively, the command was invoked with
|
|
|
|
a prefix argument), don't reload the page from the network, but
|
|
|
|
just re-display the HTML already fetched."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive "P" eww-mode)
|
2014-11-10 21:22:59 +01:00
|
|
|
(let ((url (plist-get eww-data :url)))
|
2014-12-07 20:49:16 +01:00
|
|
|
(if local
|
|
|
|
(if (null (plist-get eww-data :dom))
|
|
|
|
(error "No current HTML data")
|
2024-03-17 12:01:59 -07:00
|
|
|
(eww-display-document (plist-get eww-data :dom) (point)))
|
2022-02-20 15:52:10 +01:00
|
|
|
(let ((parsed (url-generic-parse-url url)))
|
|
|
|
(if (equal (url-type parsed) "file")
|
|
|
|
;; Use Tramp instead of url.el for files (since url.el
|
|
|
|
;; doesn't work well with Tramp files).
|
|
|
|
(let ((eww-buffer (current-buffer)))
|
|
|
|
(with-current-buffer (eww--file-buffer (url-filename parsed))
|
|
|
|
(eww-render nil url nil eww-buffer)))
|
|
|
|
(let ((url-mime-accept-string eww-accept-content-types))
|
|
|
|
(eww-retrieve url #'eww-render
|
|
|
|
(list url (point) (current-buffer) encode))))))))
|
2013-06-10 22:12:47 +00:00
|
|
|
|
2013-06-10 14:11:01 +00:00
|
|
|
;; Form support.
|
|
|
|
|
|
|
|
(defvar eww-form nil)
|
|
|
|
|
2021-10-05 10:34:37 +02:00
|
|
|
(defvar-keymap eww-submit-map
|
2021-11-16 08:18:30 +01:00
|
|
|
"RET" #'eww-submit
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
"C-c C-c" #'eww-submit
|
|
|
|
"<mouse-2>" #'eww-submit)
|
2021-10-04 10:15:04 +02:00
|
|
|
|
2021-10-05 10:34:37 +02:00
|
|
|
(defvar-keymap eww-submit-file
|
2021-11-16 08:18:30 +01:00
|
|
|
"RET" #'eww-select-file
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
"C-c C-c" #'eww-submit
|
|
|
|
"<mouse-2>" #'eww-select-file)
|
2021-10-04 10:15:04 +02:00
|
|
|
|
2021-10-05 10:34:37 +02:00
|
|
|
(defvar-keymap eww-checkbox-map
|
2021-11-16 08:18:30 +01:00
|
|
|
"SPC" #'eww-toggle-checkbox
|
|
|
|
"RET" #'eww-toggle-checkbox
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
"C-c C-c" #'eww-submit
|
|
|
|
"<mouse-2>" #'eww-toggle-checkbox)
|
2021-10-04 10:15:04 +02:00
|
|
|
|
2021-10-05 10:34:37 +02:00
|
|
|
(defvar-keymap eww-text-map
|
|
|
|
:full t :parent text-mode-map
|
2021-11-16 08:18:30 +01:00
|
|
|
"RET" #'eww-submit
|
|
|
|
"C-a" #'eww-beginning-of-text
|
|
|
|
"C-c C-c" #'eww-submit
|
|
|
|
"C-e" #'eww-end-of-text
|
|
|
|
"TAB" #'shr-next-link
|
|
|
|
"M-TAB" #'shr-previous-link
|
|
|
|
"<backtab>" #'shr-previous-link)
|
2021-10-04 10:15:04 +02:00
|
|
|
|
2021-10-05 10:34:37 +02:00
|
|
|
(defvar-keymap eww-textarea-map
|
|
|
|
:full t :parent text-mode-map
|
2021-11-16 08:18:30 +01:00
|
|
|
"RET" #'forward-line
|
|
|
|
"C-c C-c" #'eww-submit
|
|
|
|
"TAB" #'shr-next-link
|
|
|
|
"M-TAB" #'shr-previous-link
|
|
|
|
"<backtab>" #'shr-previous-link)
|
2021-10-04 10:15:04 +02:00
|
|
|
|
2021-10-05 10:34:37 +02:00
|
|
|
(defvar-keymap eww-select-map
|
|
|
|
:doc "Map for select buttons"
|
2021-11-16 08:18:30 +01:00
|
|
|
"RET" #'eww-change-select
|
|
|
|
"<follow-link>" 'mouse-face
|
|
|
|
"<mouse-2>" #'eww-change-select
|
|
|
|
"C-c C-c" #'eww-submit)
|
2013-06-19 22:28:04 +00:00
|
|
|
|
|
|
|
(defun eww-beginning-of-text ()
|
|
|
|
"Move to the start of the input field."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2013-06-19 22:28:04 +00:00
|
|
|
(goto-char (eww-beginning-of-field)))
|
|
|
|
|
|
|
|
(defun eww-end-of-text ()
|
|
|
|
"Move to the end of the text in the input field."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2013-06-19 22:28:04 +00:00
|
|
|
(goto-char (eww-end-of-field))
|
|
|
|
(let ((start (eww-beginning-of-field)))
|
|
|
|
(while (and (equal (following-char) ? )
|
|
|
|
(> (point) start))
|
|
|
|
(forward-char -1))
|
|
|
|
(when (> (point) start)
|
|
|
|
(forward-char 1))))
|
|
|
|
|
|
|
|
(defun eww-beginning-of-field ()
|
|
|
|
(cond
|
|
|
|
((bobp)
|
|
|
|
(point))
|
|
|
|
((not (eq (get-text-property (point) 'eww-form)
|
|
|
|
(get-text-property (1- (point)) 'eww-form)))
|
|
|
|
(point))
|
|
|
|
(t
|
|
|
|
(previous-single-property-change
|
|
|
|
(point) 'eww-form nil (point-min)))))
|
|
|
|
|
|
|
|
(defun eww-end-of-field ()
|
|
|
|
(1- (next-single-property-change
|
|
|
|
(point) 'eww-form nil (point-max))))
|
|
|
|
|
2014-11-26 19:41:13 +01:00
|
|
|
(defun eww-tag-form (dom)
|
|
|
|
(let ((eww-form (list (cons :method (dom-attr dom 'method))
|
|
|
|
(cons :action (dom-attr dom 'action))))
|
2013-06-10 14:11:01 +00:00
|
|
|
(start (point)))
|
2016-02-02 18:00:02 +11:00
|
|
|
(insert "\n")
|
2013-06-10 14:11:01 +00:00
|
|
|
(shr-ensure-paragraph)
|
2014-11-26 19:41:13 +01:00
|
|
|
(shr-generic dom)
|
2013-06-14 03:22:26 +00:00
|
|
|
(unless (bolp)
|
|
|
|
(insert "\n"))
|
|
|
|
(insert "\n")
|
2013-06-10 22:28:35 +00:00
|
|
|
(when (> (point) start)
|
|
|
|
(put-text-property start (1+ start)
|
|
|
|
'eww-form eww-form))))
|
2013-06-10 14:11:01 +00:00
|
|
|
|
2014-11-26 19:41:13 +01:00
|
|
|
(defun eww-form-submit (dom)
|
2013-06-19 22:28:04 +00:00
|
|
|
(let ((start (point))
|
2014-11-26 19:41:13 +01:00
|
|
|
(value (dom-attr dom 'value)))
|
2020-02-20 14:44:16 +01:00
|
|
|
(if (null value)
|
|
|
|
(shr-generic dom)
|
|
|
|
(insert value))
|
|
|
|
;; If the contents of the <button>...</button> turns out to be
|
|
|
|
;; empty, or the value was blank, default to this:
|
|
|
|
(when (= (point) start)
|
|
|
|
(insert "Submit"))
|
2013-06-19 22:28:04 +00:00
|
|
|
(add-face-text-property start (point) 'eww-form-submit)
|
|
|
|
(put-text-property start (point) 'eww-form
|
|
|
|
(list :eww-form eww-form
|
|
|
|
:value value
|
|
|
|
:type "submit"
|
2014-11-26 19:41:13 +01:00
|
|
|
:name (dom-attr dom 'name)))
|
2013-06-19 22:28:04 +00:00
|
|
|
(put-text-property start (point) 'keymap eww-submit-map)
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
;; Pretend to touch-screen.el that this is a button.
|
|
|
|
(put-text-property start (point) 'button t)
|
2013-06-19 22:28:04 +00:00
|
|
|
(insert " ")))
|
|
|
|
|
2014-11-26 19:41:13 +01:00
|
|
|
(defun eww-form-checkbox (dom)
|
2013-06-19 22:28:04 +00:00
|
|
|
(let ((start (point)))
|
2014-11-26 19:41:13 +01:00
|
|
|
(if (dom-attr dom 'checked)
|
2013-12-01 16:52:04 +01:00
|
|
|
(insert eww-form-checkbox-selected-symbol)
|
|
|
|
(insert eww-form-checkbox-symbol))
|
2013-06-19 22:28:04 +00:00
|
|
|
(add-face-text-property start (point) 'eww-form-checkbox)
|
|
|
|
(put-text-property start (point) 'eww-form
|
|
|
|
(list :eww-form eww-form
|
2014-11-26 19:41:13 +01:00
|
|
|
:value (dom-attr dom 'value)
|
|
|
|
:type (downcase (dom-attr dom 'type))
|
|
|
|
:checked (dom-attr dom 'checked)
|
|
|
|
:name (dom-attr dom 'name)))
|
2013-06-19 22:28:04 +00:00
|
|
|
(put-text-property start (point) 'keymap eww-checkbox-map)
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
;; Pretend to touch-screen.el that this is a button.
|
|
|
|
(put-text-property start (point) 'button t)
|
2013-06-19 22:28:04 +00:00
|
|
|
(insert " ")))
|
|
|
|
|
2014-11-26 19:41:13 +01:00
|
|
|
(defun eww-form-file (dom)
|
2014-11-10 22:33:55 +01:00
|
|
|
(let ((start (point))
|
2014-11-26 19:41:13 +01:00
|
|
|
(value (dom-attr dom 'value)))
|
2014-11-10 22:33:55 +01:00
|
|
|
(setq value
|
|
|
|
(if (zerop (length value))
|
|
|
|
" No file selected"
|
|
|
|
value))
|
|
|
|
(insert "Browse")
|
|
|
|
(add-face-text-property start (point) 'eww-form-file)
|
|
|
|
(insert value)
|
|
|
|
(put-text-property start (point) 'eww-form
|
|
|
|
(list :eww-form eww-form
|
2014-11-26 19:41:13 +01:00
|
|
|
:value (dom-attr dom 'value)
|
|
|
|
:type (downcase (dom-attr dom 'type))
|
|
|
|
:name (dom-attr dom 'name)))
|
2014-11-10 22:33:55 +01:00
|
|
|
(put-text-property start (point) 'keymap eww-submit-file)
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
;; Pretend to touch-screen.el that this is a button.
|
|
|
|
(put-text-property start (point) 'button t)
|
2014-11-10 22:33:55 +01:00
|
|
|
(insert " ")))
|
|
|
|
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
(defun eww-select-file (&optional event)
|
|
|
|
"Change the value of the upload file menu under point.
|
2024-04-29 15:32:12 +03:00
|
|
|
EVENT, if non-nil, is the mouse event that preceded this command.
|
|
|
|
Interactively, EVENT is the value of `last-nonmenu-event'."
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
(interactive (list last-nonmenu-event) eww-mode)
|
|
|
|
(when (and event (setq event (event-start event)))
|
|
|
|
(goto-char (posn-point event)))
|
2014-11-10 22:33:55 +01:00
|
|
|
(let* ((input (get-text-property (point) 'eww-form)))
|
|
|
|
(let ((filename
|
|
|
|
(let ((insert-default-directory t))
|
|
|
|
(read-file-name "filename: "))))
|
|
|
|
(eww-update-field filename (length "Browse"))
|
|
|
|
(plist-put input :filename filename))))
|
|
|
|
|
2014-11-26 19:41:13 +01:00
|
|
|
(defun eww-form-text (dom)
|
2013-06-19 22:28:04 +00:00
|
|
|
(let ((start (point))
|
2014-11-26 19:41:13 +01:00
|
|
|
(type (downcase (or (dom-attr dom 'type) "text")))
|
|
|
|
(value (or (dom-attr dom 'value) ""))
|
|
|
|
(width (string-to-number (or (dom-attr dom 'size) "40")))
|
|
|
|
(readonly-property (if (or (dom-attr dom 'disabled)
|
|
|
|
(dom-attr dom 'readonly))
|
2013-12-21 15:42:23 -05:00
|
|
|
'read-only
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
'inhibit-read-only))
|
|
|
|
form)
|
|
|
|
(setq form (list :eww-form eww-form
|
|
|
|
:value value
|
|
|
|
:type type
|
|
|
|
:name (dom-attr dom 'name)))
|
2013-06-19 22:28:04 +00:00
|
|
|
(insert value)
|
|
|
|
(when (< (length value) width)
|
|
|
|
(insert (make-string (- width (length value)) ? )))
|
|
|
|
(put-text-property start (point) 'face 'eww-form-text)
|
2014-11-16 23:39:53 +01:00
|
|
|
(put-text-property start (point) 'inhibit-read-only t)
|
2013-06-19 22:28:04 +00:00
|
|
|
(put-text-property start (point) 'local-map eww-text-map)
|
2013-12-21 15:42:23 -05:00
|
|
|
(put-text-property start (point) readonly-property t)
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
(put-text-property start (point) 'eww-form form)
|
|
|
|
(put-text-property start (point) 'field form)
|
2024-04-30 13:21:59 +08:00
|
|
|
(put-text-property start (point) 'front-sticky t)
|
2013-06-19 22:28:04 +00:00
|
|
|
(insert " ")))
|
|
|
|
|
2013-12-01 16:38:43 +01:00
|
|
|
(defconst eww-text-input-types '("text" "password" "textarea"
|
|
|
|
"color" "date" "datetime" "datetime-local"
|
|
|
|
"email" "month" "number" "search" "tel"
|
|
|
|
"time" "url" "week")
|
|
|
|
"List of input types which represent a text input.
|
|
|
|
See URL `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input'.")
|
|
|
|
|
2014-11-27 20:26:24 +01:00
|
|
|
(defun eww-process-text-input (beg end replace-length)
|
2024-04-30 13:21:59 +08:00
|
|
|
(when-let* ((pos (field-beginning (point))))
|
2014-11-27 17:50:05 +01:00
|
|
|
(let* ((form (get-text-property pos 'eww-form))
|
|
|
|
(properties (text-properties-at pos))
|
2016-02-02 18:00:02 +11:00
|
|
|
(buffer-undo-list t)
|
2014-11-27 17:50:05 +01:00
|
|
|
(inhibit-read-only t)
|
2014-11-27 20:26:24 +01:00
|
|
|
(length (- end beg replace-length))
|
2014-11-27 17:50:05 +01:00
|
|
|
(type (plist-get form :type)))
|
|
|
|
(when (and form
|
|
|
|
(member type eww-text-input-types))
|
|
|
|
(cond
|
2014-11-27 20:26:24 +01:00
|
|
|
((> length 0)
|
2014-11-27 17:50:05 +01:00
|
|
|
;; Delete some space at the end.
|
|
|
|
(save-excursion
|
|
|
|
(goto-char
|
|
|
|
(if (equal type "textarea")
|
|
|
|
(1- (line-end-position))
|
|
|
|
(eww-end-of-field)))
|
2014-11-27 20:26:24 +01:00
|
|
|
(while (and (> length 0)
|
2024-04-30 13:21:59 +08:00
|
|
|
(eq (char-after (1- (point))) ? ))
|
2014-11-27 20:26:24 +01:00
|
|
|
(delete-region (1- (point)) (point))
|
|
|
|
(cl-decf length))))
|
|
|
|
((< length 0)
|
2014-11-27 17:50:05 +01:00
|
|
|
;; Add padding.
|
|
|
|
(save-excursion
|
2016-02-02 18:00:02 +11:00
|
|
|
(goto-char end)
|
2014-11-27 17:50:05 +01:00
|
|
|
(goto-char
|
|
|
|
(if (equal type "textarea")
|
|
|
|
(1- (line-end-position))
|
|
|
|
(1+ (eww-end-of-field))))
|
|
|
|
(let ((start (point)))
|
2016-02-02 18:00:02 +11:00
|
|
|
(insert (make-string (abs length) ? ))
|
2014-11-27 20:26:24 +01:00
|
|
|
(set-text-properties start (point) properties))
|
|
|
|
(goto-char (1- end)))))
|
2017-02-18 16:46:06 +01:00
|
|
|
(set-text-properties (cdr (assq :start form))
|
|
|
|
(cdr (assq :end form))
|
2014-11-27 20:26:24 +01:00
|
|
|
properties)
|
2014-11-27 17:50:05 +01:00
|
|
|
(let ((value (buffer-substring-no-properties
|
|
|
|
(eww-beginning-of-field)
|
|
|
|
(eww-end-of-field))))
|
|
|
|
(when (string-match " +\\'" value)
|
|
|
|
(setq value (substring value 0 (match-beginning 0))))
|
|
|
|
(plist-put form :value value)
|
2024-04-30 13:21:59 +08:00
|
|
|
(plist-put form :type type)
|
2014-11-27 17:50:05 +01:00
|
|
|
(when (equal type "password")
|
|
|
|
;; Display passwords as asterisks.
|
|
|
|
(let ((start (eww-beginning-of-field)))
|
2016-02-02 18:00:02 +11:00
|
|
|
(put-text-property
|
|
|
|
start (+ start (length value))
|
|
|
|
'display (make-string (length value) ?*)))))))))
|
2013-06-12 01:38:23 +00:00
|
|
|
|
2014-11-26 19:41:13 +01:00
|
|
|
(defun eww-tag-textarea (dom)
|
2013-06-19 22:28:04 +00:00
|
|
|
(let ((start (point))
|
2020-07-17 16:43:57 +02:00
|
|
|
(value (or (dom-text dom) ""))
|
2014-11-26 19:41:13 +01:00
|
|
|
(lines (string-to-number (or (dom-attr dom 'rows) "10")))
|
|
|
|
(width (string-to-number (or (dom-attr dom 'cols) "10")))
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
end form)
|
2013-06-19 22:28:04 +00:00
|
|
|
(shr-ensure-newline)
|
|
|
|
(insert value)
|
|
|
|
(shr-ensure-newline)
|
|
|
|
(when (< (count-lines start (point)) lines)
|
2015-01-12 13:07:52 -05:00
|
|
|
(dotimes (_ (- lines (count-lines start (point))))
|
2013-06-19 22:28:04 +00:00
|
|
|
(insert "\n")))
|
|
|
|
(setq end (point-marker))
|
|
|
|
(goto-char start)
|
|
|
|
(while (< (point) end)
|
|
|
|
(end-of-line)
|
|
|
|
(let ((pad (- width (- (point) (line-beginning-position)))))
|
|
|
|
(when (> pad 0)
|
|
|
|
(insert (make-string pad ? ))))
|
|
|
|
(add-face-text-property (line-beginning-position)
|
2013-12-25 16:33:16 +01:00
|
|
|
(point) 'eww-form-textarea)
|
2014-11-16 23:39:53 +01:00
|
|
|
(put-text-property (line-beginning-position) (point) 'inhibit-read-only t)
|
2013-06-19 22:28:04 +00:00
|
|
|
(put-text-property (line-beginning-position) (point)
|
|
|
|
'local-map eww-textarea-map)
|
|
|
|
(forward-line 1))
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
(setq form (list :eww-form eww-form
|
|
|
|
:value value
|
|
|
|
:type "textarea"
|
|
|
|
:name (dom-attr dom 'name)))
|
|
|
|
(put-text-property start (point) 'eww-form form)
|
2024-04-30 13:21:59 +08:00
|
|
|
(put-text-property start (point) 'front-sticky t)
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
(put-text-property start (point) 'field form)
|
2022-11-02 22:28:45 +01:00
|
|
|
(put-text-property start (1+ start) 'shr-tab-stop t)))
|
2013-06-19 22:28:04 +00:00
|
|
|
|
2014-11-26 19:41:13 +01:00
|
|
|
(defun eww-tag-input (dom)
|
|
|
|
(let ((type (downcase (or (dom-attr dom 'type) "text")))
|
2013-06-19 22:28:04 +00:00
|
|
|
(start (point)))
|
|
|
|
(cond
|
|
|
|
((or (equal type "checkbox")
|
|
|
|
(equal type "radio"))
|
2014-11-26 19:41:13 +01:00
|
|
|
(eww-form-checkbox dom))
|
2014-11-10 22:33:55 +01:00
|
|
|
((equal type "file")
|
2014-11-26 19:41:13 +01:00
|
|
|
(eww-form-file dom))
|
2013-06-19 22:28:04 +00:00
|
|
|
((equal type "submit")
|
2014-11-26 19:41:13 +01:00
|
|
|
(eww-form-submit dom))
|
2013-06-19 22:28:04 +00:00
|
|
|
((equal type "hidden")
|
|
|
|
(let ((form eww-form)
|
2014-11-26 19:41:13 +01:00
|
|
|
(name (dom-attr dom 'name)))
|
2013-06-19 22:28:04 +00:00
|
|
|
;; Don't add <input type=hidden> elements repeatedly.
|
|
|
|
(while (and form
|
|
|
|
(or (not (consp (car form)))
|
|
|
|
(not (eq (caar form) 'hidden))
|
|
|
|
(not (equal (plist-get (cdr (car form)) :name)
|
|
|
|
name))))
|
|
|
|
(setq form (cdr form)))
|
|
|
|
(unless form
|
|
|
|
(nconc eww-form (list
|
|
|
|
(list 'hidden
|
|
|
|
:name name
|
2016-02-04 15:52:59 +11:00
|
|
|
:value (or (dom-attr dom 'value) "")))))))
|
2013-06-19 22:28:04 +00:00
|
|
|
(t
|
2014-11-26 19:41:13 +01:00
|
|
|
(eww-form-text dom)))
|
2013-06-19 22:28:04 +00:00
|
|
|
(unless (= start (point))
|
2016-02-04 15:42:08 +11:00
|
|
|
(put-text-property start (1+ start) 'help-echo "Input field")
|
|
|
|
;; Mark this as an element we can TAB to.
|
2022-09-26 15:16:16 +02:00
|
|
|
(put-text-property start (1+ start) 'shr-tab-stop t))))
|
2013-06-16 22:20:55 +00:00
|
|
|
|
2014-11-26 19:41:13 +01:00
|
|
|
(defun eww-tag-select (dom)
|
2013-06-12 01:38:23 +00:00
|
|
|
(shr-ensure-paragraph)
|
2014-11-26 19:41:13 +01:00
|
|
|
(let ((menu (list :name (dom-attr dom 'name)
|
2013-06-12 01:38:23 +00:00
|
|
|
:eww-form eww-form))
|
|
|
|
(options nil)
|
2013-06-19 22:28:04 +00:00
|
|
|
(start (point))
|
2018-04-13 02:23:49 +02:00
|
|
|
(max 0))
|
2020-09-05 15:42:26 +02:00
|
|
|
(dolist (elem (dom-by-tag dom 'option))
|
|
|
|
(when (dom-attr elem 'selected)
|
|
|
|
(nconc menu (list :value (dom-attr elem 'value))))
|
|
|
|
(let ((display (dom-text elem)))
|
|
|
|
(setq max (max max (length display)))
|
|
|
|
(push (list 'item
|
|
|
|
:value (dom-attr elem 'value)
|
|
|
|
:display display)
|
|
|
|
options)))
|
2013-06-17 22:06:27 +00:00
|
|
|
(when options
|
2013-06-19 22:28:04 +00:00
|
|
|
(setq options (nreverse options))
|
2013-06-17 22:06:27 +00:00
|
|
|
;; If we have no selected values, default to the first value.
|
2013-06-19 22:28:04 +00:00
|
|
|
(unless (plist-get menu :value)
|
2013-06-17 22:06:27 +00:00
|
|
|
(nconc menu (list :value (nth 2 (car options)))))
|
|
|
|
(nconc menu options)
|
2013-06-19 22:28:04 +00:00
|
|
|
(let ((selected (eww-select-display menu)))
|
|
|
|
(insert selected
|
|
|
|
(make-string (- max (length selected)) ? )))
|
|
|
|
(put-text-property start (point) 'eww-form menu)
|
|
|
|
(add-face-text-property start (point) 'eww-form-select)
|
|
|
|
(put-text-property start (point) 'keymap eww-select-map)
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
;; Pretend to touch-screen.el that this is a button.
|
|
|
|
(put-text-property start (point) 'button t)
|
2013-12-22 17:40:35 -05:00
|
|
|
(unless (= start (point))
|
2022-11-02 22:28:45 +01:00
|
|
|
(put-text-property start (1+ start) 'help-echo "select field")
|
|
|
|
(put-text-property start (1+ start) 'shr-tab-stop t))
|
2013-06-17 22:06:27 +00:00
|
|
|
(shr-ensure-paragraph))))
|
2013-06-10 14:11:01 +00:00
|
|
|
|
2013-06-19 22:28:04 +00:00
|
|
|
(defun eww-select-display (select)
|
|
|
|
(let ((value (plist-get select :value))
|
|
|
|
display)
|
|
|
|
(dolist (elem select)
|
|
|
|
(when (and (consp elem)
|
|
|
|
(eq (car elem) 'item)
|
|
|
|
(equal value (plist-get (cdr elem) :value)))
|
|
|
|
(setq display (plist-get (cdr elem) :display))))
|
|
|
|
display))
|
|
|
|
|
2020-09-06 19:04:00 +02:00
|
|
|
(defun eww--form-items (form)
|
|
|
|
(cl-loop for elem in form
|
|
|
|
when (and (consp elem)
|
|
|
|
(eq (car elem) 'item))
|
|
|
|
collect (cdr elem)))
|
|
|
|
|
|
|
|
(defun eww-change-select (event)
|
2013-06-19 22:28:04 +00:00
|
|
|
"Change the value of the select drop-down menu under point."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive
|
|
|
|
(list last-nonmenu-event)
|
|
|
|
eww-mode)
|
2020-09-06 19:04:00 +02:00
|
|
|
(mouse-set-point event)
|
|
|
|
(let ((input (get-text-property (point) 'eww-form)))
|
|
|
|
(popup-menu
|
|
|
|
(cons
|
|
|
|
"Change Value"
|
|
|
|
(mapcar
|
|
|
|
(lambda (elem)
|
|
|
|
(vector (plist-get elem :display)
|
|
|
|
(lambda ()
|
|
|
|
(interactive)
|
|
|
|
(plist-put input :value (plist-get elem :value))
|
|
|
|
(goto-char (eww-update-field (plist-get elem :display))))
|
|
|
|
t))
|
|
|
|
(eww--form-items input)))
|
|
|
|
event)))
|
2013-06-19 22:28:04 +00:00
|
|
|
|
2014-11-10 22:33:55 +01:00
|
|
|
(defun eww-update-field (string &optional offset)
|
2015-12-25 06:47:28 +01:00
|
|
|
(unless offset
|
|
|
|
(setq offset 0))
|
2013-06-19 22:28:04 +00:00
|
|
|
(let ((properties (text-properties-at (point)))
|
2014-11-10 22:33:55 +01:00
|
|
|
(start (+ (eww-beginning-of-field) offset))
|
|
|
|
(current-end (1+ (eww-end-of-field)))
|
2015-12-25 06:47:28 +01:00
|
|
|
(new-end (+ (eww-beginning-of-field) (length string)))
|
|
|
|
(inhibit-read-only t))
|
2014-11-10 22:33:55 +01:00
|
|
|
(delete-region start current-end)
|
|
|
|
(forward-char offset)
|
2013-06-19 22:28:04 +00:00
|
|
|
(insert string
|
2014-11-10 22:33:55 +01:00
|
|
|
(make-string (- (- (+ new-end offset) start) (length string)) ? ))
|
2015-12-25 06:47:28 +01:00
|
|
|
(when (= 0 offset)
|
|
|
|
(set-text-properties start new-end properties))
|
2013-06-19 22:28:04 +00:00
|
|
|
start))
|
|
|
|
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
(defun eww-toggle-checkbox (&optional event)
|
|
|
|
"Toggle the value of the checkbox under point.
|
2024-04-29 15:32:12 +03:00
|
|
|
EVENT, if non-nil, is the mouse event that preceded this command.
|
|
|
|
Interactively, EVENT is the value of `last-nonmenu-event'."
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
(interactive (list last-nonmenu-event) eww-mode)
|
|
|
|
(when (and event (setq event (event-start event)))
|
|
|
|
(goto-char (posn-point event)))
|
2013-06-19 22:28:04 +00:00
|
|
|
(let* ((input (get-text-property (point) 'eww-form))
|
|
|
|
(type (plist-get input :type)))
|
|
|
|
(if (equal type "checkbox")
|
|
|
|
(goto-char
|
|
|
|
(1+
|
|
|
|
(if (plist-get input :checked)
|
|
|
|
(progn
|
|
|
|
(plist-put input :checked nil)
|
2013-12-01 16:52:04 +01:00
|
|
|
(eww-update-field eww-form-checkbox-symbol))
|
2013-06-19 22:28:04 +00:00
|
|
|
(plist-put input :checked t)
|
2013-12-01 16:52:04 +01:00
|
|
|
(eww-update-field eww-form-checkbox-selected-symbol))))
|
2013-06-19 22:28:04 +00:00
|
|
|
;; Radio button. Switch all other buttons off.
|
|
|
|
(let ((name (plist-get input :name)))
|
|
|
|
(save-excursion
|
|
|
|
(dolist (elem (eww-inputs (plist-get input :eww-form)))
|
|
|
|
(when (equal (plist-get (cdr elem) :name) name)
|
|
|
|
(goto-char (car elem))
|
|
|
|
(if (not (eq (cdr elem) input))
|
|
|
|
(progn
|
2021-03-04 12:11:08 +01:00
|
|
|
(plist-put (cdr elem) :checked nil)
|
2013-12-01 16:52:04 +01:00
|
|
|
(eww-update-field eww-form-checkbox-symbol))
|
2021-03-04 12:11:08 +01:00
|
|
|
(plist-put (cdr elem) :checked t)
|
2013-12-01 16:52:04 +01:00
|
|
|
(eww-update-field eww-form-checkbox-selected-symbol)))))
|
2013-06-19 22:28:04 +00:00
|
|
|
(forward-char 1)))))
|
|
|
|
|
|
|
|
(defun eww-inputs (form)
|
|
|
|
(let ((start (point-min))
|
|
|
|
(inputs nil))
|
|
|
|
(while (and start
|
|
|
|
(< start (point-max)))
|
|
|
|
(when (or (get-text-property start 'eww-form)
|
|
|
|
(setq start (next-single-property-change start 'eww-form)))
|
|
|
|
(when (eq (plist-get (get-text-property start 'eww-form) :eww-form)
|
|
|
|
form)
|
|
|
|
(push (cons start (get-text-property start 'eww-form))
|
|
|
|
inputs))
|
|
|
|
(setq start (next-single-property-change start 'eww-form))))
|
|
|
|
(nreverse inputs)))
|
|
|
|
|
2014-11-27 20:26:24 +01:00
|
|
|
(defun eww-size-text-inputs ()
|
|
|
|
(let ((start (point-min)))
|
|
|
|
(while (and start
|
|
|
|
(< start (point-max)))
|
|
|
|
(when (or (get-text-property start 'eww-form)
|
|
|
|
(setq start (next-single-property-change start 'eww-form)))
|
|
|
|
(let ((props (get-text-property start 'eww-form)))
|
2017-02-18 16:46:06 +01:00
|
|
|
(nconc props (list (cons :start start)))
|
|
|
|
(setq start (next-single-property-change
|
|
|
|
start 'eww-form nil (point-max)))
|
|
|
|
(nconc props (list (cons :end start))))))))
|
2014-11-27 20:26:24 +01:00
|
|
|
|
2013-06-19 22:28:04 +00:00
|
|
|
(defun eww-input-value (input)
|
|
|
|
(let ((type (plist-get input :type))
|
|
|
|
(value (plist-get input :value)))
|
|
|
|
(cond
|
|
|
|
((equal type "textarea")
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert value)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (re-search-forward "^ +\n\\| +$" nil t)
|
|
|
|
(replace-match "" t t))
|
|
|
|
(buffer-string)))
|
|
|
|
(t
|
|
|
|
(if (string-match " +\\'" value)
|
|
|
|
(substring value 0 (match-beginning 0))
|
|
|
|
value)))))
|
|
|
|
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
(defun eww-submit (&optional event)
|
|
|
|
"Submit the form under point or EVENT.
|
2024-04-29 15:32:12 +03:00
|
|
|
EVENT, if non-nil, is the mouse event that preceded this command.
|
|
|
|
Interactively, EVENT is the value of `last-nonmenu-event'."
|
Adapt eww to touch screens, mice and text conversion
* doc/emacs/input.texi (On-Screen Keyboards): Update conditions
for displaying the virtual keyboard when t-s-d-k is enabled.
* etc/NEWS (Announce): Document changes.
* lisp/net/eww.el (eww-check-text-conversion): New function.
(eww-mode): Install it as a local post-command-hook.
(eww-submit-map, eww-submit-file, eww-checkbox-map): Bind
suitable commands to mouse-2.
(eww-form-submit, eww-form-checkbox, eww-form-file)
(eww-tag-select): Disguise inserted forms as buttons, that touch
event translation may prefer their bindings to mouse-2 over
mouse-1.
(eww-form-text, eww-tag-textarea): Insert field properties as
well.
(eww-select-file, eww-toggle-checkbox, eww-submit): New argument
EVENT, to whose position point is set.
* lisp/touch-screen.el (touch-screen-handle-point-up): Trivial
adjustments to the criteria for selecting mouse commands and
displaying the on screen keyboard.
2024-04-29 20:01:59 +08:00
|
|
|
(interactive (list last-nonmenu-event) eww-mode)
|
|
|
|
(when (and event (setq event (event-start event)))
|
|
|
|
(goto-char (posn-point event)))
|
2013-06-19 22:28:04 +00:00
|
|
|
(let* ((this-input (get-text-property (point) 'eww-form))
|
|
|
|
(form (plist-get this-input :eww-form))
|
|
|
|
values next-submit)
|
|
|
|
(dolist (elem (sort (eww-inputs form)
|
2014-11-10 22:33:55 +01:00
|
|
|
(lambda (o1 o2)
|
|
|
|
(< (car o1) (car o2)))))
|
2013-06-19 22:28:04 +00:00
|
|
|
(let* ((input (cdr elem))
|
|
|
|
(input-start (car elem))
|
|
|
|
(name (plist-get input :name)))
|
|
|
|
(when name
|
|
|
|
(cond
|
|
|
|
((member (plist-get input :type) '("checkbox" "radio"))
|
|
|
|
(when (plist-get input :checked)
|
2020-09-21 13:57:31 +02:00
|
|
|
(push (cons name (or (plist-get input :value) "on"))
|
2013-06-19 22:28:04 +00:00
|
|
|
values)))
|
2014-11-10 22:33:55 +01:00
|
|
|
((equal (plist-get input :type) "file")
|
2019-09-14 16:55:24 +02:00
|
|
|
(when-let ((file (plist-get input :filename)))
|
|
|
|
(push (list "file"
|
|
|
|
(cons "filedata"
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert-file-contents file)
|
|
|
|
(buffer-string)))
|
|
|
|
(cons "name" name)
|
|
|
|
(cons "filename" file))
|
|
|
|
values)))
|
2013-06-19 22:28:04 +00:00
|
|
|
((equal (plist-get input :type) "submit")
|
|
|
|
;; We want the values from buttons if we hit a button if
|
|
|
|
;; we hit enter on it, or if it's the first button after
|
|
|
|
;; the field we did hit return on.
|
|
|
|
(when (or (eq input this-input)
|
|
|
|
(and (not (eq input this-input))
|
|
|
|
(null next-submit)
|
|
|
|
(> input-start (point))))
|
|
|
|
(setq next-submit t)
|
|
|
|
(push (cons name (plist-get input :value))
|
|
|
|
values)))
|
|
|
|
(t
|
|
|
|
(push (cons name (eww-input-value input))
|
|
|
|
values))))))
|
2013-06-10 22:12:47 +00:00
|
|
|
(dolist (elem form)
|
|
|
|
(when (and (consp elem)
|
|
|
|
(eq (car elem) 'hidden))
|
|
|
|
(push (cons (plist-get (cdr elem) :name)
|
2014-11-02 16:34:40 -05:00
|
|
|
(or (plist-get (cdr elem) :value) ""))
|
2013-06-10 22:12:47 +00:00
|
|
|
values)))
|
2013-06-16 22:20:55 +00:00
|
|
|
(if (and (stringp (cdr (assq :method form)))
|
|
|
|
(equal (downcase (cdr (assq :method form))) "post"))
|
2014-11-10 22:33:55 +01:00
|
|
|
(let ((mtype))
|
|
|
|
(dolist (x values mtype)
|
|
|
|
(if (equal (car x) "file")
|
|
|
|
(progn
|
|
|
|
(setq mtype "multipart/form-data"))))
|
|
|
|
(cond ((equal mtype "multipart/form-data")
|
|
|
|
(let ((boundary (mml-compute-boundary '())))
|
|
|
|
(let ((url-request-method "POST")
|
|
|
|
(url-request-extra-headers
|
|
|
|
(list (cons "Content-Type"
|
|
|
|
(concat "multipart/form-data; boundary="
|
|
|
|
boundary))))
|
|
|
|
(url-request-data
|
|
|
|
(mm-url-encode-multipart-form-data values boundary)))
|
|
|
|
(eww-browse-url (shr-expand-url
|
|
|
|
(cdr (assq :action form))
|
|
|
|
(plist-get eww-data :url))))))
|
|
|
|
(t
|
|
|
|
(let ((url-request-method "POST")
|
|
|
|
(url-request-extra-headers
|
|
|
|
'(("Content-Type" .
|
|
|
|
"application/x-www-form-urlencoded")))
|
|
|
|
(url-request-data
|
|
|
|
(mm-url-encode-www-form-urlencoded values)))
|
|
|
|
(eww-browse-url (shr-expand-url
|
|
|
|
(cdr (assq :action form))
|
|
|
|
(plist-get eww-data :url)))))))
|
2013-06-16 22:20:55 +00:00
|
|
|
(eww-browse-url
|
|
|
|
(concat
|
|
|
|
(if (cdr (assq :action form))
|
2014-11-26 19:41:13 +01:00
|
|
|
(shr-expand-url (cdr (assq :action form)) (plist-get eww-data :url))
|
2014-11-10 21:22:59 +01:00
|
|
|
(plist-get eww-data :url))
|
2013-06-16 22:20:55 +00:00
|
|
|
"?"
|
|
|
|
(mm-url-encode-www-form-urlencoded values))))))
|
2013-06-10 14:11:01 +00:00
|
|
|
|
2013-12-01 16:44:25 +01:00
|
|
|
(defun eww-browse-with-external-browser (&optional url)
|
2013-06-23 20:27:58 +02:00
|
|
|
"Browse the current URL with an external browser.
|
2024-12-08 07:58:41 +02:00
|
|
|
The browser to use is specified by the
|
2019-07-29 00:07:34 +02:00
|
|
|
`browse-url-secondary-browser-function' variable."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2019-07-29 00:07:34 +02:00
|
|
|
(funcall browse-url-secondary-browser-function
|
|
|
|
(or url (plist-get eww-data :url))))
|
2013-06-23 20:27:58 +02:00
|
|
|
|
2021-11-07 00:45:01 +01:00
|
|
|
(defun eww-remove-tracking (url)
|
|
|
|
"Remove the commong utm_ tracking cookies from URLs."
|
|
|
|
(replace-regexp-in-string ".utm_.*" "" url))
|
|
|
|
|
|
|
|
(defun eww--transform-url (url)
|
2022-05-15 11:15:06 +02:00
|
|
|
"Apply `eww-url-transformers'."
|
2021-11-07 00:45:01 +01:00
|
|
|
(when url
|
|
|
|
(dolist (func eww-url-transformers)
|
|
|
|
(setq url (funcall func url)))
|
|
|
|
url))
|
|
|
|
|
2013-12-01 15:12:44 +01:00
|
|
|
(defun eww-follow-link (&optional external mouse-event)
|
|
|
|
"Browse the URL under point.
|
2019-07-28 15:55:31 +02:00
|
|
|
If EXTERNAL is single prefix, browse the URL using
|
2019-07-29 00:07:34 +02:00
|
|
|
`browse-url-secondary-browser-function'.
|
2019-07-28 15:55:31 +02:00
|
|
|
|
2014-12-07 21:44:19 +01:00
|
|
|
If EXTERNAL is double prefix, browse in new buffer."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive
|
|
|
|
(list current-prefix-arg last-nonmenu-event)
|
|
|
|
eww-mode)
|
2013-12-01 15:12:44 +01:00
|
|
|
(mouse-set-point mouse-event)
|
2021-11-07 00:45:01 +01:00
|
|
|
(let* ((orig-url (get-text-property (point) 'shr-url))
|
2022-09-28 12:59:04 +02:00
|
|
|
(url (eww--transform-url orig-url))
|
|
|
|
target)
|
2013-12-01 15:12:44 +01:00
|
|
|
(cond
|
|
|
|
((not url)
|
|
|
|
(message "No link under point"))
|
2020-11-24 08:22:26 +01:00
|
|
|
((string-match-p eww-use-browse-url url)
|
2020-05-06 18:02:32 +01:00
|
|
|
;; This respects the user options `browse-url-handlers'
|
|
|
|
;; and `browse-url-mailto-function'.
|
|
|
|
(browse-url url))
|
2014-12-07 21:44:19 +01:00
|
|
|
((and (consp external) (<= (car external) 4))
|
2019-07-29 00:07:34 +02:00
|
|
|
(funcall browse-url-secondary-browser-function url)
|
2018-04-13 14:17:51 +02:00
|
|
|
(shr--blink-link))
|
2013-12-01 15:12:44 +01:00
|
|
|
;; This is a #target url in the same page as the current one.
|
2022-09-28 12:59:04 +02:00
|
|
|
((and (setq target (url-target (url-generic-parse-url url)))
|
2014-11-10 21:22:59 +01:00
|
|
|
(eww-same-page-p url (plist-get eww-data :url)))
|
2022-09-28 12:59:04 +02:00
|
|
|
(let ((point (point)))
|
2014-11-23 17:37:58 +01:00
|
|
|
(eww-save-history)
|
2024-02-17 20:49:15 -08:00
|
|
|
(eww--before-browse)
|
2019-05-12 16:35:49 -04:00
|
|
|
(plist-put eww-data :url url)
|
2022-09-28 12:59:04 +02:00
|
|
|
(goto-char (point-min))
|
|
|
|
(if-let ((match (text-property-search-forward 'shr-target-id target #'member)))
|
|
|
|
(goto-char (prop-match-beginning match))
|
|
|
|
(goto-char (if (equal target "top")
|
|
|
|
(point-min)
|
|
|
|
point)))))
|
2013-12-01 15:12:44 +01:00
|
|
|
(t
|
2021-11-07 00:45:01 +01:00
|
|
|
(eww-browse-url orig-url external)))))
|
2013-12-01 15:12:44 +01:00
|
|
|
|
|
|
|
(defun eww-same-page-p (url1 url2)
|
2015-03-04 12:34:48 +01:00
|
|
|
"Return non-nil if URL1 and URL2 represent the same page.
|
2013-12-01 15:12:44 +01:00
|
|
|
Differences in #targets are ignored."
|
|
|
|
(let ((obj1 (url-generic-parse-url url1))
|
|
|
|
(obj2 (url-generic-parse-url url2)))
|
|
|
|
(setf (url-target obj1) nil)
|
|
|
|
(setf (url-target obj2) nil)
|
|
|
|
(equal (url-recreate-url obj1) (url-recreate-url obj2))))
|
|
|
|
|
2013-06-25 21:25:14 +02:00
|
|
|
(defun eww-copy-page-url ()
|
2014-12-07 22:18:09 +01:00
|
|
|
"Copy the URL of the current page into the kill ring."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2014-11-10 21:22:59 +01:00
|
|
|
(message "%s" (plist-get eww-data :url))
|
|
|
|
(kill-new (plist-get eww-data :url)))
|
2013-06-25 21:25:14 +02:00
|
|
|
|
2013-06-25 21:50:05 +02:00
|
|
|
(defun eww-download ()
|
2019-02-02 12:35:02 -06:00
|
|
|
"Download URL to `eww-download-directory'.
|
2019-02-08 09:53:32 +02:00
|
|
|
Use link at point if there is one, else the current page's URL."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2020-07-29 07:13:56 +02:00
|
|
|
(let ((dir (if (stringp eww-download-directory)
|
|
|
|
eww-download-directory
|
|
|
|
(funcall eww-download-directory))))
|
|
|
|
(access-file dir "Download failed")
|
|
|
|
(let ((url (or (get-text-property (point) 'shr-url)
|
|
|
|
(eww-current-url))))
|
|
|
|
(if (not url)
|
|
|
|
(message "No URL under point")
|
|
|
|
(url-retrieve url #'eww-download-callback (list url dir))))))
|
|
|
|
|
|
|
|
(defun eww-download-callback (status url dir)
|
2013-06-25 21:50:05 +02:00
|
|
|
(unless (plist-get status :error)
|
|
|
|
(let* ((obj (url-generic-parse-url url))
|
2019-02-02 12:50:03 -06:00
|
|
|
(path (directory-file-name (car (url-path-and-query obj))))
|
2015-12-24 22:21:24 +01:00
|
|
|
(file (eww-make-unique-file-name
|
|
|
|
(eww-decode-url-file-name (file-name-nondirectory path))
|
2020-07-29 07:13:56 +02:00
|
|
|
dir)))
|
2014-11-10 21:55:55 +01:00
|
|
|
(goto-char (point-min))
|
|
|
|
(re-search-forward "\r?\n\r?\n")
|
2018-03-02 10:44:44 +02:00
|
|
|
(let ((coding-system-for-write 'no-conversion))
|
|
|
|
(write-region (point) (point-max) file))
|
2013-06-25 21:50:05 +02:00
|
|
|
(message "Saved %s" file))))
|
|
|
|
|
2015-12-24 22:21:24 +01:00
|
|
|
(defun eww-decode-url-file-name (string)
|
|
|
|
(let* ((binary (url-unhex-string string))
|
|
|
|
(decoded
|
|
|
|
(decode-coding-string
|
|
|
|
binary
|
|
|
|
;; Possibly set by `universal-coding-system-argument'.
|
|
|
|
(or coding-system-for-read
|
|
|
|
;; RFC 3986 says that %AB stuff is utf-8.
|
|
|
|
(if (equal (decode-coding-string binary 'utf-8)
|
|
|
|
'(unicode))
|
|
|
|
'utf-8
|
|
|
|
;; But perhaps not.
|
|
|
|
(car (detect-coding-string binary))))))
|
|
|
|
(encodes (find-coding-systems-string decoded)))
|
|
|
|
(if (or (equal encodes '(undecided))
|
2015-12-25 08:31:10 +01:00
|
|
|
(memq (coding-system-base (or file-name-coding-system
|
|
|
|
default-file-name-coding-system))
|
2015-12-24 22:21:24 +01:00
|
|
|
encodes))
|
|
|
|
decoded
|
|
|
|
;; If we can't encode the decoded file name (due to language
|
|
|
|
;; environment settings), then we return the original, hexified
|
|
|
|
;; string.
|
|
|
|
string)))
|
|
|
|
|
2013-06-25 21:50:05 +02:00
|
|
|
(defun eww-make-unique-file-name (file directory)
|
2016-02-04 16:05:05 +11:00
|
|
|
(cond
|
|
|
|
((zerop (length file))
|
|
|
|
(setq file "!"))
|
|
|
|
((string-match "\\`[.]" file)
|
|
|
|
(setq file (concat "!" file))))
|
|
|
|
(let ((count 1)
|
|
|
|
(stem file)
|
|
|
|
(suffix ""))
|
|
|
|
(when (string-match "\\`\\(.*\\)\\([.][^.]+\\)" file)
|
|
|
|
(setq stem (match-string 1 file)
|
2020-11-29 11:40:47 +01:00
|
|
|
suffix (match-string 2 file)))
|
2016-02-04 16:05:05 +11:00
|
|
|
(while (file-exists-p (expand-file-name file directory))
|
|
|
|
(setq file (format "%s(%d)%s" stem count suffix))
|
|
|
|
(setq count (1+ count)))
|
|
|
|
(expand-file-name file directory)))
|
2013-06-25 21:50:05 +02:00
|
|
|
|
2014-11-24 16:58:37 +01:00
|
|
|
(defun eww-set-character-encoding (charset)
|
2015-03-04 12:34:48 +01:00
|
|
|
"Set character encoding to CHARSET.
|
|
|
|
If CHARSET is nil then use UTF-8."
|
2021-10-21 15:53:35 +02:00
|
|
|
(interactive "zUse character set (default `utf-8'): " eww-mode)
|
2014-11-24 16:58:37 +01:00
|
|
|
(if (null charset)
|
2014-12-07 20:49:16 +01:00
|
|
|
(eww-reload nil 'utf-8)
|
|
|
|
(eww-reload nil charset)))
|
2014-11-23 16:30:40 +01:00
|
|
|
|
2016-02-04 18:00:37 +11:00
|
|
|
(defun eww-switch-to-buffer ()
|
|
|
|
"Prompt for an EWW buffer to display in the selected window."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2016-02-04 18:00:37 +11:00
|
|
|
(let ((completion-extra-properties
|
2024-01-09 19:57:50 +02:00
|
|
|
`(:annotation-function
|
|
|
|
,(lambda (buf)
|
|
|
|
(with-current-buffer buf
|
|
|
|
(format " %s" (eww-current-url))))))
|
2023-09-16 05:50:58 +05:30
|
|
|
(curbuf (current-buffer)))
|
2016-02-04 12:48:35 -05:00
|
|
|
(pop-to-buffer-same-window
|
2016-02-04 18:00:37 +11:00
|
|
|
(read-buffer "Switch to EWW buffer: "
|
|
|
|
(cl-loop for buf in (nreverse (buffer-list))
|
|
|
|
if (with-current-buffer buf (derived-mode-p 'eww-mode))
|
|
|
|
return buf)
|
|
|
|
t
|
|
|
|
(lambda (bufn)
|
2023-09-16 05:50:58 +05:30
|
|
|
(setq bufn (if (consp bufn) (cdr bufn) (get-buffer bufn)))
|
|
|
|
(and (with-current-buffer bufn
|
|
|
|
(derived-mode-p 'eww-mode))
|
|
|
|
(not (eq bufn curbuf))))))))
|
2016-02-04 18:00:37 +11:00
|
|
|
|
2015-02-10 16:29:05 +11:00
|
|
|
(defun eww-toggle-fonts ()
|
|
|
|
"Toggle whether to use monospaced or font-enabled layouts."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2016-02-19 16:55:54 +11:00
|
|
|
(setq shr-use-fonts (not shr-use-fonts))
|
|
|
|
(eww-reload)
|
|
|
|
(message "Proportional fonts are now %s"
|
|
|
|
(if shr-use-fonts "on" "off")))
|
2015-02-10 16:29:05 +11:00
|
|
|
|
2015-12-25 18:50:43 +01:00
|
|
|
(defun eww-toggle-colors ()
|
|
|
|
"Toggle whether to use HTML-specified colors or not."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2015-12-25 18:50:43 +01:00
|
|
|
(message "Colors are now %s"
|
|
|
|
(if (setq shr-use-colors (not shr-use-colors))
|
|
|
|
"on"
|
|
|
|
"off"))
|
|
|
|
(eww-reload))
|
|
|
|
|
2021-04-12 10:31:46 +02:00
|
|
|
(defun eww-toggle-images ()
|
|
|
|
"Toggle whether or not to display images."
|
|
|
|
(interactive nil eww-mode)
|
|
|
|
(setq shr-inhibit-images (not shr-inhibit-images))
|
|
|
|
(eww-reload)
|
|
|
|
(message "Images are now %s"
|
|
|
|
(if shr-inhibit-images "off" "on")))
|
|
|
|
|
2013-06-26 18:54:48 +02:00
|
|
|
;;; Bookmarks code
|
|
|
|
|
|
|
|
(defvar eww-bookmarks nil)
|
|
|
|
|
|
|
|
(defun eww-add-bookmark ()
|
2015-01-26 12:48:44 +11:00
|
|
|
"Bookmark the current page."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-mode)
|
2013-06-26 18:54:48 +02:00
|
|
|
(eww-read-bookmarks)
|
|
|
|
(dolist (bookmark eww-bookmarks)
|
2014-11-10 21:22:59 +01:00
|
|
|
(when (equal (plist-get eww-data :url) (plist-get bookmark :url))
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(user-error "Already bookmarked")))
|
2015-01-26 12:48:44 +11:00
|
|
|
(when (y-or-n-p "Bookmark this page?")
|
|
|
|
(let ((title (replace-regexp-in-string "[\n\t\r]" " "
|
|
|
|
(plist-get eww-data :title))))
|
|
|
|
(setq title (replace-regexp-in-string "\\` +\\| +\\'" "" title))
|
|
|
|
(push (list :url (plist-get eww-data :url)
|
|
|
|
:title title
|
|
|
|
:time (current-time-string))
|
|
|
|
eww-bookmarks))
|
|
|
|
(eww-write-bookmarks)
|
|
|
|
(message "Bookmarked %s (%s)" (plist-get eww-data :url)
|
|
|
|
(plist-get eww-data :title))))
|
2013-06-26 18:54:48 +02:00
|
|
|
|
|
|
|
(defun eww-write-bookmarks ()
|
2014-08-05 20:15:52 +02:00
|
|
|
(with-temp-file (expand-file-name "eww-bookmarks" eww-bookmarks-directory)
|
2020-04-18 02:46:04 +01:00
|
|
|
(insert ";; Auto-generated file; don't edit -*- mode: lisp-data -*-\n")
|
2022-03-29 14:34:38 +02:00
|
|
|
(let ((print-length nil)
|
|
|
|
(print-level nil))
|
|
|
|
(pp eww-bookmarks (current-buffer)))))
|
2013-06-26 18:54:48 +02:00
|
|
|
|
2020-07-17 03:23:15 +02:00
|
|
|
(defun eww-read-bookmarks (&optional error-out)
|
|
|
|
"Read bookmarks from `eww-bookmarks'.
|
|
|
|
If ERROR-OUT, signal user-error if there are no bookmarks."
|
2014-08-05 20:15:52 +02:00
|
|
|
(let ((file (expand-file-name "eww-bookmarks" eww-bookmarks-directory)))
|
2013-06-27 12:27:53 +08:00
|
|
|
(setq eww-bookmarks
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
(unless (zerop (or (file-attribute-size (file-attributes file)) 0))
|
2013-06-27 12:27:53 +08:00
|
|
|
(with-temp-buffer
|
|
|
|
(insert-file-contents file)
|
2020-07-17 03:23:15 +02:00
|
|
|
(read (current-buffer)))))
|
|
|
|
(when (and error-out (not eww-bookmarks))
|
|
|
|
(user-error "No bookmarks are defined"))))
|
2013-06-26 18:54:48 +02:00
|
|
|
|
2014-11-03 08:22:43 -05:00
|
|
|
;;;###autoload
|
2013-06-26 18:54:48 +02:00
|
|
|
(defun eww-list-bookmarks ()
|
|
|
|
"Display the bookmarks."
|
|
|
|
(interactive)
|
2020-07-17 03:23:15 +02:00
|
|
|
(eww-read-bookmarks t)
|
2016-02-04 16:10:49 +11:00
|
|
|
(pop-to-buffer "*eww bookmarks*")
|
|
|
|
(eww-bookmark-prepare))
|
2013-06-26 18:54:48 +02:00
|
|
|
|
|
|
|
(defun eww-bookmark-prepare ()
|
|
|
|
(set-buffer (get-buffer-create "*eww bookmarks*"))
|
|
|
|
(eww-bookmark-mode)
|
2014-12-07 20:32:07 +01:00
|
|
|
(let* ((width (/ (window-width) 2))
|
|
|
|
(format (format "%%-%ds %%s" width))
|
|
|
|
(inhibit-read-only t)
|
|
|
|
start title)
|
2013-06-26 18:54:48 +02:00
|
|
|
(erase-buffer)
|
2014-12-07 20:32:07 +01:00
|
|
|
(setq header-line-format (concat " " (format format "Title" "URL")))
|
2013-06-26 18:54:48 +02:00
|
|
|
(dolist (bookmark eww-bookmarks)
|
2014-12-07 20:32:07 +01:00
|
|
|
(setq start (point)
|
|
|
|
title (plist-get bookmark :title))
|
|
|
|
(when (> (length title) width)
|
2015-10-10 22:43:44 -04:00
|
|
|
(setq title (truncate-string-to-width title width)))
|
2014-12-07 20:32:07 +01:00
|
|
|
(insert (format format title (plist-get bookmark :url)) "\n")
|
2013-06-26 18:54:48 +02:00
|
|
|
(put-text-property start (1+ start) 'eww-bookmark bookmark))
|
|
|
|
(goto-char (point-min))))
|
|
|
|
|
|
|
|
(defvar eww-bookmark-kill-ring nil)
|
|
|
|
|
|
|
|
(defun eww-bookmark-kill ()
|
|
|
|
"Kill the current bookmark."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-bookmark-mode)
|
2013-06-26 18:54:48 +02:00
|
|
|
(let* ((start (line-beginning-position))
|
|
|
|
(bookmark (get-text-property start 'eww-bookmark))
|
|
|
|
(inhibit-read-only t))
|
|
|
|
(unless bookmark
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(user-error "No bookmark on the current line"))
|
2013-06-26 18:54:48 +02:00
|
|
|
(forward-line 1)
|
|
|
|
(push (buffer-substring start (point)) eww-bookmark-kill-ring)
|
|
|
|
(delete-region start (point))
|
|
|
|
(setq eww-bookmarks (delq bookmark eww-bookmarks))
|
|
|
|
(eww-write-bookmarks)))
|
|
|
|
|
|
|
|
(defun eww-bookmark-yank ()
|
|
|
|
"Yank a previously killed bookmark to the current line."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-bookmark-mode)
|
2013-06-26 18:54:48 +02:00
|
|
|
(unless eww-bookmark-kill-ring
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(user-error "No previously killed bookmark"))
|
2013-06-26 18:54:48 +02:00
|
|
|
(beginning-of-line)
|
|
|
|
(let ((inhibit-read-only t)
|
|
|
|
(start (point))
|
|
|
|
bookmark)
|
|
|
|
(insert (pop eww-bookmark-kill-ring))
|
|
|
|
(setq bookmark (get-text-property start 'eww-bookmark))
|
|
|
|
(if (= start (point-min))
|
|
|
|
(push bookmark eww-bookmarks)
|
|
|
|
(let ((line (count-lines start (point))))
|
|
|
|
(setcdr (nthcdr (1- line) eww-bookmarks)
|
|
|
|
(cons bookmark (nthcdr line eww-bookmarks)))))
|
|
|
|
(eww-write-bookmarks)))
|
|
|
|
|
|
|
|
(defun eww-bookmark-browse ()
|
|
|
|
"Browse the bookmark under point in eww."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-bookmark-mode)
|
2013-06-26 18:54:48 +02:00
|
|
|
(let ((bookmark (get-text-property (line-beginning-position) 'eww-bookmark)))
|
|
|
|
(unless bookmark
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(user-error "No bookmark on the current line"))
|
2013-12-24 08:25:27 +01:00
|
|
|
(quit-window)
|
2013-11-26 15:05:48 -05:00
|
|
|
(eww-browse-url (plist-get bookmark :url))))
|
2013-06-26 18:54:48 +02:00
|
|
|
|
|
|
|
(defun eww-next-bookmark ()
|
|
|
|
"Go to the next bookmark in the list."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-bookmark-mode)
|
2013-06-26 18:54:48 +02:00
|
|
|
(let ((first nil)
|
|
|
|
bookmark)
|
|
|
|
(unless (get-buffer "*eww bookmarks*")
|
|
|
|
(setq first t)
|
2020-07-17 03:23:15 +02:00
|
|
|
(eww-read-bookmarks t)
|
2013-06-26 18:54:48 +02:00
|
|
|
(eww-bookmark-prepare))
|
2024-03-12 00:21:06 +00:00
|
|
|
(with-current-buffer "*eww bookmarks*"
|
2013-06-26 18:54:48 +02:00
|
|
|
(when (and (not first)
|
|
|
|
(not (eobp)))
|
|
|
|
(forward-line 1))
|
|
|
|
(setq bookmark (get-text-property (line-beginning-position)
|
|
|
|
'eww-bookmark))
|
|
|
|
(unless bookmark
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(user-error "No next bookmark")))
|
2013-06-26 18:54:48 +02:00
|
|
|
(eww-browse-url (plist-get bookmark :url))))
|
|
|
|
|
|
|
|
(defun eww-previous-bookmark ()
|
|
|
|
"Go to the previous bookmark in the list."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-bookmark-mode)
|
2013-06-26 18:54:48 +02:00
|
|
|
(let ((first nil)
|
|
|
|
bookmark)
|
|
|
|
(unless (get-buffer "*eww bookmarks*")
|
|
|
|
(setq first t)
|
2020-07-17 03:23:15 +02:00
|
|
|
(eww-read-bookmarks t)
|
2013-06-26 18:54:48 +02:00
|
|
|
(eww-bookmark-prepare))
|
2024-03-12 00:21:06 +00:00
|
|
|
(with-current-buffer "*eww bookmarks*"
|
2013-06-26 18:54:48 +02:00
|
|
|
(if first
|
|
|
|
(goto-char (point-max))
|
|
|
|
(beginning-of-line))
|
|
|
|
;; On the final line.
|
|
|
|
(when (eolp)
|
|
|
|
(forward-line -1))
|
|
|
|
(if (bobp)
|
eww: minor code fixes and toolbar support
* net/eww.el (eww-back-url, eww-forward-url, eww-next-url)
(eww-previous-url, eww-up-url, eww-top-url, eww-add-bookmark)
(eww-bookmark-prepare, eww-bookmark-kill, eww-bookmark-yank)
(eww-bookmark-browse, eww-next-bookmark, eww-previous-bookmark):
Use `user-error'.
(eww-bookmark-mode-map): Add menu.
(eww-render, eww-mode): Use `setq-local'.
(eww-tool-bar-map): New variable.
(eww-mode): Set `tool-bar-map'.
(eww-view-source): Check for `html-mode' with `fboundp'.
2013-12-21 15:13:09 -05:00
|
|
|
(user-error "No previous bookmark")
|
2013-06-26 18:54:48 +02:00
|
|
|
(forward-line -1))
|
|
|
|
(setq bookmark (get-text-property (line-beginning-position)
|
|
|
|
'eww-bookmark)))
|
|
|
|
(eww-browse-url (plist-get bookmark :url))))
|
|
|
|
|
2023-04-13 15:59:54 +00:00
|
|
|
(defun eww-bookmark-urls ()
|
|
|
|
"Get the URLs from the current list of bookmarks."
|
|
|
|
(interactive nil eww-boomark-mode)
|
|
|
|
(eww-read-bookmarks)
|
|
|
|
(mapcar (lambda (x) (plist-get x :url)) eww-bookmarks))
|
|
|
|
|
2021-10-05 10:34:37 +02:00
|
|
|
(defvar-keymap eww-bookmark-mode-map
|
2021-11-16 08:18:30 +01:00
|
|
|
"C-k" #'eww-bookmark-kill
|
|
|
|
"C-y" #'eww-bookmark-yank
|
|
|
|
"RET" #'eww-bookmark-browse
|
2021-10-04 10:15:04 +02:00
|
|
|
:menu '("Eww Bookmark"
|
|
|
|
["Exit" quit-window t]
|
|
|
|
["Browse" eww-bookmark-browse
|
|
|
|
:active (get-text-property (line-beginning-position) 'eww-bookmark)]
|
|
|
|
["Kill" eww-bookmark-kill
|
|
|
|
:active (get-text-property (line-beginning-position) 'eww-bookmark)]
|
|
|
|
["Yank" eww-bookmark-yank
|
|
|
|
:active eww-bookmark-kill-ring]))
|
2013-06-26 18:54:48 +02:00
|
|
|
|
2015-09-30 14:24:38 -04:00
|
|
|
(define-derived-mode eww-bookmark-mode special-mode "eww bookmarks"
|
2013-06-26 18:54:48 +02:00
|
|
|
"Mode for listing bookmarks.
|
|
|
|
|
|
|
|
\\{eww-bookmark-mode-map}"
|
2021-02-14 14:08:56 +01:00
|
|
|
:interactive nil
|
2013-06-26 18:54:48 +02:00
|
|
|
(buffer-disable-undo)
|
2015-09-30 14:24:38 -04:00
|
|
|
(setq truncate-lines t))
|
2013-06-26 18:54:48 +02:00
|
|
|
|
2013-12-21 15:33:44 -05:00
|
|
|
;;; History code
|
|
|
|
|
|
|
|
(defun eww-save-history ()
|
2024-02-17 20:49:15 -08:00
|
|
|
"Save the current page's data to the history.
|
2024-06-04 22:13:47 -07:00
|
|
|
If the current page is a historical one loaded from
|
2024-02-17 20:49:15 -08:00
|
|
|
`eww-history' (e.g. by calling `eww-back-url'), this will update the
|
|
|
|
page's entry in `eww-history' and return nil. Otherwise, add a new
|
|
|
|
entry to `eww-history' and return t."
|
2014-11-10 21:22:59 +01:00
|
|
|
(plist-put eww-data :point (point))
|
|
|
|
(plist-put eww-data :text (buffer-string))
|
2024-02-17 20:49:15 -08:00
|
|
|
(if (zerop eww-history-position)
|
|
|
|
(let ((history-delete-duplicates nil))
|
|
|
|
(add-to-history 'eww-history eww-data eww-history-limit t)
|
|
|
|
(setq eww-history-position 1)
|
|
|
|
t)
|
|
|
|
(setf (elt eww-history (1- eww-history-position)) eww-data)
|
|
|
|
nil))
|
|
|
|
|
|
|
|
(defun eww-delete-future-history ()
|
|
|
|
"Remove any entries in `eww-history' after the currently-shown one.
|
|
|
|
This is useful for `eww-before-browse-history-function' to make EWW's
|
|
|
|
navigation to a new page from a historical one work like other web
|
|
|
|
browsers: it will delete any \"future\" history elements before adding
|
|
|
|
the new page to the end of the history.
|
|
|
|
|
|
|
|
For example, if `eww-history' looks like this (going from newest to
|
|
|
|
oldest, with \"*\" marking the current page):
|
|
|
|
|
|
|
|
E D C* B A
|
|
|
|
|
|
|
|
then calling this function updates `eww-history' to:
|
|
|
|
|
|
|
|
C* B A"
|
|
|
|
(when (> eww-history-position 1)
|
|
|
|
(setq eww-history (nthcdr (1- eww-history-position) eww-history)
|
|
|
|
;; We don't really need to set this since `eww--before-browse'
|
|
|
|
;; sets it too, but this ensures that other callers can use
|
|
|
|
;; this function and get the expected results.
|
|
|
|
eww-history-position 1)))
|
|
|
|
|
|
|
|
(defun eww-clone-previous-history ()
|
|
|
|
"Clone and prepend entries in `eww-history' up to the currently-shown one.
|
|
|
|
These cloned entries get added to the beginning of `eww-history' so that
|
|
|
|
it's possible to navigate back to the very first page for this EWW
|
|
|
|
without deleting any history entries.
|
|
|
|
|
|
|
|
For example, if `eww-history' looks like this (going from newest to
|
|
|
|
oldest, with \"*\" marking the current page):
|
|
|
|
|
|
|
|
E D C* B A
|
|
|
|
|
|
|
|
then calling this function updates `eww-history' to:
|
|
|
|
|
|
|
|
C* B A E D C B A
|
|
|
|
|
|
|
|
This is useful for setting `eww-before-browse-history-function' (which
|
|
|
|
see)."
|
|
|
|
(when (> eww-history-position 1)
|
|
|
|
(setq eww-history (take eww-history-limit
|
|
|
|
(append (nthcdr (1- eww-history-position)
|
|
|
|
eww-history)
|
|
|
|
eww-history))
|
|
|
|
;; As with `eww-delete-future-history', we don't really need
|
|
|
|
;; to set this since `eww--before-browse' sets it too, but
|
|
|
|
;; let's be thorough.
|
|
|
|
eww-history-position 1)))
|
2013-12-21 15:33:44 -05:00
|
|
|
|
2014-12-07 20:50:23 +01:00
|
|
|
(defvar eww-current-buffer)
|
|
|
|
|
2013-12-21 15:33:44 -05:00
|
|
|
(defun eww-list-histories ()
|
|
|
|
"List the eww-histories."
|
|
|
|
(interactive)
|
|
|
|
(when (null eww-history)
|
|
|
|
(error "No eww-histories are defined"))
|
2014-12-07 20:38:38 +01:00
|
|
|
(let ((eww-history-trans eww-history)
|
|
|
|
(buffer (current-buffer)))
|
2014-01-05 10:27:26 +01:00
|
|
|
(set-buffer (get-buffer-create "*eww history*"))
|
|
|
|
(eww-history-mode)
|
2014-12-07 20:38:38 +01:00
|
|
|
(setq-local eww-current-buffer buffer)
|
2014-01-05 10:27:26 +01:00
|
|
|
(let ((inhibit-read-only t)
|
|
|
|
(domain-length 0)
|
|
|
|
(title-length 0)
|
|
|
|
url title format start)
|
|
|
|
(erase-buffer)
|
|
|
|
(dolist (history eww-history-trans)
|
|
|
|
(setq start (point))
|
|
|
|
(setq domain-length (max domain-length (length (plist-get history :url))))
|
|
|
|
(setq title-length (max title-length (length (plist-get history :title)))))
|
|
|
|
(setq format (format "%%-%ds %%-%ds" title-length domain-length)
|
|
|
|
header-line-format
|
|
|
|
(concat " " (format format "Title" "URL")))
|
|
|
|
(dolist (history eww-history-trans)
|
|
|
|
(setq start (point))
|
|
|
|
(setq url (plist-get history :url))
|
|
|
|
(setq title (plist-get history :title))
|
|
|
|
(insert (format format title url))
|
|
|
|
(insert "\n")
|
|
|
|
(put-text-property start (1+ start) 'eww-history history))
|
|
|
|
(goto-char (point-min)))
|
|
|
|
(pop-to-buffer "*eww history*")))
|
2013-12-21 15:33:44 -05:00
|
|
|
|
|
|
|
(defun eww-history-browse ()
|
|
|
|
"Browse the history under point in eww."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-history-mode)
|
2013-12-21 15:33:44 -05:00
|
|
|
(let ((history (get-text-property (line-beginning-position) 'eww-history)))
|
|
|
|
(unless history
|
|
|
|
(error "No history on the current line"))
|
2014-12-07 20:38:38 +01:00
|
|
|
(let ((buffer eww-current-buffer))
|
|
|
|
(quit-window)
|
|
|
|
(when buffer
|
2016-02-03 13:35:10 +11:00
|
|
|
(pop-to-buffer-same-window buffer)))
|
2014-01-05 10:27:26 +01:00
|
|
|
(eww-restore-history history)))
|
2013-12-21 15:33:44 -05:00
|
|
|
|
2021-10-05 10:34:37 +02:00
|
|
|
(defvar-keymap eww-history-mode-map
|
2021-11-16 08:18:30 +01:00
|
|
|
"RET" #'eww-history-browse
|
2021-10-04 10:15:04 +02:00
|
|
|
"n" #'next-line
|
|
|
|
"p" #'previous-line
|
|
|
|
:menu '("Eww History"
|
|
|
|
["Exit" quit-window t]
|
|
|
|
["Browse" eww-history-browse
|
|
|
|
:active (get-text-property (line-beginning-position)
|
|
|
|
'eww-history)]))
|
2013-12-21 15:33:44 -05:00
|
|
|
|
2015-09-30 14:24:38 -04:00
|
|
|
(define-derived-mode eww-history-mode special-mode "eww history"
|
2013-12-21 15:33:44 -05:00
|
|
|
"Mode for listing eww-histories.
|
|
|
|
|
|
|
|
\\{eww-history-mode-map}"
|
2021-02-14 14:08:56 +01:00
|
|
|
:interactive nil
|
2013-12-21 15:33:44 -05:00
|
|
|
(buffer-disable-undo)
|
2015-09-30 14:24:38 -04:00
|
|
|
(setq truncate-lines t))
|
2013-12-21 15:33:44 -05:00
|
|
|
|
2014-12-08 19:29:06 +01:00
|
|
|
;;; eww buffers list
|
|
|
|
|
|
|
|
(defun eww-list-buffers ()
|
|
|
|
"Enlist eww buffers."
|
|
|
|
(interactive)
|
|
|
|
(let (buffers-info
|
|
|
|
(current (current-buffer)))
|
|
|
|
(dolist (buffer (buffer-list))
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(when (derived-mode-p 'eww-mode)
|
|
|
|
(push (vector buffer (plist-get eww-data :title)
|
|
|
|
(plist-get eww-data :url))
|
|
|
|
buffers-info))))
|
|
|
|
(unless buffers-info
|
|
|
|
(error "No eww buffers"))
|
|
|
|
(setq buffers-info (nreverse buffers-info)) ;more recent on top
|
|
|
|
(set-buffer (get-buffer-create "*eww buffers*"))
|
|
|
|
(eww-buffers-mode)
|
|
|
|
(let ((inhibit-read-only t)
|
|
|
|
(domain-length 0)
|
|
|
|
(title-length 0)
|
|
|
|
url title format start)
|
|
|
|
(erase-buffer)
|
|
|
|
(dolist (buffer-info buffers-info)
|
|
|
|
(setq title-length (max title-length
|
|
|
|
(length (elt buffer-info 1)))
|
|
|
|
domain-length (max domain-length
|
|
|
|
(length (elt buffer-info 2)))))
|
|
|
|
(setq format (format "%%-%ds %%-%ds" title-length domain-length)
|
|
|
|
header-line-format
|
|
|
|
(concat " " (format format "Title" "URL")))
|
|
|
|
(let ((line 0)
|
|
|
|
(current-buffer-line 1))
|
|
|
|
(dolist (buffer-info buffers-info)
|
|
|
|
(setq start (point)
|
|
|
|
title (elt buffer-info 1)
|
|
|
|
url (elt buffer-info 2)
|
|
|
|
line (1+ line))
|
|
|
|
(insert (format format title url))
|
|
|
|
(insert "\n")
|
|
|
|
(let ((buffer (elt buffer-info 0)))
|
|
|
|
(put-text-property start (1+ start) 'eww-buffer
|
|
|
|
buffer)
|
|
|
|
(when (eq current buffer)
|
|
|
|
(setq current-buffer-line line))))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(forward-line (1- current-buffer-line)))))
|
|
|
|
(pop-to-buffer "*eww buffers*"))
|
|
|
|
|
|
|
|
(defun eww-buffer-select ()
|
|
|
|
"Switch to eww buffer."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-buffers-mode)
|
2014-12-08 19:29:06 +01:00
|
|
|
(let ((buffer (get-text-property (line-beginning-position)
|
|
|
|
'eww-buffer)))
|
|
|
|
(unless buffer
|
|
|
|
(error "No buffer on current line"))
|
|
|
|
(quit-window)
|
2016-02-03 13:35:10 +11:00
|
|
|
(pop-to-buffer-same-window buffer)))
|
2014-12-08 19:29:06 +01:00
|
|
|
|
|
|
|
(defun eww-buffer-show ()
|
|
|
|
"Display buffer under point in eww buffer list."
|
|
|
|
(let ((buffer (get-text-property (line-beginning-position)
|
|
|
|
'eww-buffer)))
|
|
|
|
(unless buffer
|
|
|
|
(error "No buffer on current line"))
|
|
|
|
(other-window -1)
|
2016-02-03 13:35:10 +11:00
|
|
|
(pop-to-buffer-same-window buffer)
|
2014-12-08 19:29:06 +01:00
|
|
|
(other-window 1)))
|
|
|
|
|
|
|
|
(defun eww-buffer-show-next ()
|
|
|
|
"Move to next eww buffer in the list and display it."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-buffers-mode)
|
2014-12-08 19:29:06 +01:00
|
|
|
(forward-line)
|
|
|
|
(when (eobp)
|
|
|
|
(goto-char (point-min)))
|
|
|
|
(eww-buffer-show))
|
|
|
|
|
|
|
|
(defun eww-buffer-show-previous ()
|
|
|
|
"Move to previous eww buffer in the list and display it."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-buffers-mode)
|
2014-12-08 19:29:06 +01:00
|
|
|
(beginning-of-line)
|
|
|
|
(when (bobp)
|
|
|
|
(goto-char (point-max)))
|
|
|
|
(forward-line -1)
|
|
|
|
(eww-buffer-show))
|
|
|
|
|
|
|
|
(defun eww-buffer-kill ()
|
|
|
|
"Kill buffer from eww list."
|
2021-02-14 14:08:56 +01:00
|
|
|
(interactive nil eww-buffers-mode)
|
2014-12-08 19:29:06 +01:00
|
|
|
(let* ((start (line-beginning-position))
|
|
|
|
(buffer (get-text-property start 'eww-buffer))
|
|
|
|
(inhibit-read-only t))
|
|
|
|
(unless buffer
|
|
|
|
(user-error "No buffer on the current line"))
|
|
|
|
(kill-buffer buffer)
|
|
|
|
(forward-line 1)
|
|
|
|
(delete-region start (point)))
|
|
|
|
(when (eobp)
|
|
|
|
(forward-line -1))
|
|
|
|
(eww-buffer-show))
|
|
|
|
|
2021-10-05 10:34:37 +02:00
|
|
|
(defvar-keymap eww-buffers-mode-map
|
2021-11-16 08:18:30 +01:00
|
|
|
"C-k" #'eww-buffer-kill
|
|
|
|
"RET" #'eww-buffer-select
|
2021-10-04 10:15:04 +02:00
|
|
|
"n" #'eww-buffer-show-next
|
|
|
|
"p" #'eww-buffer-show-previous
|
|
|
|
:menu '("Eww Buffers"
|
|
|
|
["Exit" quit-window t]
|
|
|
|
["Select" eww-buffer-select
|
|
|
|
:active (get-text-property (line-beginning-position) 'eww-buffer)]
|
|
|
|
["Kill" eww-buffer-kill
|
|
|
|
:active (get-text-property (line-beginning-position)
|
|
|
|
'eww-buffer)]))
|
2014-12-08 19:29:06 +01:00
|
|
|
|
2015-09-30 14:24:38 -04:00
|
|
|
(define-derived-mode eww-buffers-mode special-mode "eww buffers"
|
2014-12-08 19:29:06 +01:00
|
|
|
"Mode for listing buffers.
|
|
|
|
|
|
|
|
\\{eww-buffers-mode-map}"
|
2021-02-14 14:08:56 +01:00
|
|
|
:interactive nil
|
2014-12-08 19:29:06 +01:00
|
|
|
(buffer-disable-undo)
|
2015-09-30 14:24:38 -04:00
|
|
|
(setq truncate-lines t))
|
2014-12-08 19:29:06 +01:00
|
|
|
|
2014-11-19 18:21:58 +01:00
|
|
|
;;; Desktop support
|
|
|
|
|
|
|
|
(defvar eww-desktop-data-save
|
|
|
|
'(:url :title :point)
|
|
|
|
"List of `eww-data' properties to preserve in the desktop file.
|
|
|
|
Also used when saving `eww-history'.")
|
|
|
|
|
|
|
|
(defun eww-desktop-data-1 (alist)
|
|
|
|
(let ((acc nil)
|
|
|
|
(tail alist))
|
|
|
|
(while tail
|
|
|
|
(let ((k (car tail))
|
|
|
|
(v (cadr tail)))
|
|
|
|
(when (memq k eww-desktop-data-save)
|
|
|
|
(setq acc (cons k (cons v acc)))))
|
|
|
|
(setq tail (cddr tail)))
|
|
|
|
acc))
|
|
|
|
|
|
|
|
(defun eww-desktop-history-duplicate (a b)
|
|
|
|
(let ((tail a) (r t))
|
|
|
|
(while tail
|
|
|
|
(if (or (memq (car tail) '(:point)) ; ignore :point
|
|
|
|
(equal (cadr tail)
|
|
|
|
(plist-get b (car tail))))
|
|
|
|
(setq tail (cddr tail))
|
|
|
|
(setq tail nil
|
|
|
|
r nil)))
|
|
|
|
;; .
|
|
|
|
r))
|
|
|
|
|
2015-01-12 13:07:52 -05:00
|
|
|
(defun eww-desktop-misc-data (_directory)
|
2014-11-19 18:21:58 +01:00
|
|
|
"Return a property list with data used to restore eww buffers.
|
|
|
|
This list will contain, as :history, the list, whose first element is
|
|
|
|
the value of `eww-data', and the tail is `eww-history'.
|
|
|
|
|
|
|
|
If `eww-desktop-remove-duplicates' is non-nil, duplicate
|
|
|
|
entries (if any) will be removed from the list.
|
|
|
|
|
|
|
|
Only the properties listed in `eww-desktop-data-save' are included.
|
|
|
|
Generally, the list should not include the (usually overly large)
|
|
|
|
:dom, :source and :text properties."
|
2020-05-06 18:02:32 +01:00
|
|
|
(let ((history (mapcar #'eww-desktop-data-1
|
2024-06-11 03:00:33 +05:30
|
|
|
(cons eww-data eww-history)))
|
|
|
|
(posn eww-history-position) rval)
|
|
|
|
(list :history
|
|
|
|
(if eww-desktop-remove-duplicates
|
|
|
|
(prog1
|
|
|
|
(setq
|
|
|
|
rval (cl-remove-duplicates
|
|
|
|
history :test #'eww-desktop-history-duplicate))
|
|
|
|
(setq posn
|
|
|
|
(cl-position
|
|
|
|
(elt history eww-history-position)
|
|
|
|
rval :test #'eq)))
|
|
|
|
history)
|
|
|
|
:history-position posn)))
|
2014-11-19 18:21:58 +01:00
|
|
|
|
|
|
|
(defun eww-restore-desktop (file-name buffer-name misc-data)
|
|
|
|
"Restore an eww buffer from its desktop file record.
|
2015-11-18 09:17:20 -08:00
|
|
|
If `eww-restore-desktop' is t or `auto', this function will also
|
2014-11-19 18:21:58 +01:00
|
|
|
initiate the retrieval of the respective URI in the background.
|
|
|
|
Otherwise, the restored buffer will contain a prompt to do so by using
|
|
|
|
\\[eww-reload]."
|
|
|
|
(with-current-buffer (get-buffer-create buffer-name)
|
|
|
|
(eww-mode)
|
|
|
|
;; NB: eww-history, eww-data are buffer-local per (eww-mode)
|
|
|
|
(setq eww-history (cdr (plist-get misc-data :history))
|
|
|
|
eww-data (or (car (plist-get misc-data :history))
|
|
|
|
;; backwards compatibility
|
2024-06-11 03:00:33 +05:30
|
|
|
(list :url (plist-get misc-data :uri)))
|
|
|
|
eww-history-position (plist-get misc-data :history-position))
|
2014-11-19 18:21:58 +01:00
|
|
|
(unless file-name
|
|
|
|
(when (plist-get eww-data :url)
|
2016-11-04 10:14:01 -04:00
|
|
|
(cl-case eww-restore-desktop
|
2014-11-19 18:21:58 +01:00
|
|
|
((t auto) (eww (plist-get eww-data :url)))
|
2022-12-21 12:33:25 +01:00
|
|
|
((nil) (when (zerop (buffer-size))
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(insert (substitute-command-keys
|
|
|
|
eww-restore-reload-prompt))))))))
|
2014-11-19 18:21:58 +01:00
|
|
|
;; .
|
|
|
|
(current-buffer)))
|
|
|
|
|
|
|
|
(add-to-list 'desktop-buffer-mode-handlers
|
|
|
|
'(eww-mode . eww-restore-desktop))
|
|
|
|
|
2014-12-31 01:50:06 +02:00
|
|
|
;;; Isearch support
|
|
|
|
|
2015-01-12 13:07:52 -05:00
|
|
|
(defun eww-isearch-next-buffer (&optional _buffer wrap)
|
2014-12-31 01:50:06 +02:00
|
|
|
"Go to the next page to search using `rel' attribute for navigation."
|
2021-09-20 10:16:09 +03:00
|
|
|
(let ((eww-retrieve-command 'sync))
|
|
|
|
(if wrap
|
|
|
|
(condition-case nil
|
|
|
|
(eww-top-url)
|
|
|
|
(error nil))
|
|
|
|
(if isearch-forward
|
|
|
|
(eww-next-url)
|
|
|
|
(eww-previous-url))))
|
2014-12-31 01:50:06 +02:00
|
|
|
(current-buffer))
|
|
|
|
|
2021-09-29 03:24:10 +02:00
|
|
|
;;; bookmark.el support
|
|
|
|
|
|
|
|
(declare-function bookmark-make-record-default
|
|
|
|
"bookmark" (&optional no-file no-context posn))
|
|
|
|
(declare-function bookmark-prop-get "bookmark" (bookmark prop))
|
|
|
|
|
|
|
|
(defun eww-bookmark-name ()
|
|
|
|
"Create a default bookmark name for the current EWW buffer."
|
|
|
|
(plist-get eww-data :title))
|
|
|
|
|
|
|
|
(defun eww-bookmark-make-record ()
|
|
|
|
"Create a bookmark for the current EWW buffer."
|
|
|
|
`(,(eww-bookmark-name)
|
|
|
|
,@(bookmark-make-record-default t)
|
|
|
|
(location . ,(plist-get eww-data :url))
|
|
|
|
(handler . eww-bookmark-jump)))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun eww-bookmark-jump (bookmark)
|
|
|
|
"Default bookmark handler for EWW buffers."
|
|
|
|
(eww (bookmark-prop-get bookmark 'location)))
|
|
|
|
|
2022-02-15 23:39:02 +01:00
|
|
|
(put 'eww-bookmark-jump 'bookmark-handler-type "EWW")
|
|
|
|
|
2013-06-10 11:46:27 +00:00
|
|
|
(provide 'eww)
|
|
|
|
|
2023-06-17 13:48:51 +03:00
|
|
|
;;; Alternate links (RSS and Atom feeds, etc.)
|
|
|
|
|
|
|
|
(defun eww--alternate-urls (dom &optional base)
|
|
|
|
"Return an alist of alternate links in DOM.
|
|
|
|
|
|
|
|
Each element is a list of the form (URL TYPE TITLE) where URL is
|
|
|
|
the href attribute of the link expanded relative to BASE, TYPE is
|
|
|
|
its type attribute, and TITLE is its title attribute. If any of
|
|
|
|
these attributes is absent, the corresponding element is nil."
|
|
|
|
(let ((alternates
|
|
|
|
(seq-filter
|
|
|
|
(lambda (attrs) (string= (alist-get 'rel attrs)
|
|
|
|
"alternate"))
|
|
|
|
(mapcar #'dom-attributes (dom-by-tag dom 'link)))))
|
|
|
|
(mapcar (lambda (alternate)
|
|
|
|
(list (url-expand-file-name (alist-get 'href alternate)
|
|
|
|
base)
|
|
|
|
(alist-get 'type alternate)
|
|
|
|
(alist-get 'title alternate)))
|
|
|
|
alternates)))
|
|
|
|
|
|
|
|
(defun eww-read-alternate-url ()
|
|
|
|
"Get the URL of an alternate link of this page.
|
|
|
|
|
|
|
|
If there is just one alternate link, return its URL. If there
|
|
|
|
are multiple alternate links, prompt for one in the minibuffer
|
|
|
|
with completion. If there are none, return nil."
|
|
|
|
(when-let ((alternates (eww--alternate-urls
|
|
|
|
(plist-get eww-data :dom)
|
|
|
|
(plist-get eww-data :url))))
|
|
|
|
(let ((url-max-width
|
|
|
|
(seq-max (mapcar #'string-pixel-width
|
|
|
|
(mapcar #'car alternates))))
|
|
|
|
(title-max-width
|
|
|
|
(seq-max (mapcar #'string-pixel-width
|
|
|
|
(mapcar #'caddr alternates))))
|
|
|
|
(sep-width (string-pixel-width " ")))
|
|
|
|
(if (cdr alternates)
|
|
|
|
(let ((completion-extra-properties
|
|
|
|
(list :annotation-function
|
|
|
|
(lambda (feed)
|
|
|
|
(let* ((attrs (alist-get feed
|
|
|
|
alternates
|
|
|
|
nil
|
|
|
|
nil
|
|
|
|
#'string=))
|
|
|
|
(type (car attrs))
|
|
|
|
(title (cadr attrs)))
|
|
|
|
(concat
|
|
|
|
(propertize " " 'display
|
|
|
|
`(space :align-to
|
|
|
|
(,(+ sep-width
|
|
|
|
url-max-width))))
|
|
|
|
title
|
|
|
|
(when type
|
|
|
|
(concat
|
|
|
|
(propertize " " 'display
|
|
|
|
`(space :align-to
|
|
|
|
(,(+ (* 2 sep-width)
|
|
|
|
url-max-width
|
|
|
|
title-max-width))))
|
|
|
|
"[" type "]"))))))))
|
|
|
|
(completing-read "Alternate URL: " alternates nil t))
|
|
|
|
(caar alternates)))))
|
|
|
|
|
|
|
|
(defun eww-copy-alternate-url ()
|
2023-06-24 14:58:44 +03:00
|
|
|
"Copy the alternate URL of the current page into the kill ring.
|
|
|
|
If there are multiple alternate links on the current page, prompt
|
|
|
|
for one in the minibuffer, with completion.
|
2023-06-17 13:48:51 +03:00
|
|
|
Alternate links are references that an HTML page may include to
|
|
|
|
point to its alternative representations, such as a translated
|
|
|
|
version or an RSS feed."
|
|
|
|
(interactive nil eww-mode)
|
|
|
|
(if-let ((url (eww-read-alternate-url)))
|
|
|
|
(progn
|
|
|
|
(kill-new url)
|
|
|
|
(message "Copied %s to kill ring" url))
|
|
|
|
(user-error "No alternate links found on this page!")))
|
|
|
|
|
2013-06-10 11:46:27 +00:00
|
|
|
;;; eww.el ends here
|