[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] xwidget_mvp 2cd0e6d 1/4: upstream merge
From: |
Joakim Verona |
Subject: |
[Emacs-diffs] xwidget_mvp 2cd0e6d 1/4: upstream merge |
Date: |
Thu, 22 Oct 2015 21:17:04 +0000 |
branch: xwidget_mvp
commit 2cd0e6d0cf2a83d10b21398398789b4579156b71
Merge: c1a5a72 e73b0d6
Author: Joakim Verona <address@hidden>
Commit: Joakim Verona <address@hidden>
upstream merge
---
admin/MAINTAINERS | 73 +++++++++-
doc/lispref/windows.texi | 14 +-
etc/NEWS | 6 +-
lisp/arc-mode.el | 35 +++---
lisp/emacs-lisp/lisp-mode.el | 20 ++-
lisp/gnus/auth-source.el | 2 +-
lisp/progmodes/grep.el | 22 ++--
lisp/progmodes/octave.el | 316 ++++++++++++++++++++++--------------------
lisp/progmodes/prog-mode.el | 43 +++++-
lisp/progmodes/prolog.el | 36 ++++-
lisp/progmodes/sh-script.el | 79 +++++++++--
src/macfont.m | 168 +++++++++++++++--------
src/window.c | 6 +-
test/indent/octave.m | 22 +++
test/indent/prolog.prolog | 52 +++++--
15 files changed, 595 insertions(+), 299 deletions(-)
diff --git a/admin/MAINTAINERS b/admin/MAINTAINERS
index c6a7be1..8a158e4 100644
--- a/admin/MAINTAINERS
+++ b/admin/MAINTAINERS
@@ -122,6 +122,13 @@ The GNU AUCTeX maintainers (address@hidden)
lisp/textmodes/reftex-vars.el
lisp/textmodes/reftex.el
+Dmitry Gutov
+ lisp/progmodes/ruby-mode.el
+ test/automated/ruby-mode-tests.el
+ test/indent/ruby.rb
+ lisp/progmodes/xref.el
+ lisp/progmodes/project.el
+
==============================================================================
2.
==============================================================================
@@ -226,6 +233,14 @@ Xue Fuqiao
Tassilo Horn
lisp/doc-view.el
+Dmitry Gutov
+ lisp/whitespace.el
+ lisp/vc/*
+
+Vibhav Pant
+ lisp/net/browse-url.el
+ lisp/erc/*
+
==============================================================================
3.
==============================================================================
@@ -504,7 +519,57 @@ lisp/mouse.el
lisp/mpc.el
lisp/msb.el
lisp/mwheel.el
-lisp/net/*
+lisp/net/ange-ftp.el
+lisp/net/dig.el
+lisp/net/dns.el
+lisp/net/eudcb-bbdb.el
+lisp/net/eudcb-ldap.el
+lisp/net/eudcb-mab.el
+lisp/net/eudc-bob.el
+lisp/net/eudcb-ph.el
+lisp/net/eudc.el
+lisp/net/eudc-export.el
+lisp/net/eudc-hotlist.el
+lisp/net/eudc-vars.el
+lisp/net/eww.el
+lisp/net/gnutls.el
+lisp/net/goto-addr.el
+lisp/net/hmac-def.el
+lisp/net/hmac-md5.el
+lisp/net/imap.el
+lisp/net/ldap.el
+lisp/net/mairix.el
+lisp/net/netrc.el
+lisp/net/net-utils.el
+lisp/net/network-stream.el
+lisp/net/newst-backend.el
+lisp/net/newsticker.el
+lisp/net/newst-plainview.el
+lisp/net/newst-reader.el
+lisp/net/newst-ticker.el
+lisp/net/newst-treeview.el
+lisp/net/nsm.el
+lisp/net/ntlm.el
+lisp/net/pinentry.el
+lisp/net/quickurl.el
+lisp/net/rcirc.el
+lisp/net/rfc2104.el
+lisp/net/rlogin.el
+lisp/net/sasl-cram.el
+lisp/net/sasl-digest.el
+lisp/net/sasl.el
+lisp/net/sasl-ntlm.el
+lisp/net/sasl-scram-rfc.el
+lisp/net/shr-color.el
+lisp/net/shr.el
+lisp/net/snmp-mode.el
+lisp/net/soap-client.el
+lisp/net/soap-inspect.el
+lisp/net/socks.el
+lisp/net/telnet.el
+lisp/net/tls.el
+lisp/net/trampver.el
+lisp/net/webjump.el
lisp/newcomment.el
lisp/novice.el
lisp/nxml/*
@@ -590,11 +655,9 @@ lisp/progmodes/octave.el
lisp/progmodes/opascal.el
lisp/progmodes/pascal.el
lisp/progmodes/prog-mode.el
-lisp/progmodes/project.el
lisp/progmodes/prolog.el
lisp/progmodes/ps-mode.el
lisp/progmodes/python.el
-lisp/progmodes/ruby-mode.el
lisp/progmodes/scheme.el
lisp/progmodes/sh-script.el
lisp/progmodes/simula.el
@@ -604,7 +667,6 @@ lisp/progmodes/vera-mode.el
lisp/progmodes/verilog-mode.el
lisp/progmodes/vhdl-mode.el
lisp/progmodes/which-func.el
-lisp/progmodes/xref.el
lisp/progmodes/xscheme.el
lisp/ps-bdf.el
lisp/ps-def.el
@@ -703,14 +765,12 @@ lisp/type-break.el
lisp/uniquify.el
lisp/url/*
lisp/userlock.el
-lisp/vc/*
lisp/vcursor.el
lisp/version.el
lisp/view.el
lisp/vt-control.el
lisp/vt100-led.el
lisp/wdired.el
-lisp/whitespace.el
lisp/wid-browse.el
lisp/wid-edit.el
lisp/widget.el
@@ -740,4 +800,5 @@ test/rmailmm.el
;;; Local Variables:
;;; coding: utf-8
+;;; indent-tabs-mode: t
;;; End:
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index 00161b2..1da2d1c 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -3174,12 +3174,14 @@ position that works well with point, and thus
@var{position} is not used.
@defun pos-visible-in-window-p &optional position window partially
This function returns address@hidden if @var{position} is within the
range of text currently visible on the screen in @var{window}. It
-returns @code{nil} if @var{position} is scrolled vertically out of view.
-Locations that are partially obscured are not considered visible unless
address@hidden is address@hidden The argument @var{position} defaults
-to the current position of point in @var{window}; @var{window}, to the
-selected window. If @var{position} is @code{t}, that means to check the
-last visible position in @var{window}.
+returns @code{nil} if @var{position} is scrolled vertically out of
+view. Locations that are partially obscured are not considered
+visible unless @var{partially} is address@hidden The argument
address@hidden defaults to the current position of point in
address@hidden; @var{window} defaults to the selected window. If
address@hidden is @code{t}, that means to check either the first
+visible position of the last screen line in @var{window}, or the
+end-of-buffer position, whichever comes first.
This function considers only vertical scrolling. If @var{position} is
out of view only because @var{window} has been scrolled horizontally,
diff --git a/etc/NEWS b/etc/NEWS
index e823905..26f0474 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -634,9 +634,13 @@ you can no longer use commas to separate regular
expressions.
** SES now supports local printer functions; see `ses-define-local-printer'.
-** In sh-mode, you can now use `sh-shell' as a file-local variable to
+** sh-script
+*** In sh-mode you can now use `sh-shell' as a file-local variable to
specify the type of shell in use (bash, csh, etc).
+*** New value `always' for sh-indent-after-continuation.
+This provides old-style ("dumb") indentation of continued lines.
+
** TLS
---
*** Fatal TLS errors are now silent by default.
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index f852f2d..cf071e2 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -1162,7 +1162,7 @@ using `make-temp-file', and the generated name is
returned."
nil
`(:file ,stdout-file)
nil
- (append (cdr command) (list archive name dest)))
+ `(,archive ,name ,@(cdr command) ,dest))
(with-temp-buffer
(insert-file-contents stdout-file)
(goto-char (point-min))
@@ -2038,37 +2038,36 @@ This doesn't recover lost files, it just undoes changes
in the buffer itself."
(maxsize 5)
(files ()))
(with-temp-buffer
- (call-process "unrar-free" nil t nil "--list" (or file copy))
+ (call-process "lsar" nil t nil "-l" (or file copy))
(if copy (delete-file copy))
(goto-char (point-min))
- (re-search-forward "^-+\n")
- (while (looking-at (concat " \\(.*\\)\n" ;Name.
- ;; Size ; Packed.
- " +\\([0-9]+\\) +[0-9]+"
- ;; Ratio ; Date'
- " +\\([0-9%]+\\) +\\([-0-9]+\\)"
- ;; Time ; Attr.
- " +\\([0-9:]+\\) +[^ \n]\\{6,10\\}"
- ;; CRC; Meth ; Var.
- " +[0-9A-F]+ +[^ \n]+ +[0-9.]+\n"))
+ (re-search-forward "^\\(\s+=+\s?+\\)+\n")
+ (while (looking-at (concat "^\s+[0-9.]+\s+-+\s+" ; Flags
+ "\\([0-9-]+\\)\s+" ; Size
+ "\\([0-9.%]+\\)\s+" ; Ratio
+ "\\([0-9a-zA-Z]+\\)\s+" ; Mode
+ "\\([0-9-]+\\)\s+" ; Date
+ "\\([0-9:]+\\)\s+" ; Time
+ "\\(.*\\)\n" ; Name
+ ))
(goto-char (match-end 0))
- (let ((name (match-string 1))
- (size (match-string 2)))
+ (let ((name (match-string 6))
+ (size (match-string 1)))
(if (> (length name) maxname) (setq maxname (length name)))
(if (> (length size) maxsize) (setq maxsize (length size)))
(push (vector name name nil nil
;; Size, Ratio.
- size (match-string 3)
+ size (match-string 2)
;; Date, Time.
(match-string 4) (match-string 5))
files))))
(setq files (nreverse files))
(goto-char (point-min))
(let* ((format (format " %%s %%s %%%ds %%5s %%s" maxsize))
- (sep (format format "--------" "-----" (make-string maxsize ?-)
+ (sep (format format "----------" "-----" (make-string maxsize ?-)
"-----" ""))
(column (length sep)))
- (insert (format format " Date " "Time " "Size " "Ratio" " Filename")
"\n")
+ (insert (format format " Date " "Time " "Size" "Ratio" "Filename")
"\n")
(insert sep (make-string maxname ?-) "\n")
(archive-summarize-files (mapcar (lambda (desc)
(let ((text
@@ -2091,7 +2090,7 @@ This doesn't recover lost files, it just undoes changes
in the buffer itself."
;; The code below assumes the name is relative and may do undesirable
;; things otherwise.
(error "Can't extract files with non-relative names")
- (archive-extract-by-file archive name '("unrar-free" "--extract") "All
OK")))
+ (archive-extract-by-file archive name `("unar" "-no-directory" "-o")
"Successfully extracted")))
;;; Section: Rar self-extracting .exe archives.
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index fec9467..9ce0dfd 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -238,17 +238,21 @@
(throw 'found t))))))
(defmacro let-when-compile (bindings &rest body)
- "Like `let', but allow for compile time optimization.
-Use BINDINGS as in regular `let', but in BODY each usage should
+ "Like `let*', but allow for compile time optimization.
+Use BINDINGS as in regular `let*', but in BODY each usage should
be wrapped in `eval-when-compile'.
This will generate compile-time constants from BINDINGS."
(declare (indent 1) (debug let))
- (cl-progv (mapcar #'car bindings)
- (mapcar (lambda (x) (eval (cadr x))) bindings)
- (macroexpand-all
- (macroexp-progn
- body)
- macroexpand-all-environment)))
+ (letrec ((loop
+ (lambda (bindings)
+ (if (null bindings)
+ (macroexpand-all (macroexp-progn body)
+ macroexpand-all-environment)
+ (let ((binding (pop bindings)))
+ (cl-progv (list (car binding))
+ (list (eval (nth 1 binding) t))
+ (funcall loop bindings)))))))
+ (funcall loop bindings)))
(let-when-compile
((lisp-fdefs '("defmacro" "defun"))
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el
index f101ecd..32e22eb 100644
--- a/lisp/gnus/auth-source.el
+++ b/lisp/gnus/auth-source.el
@@ -560,7 +560,7 @@ other properties will always hold scalar values.
Typically the :secret property, if present, contains a password.
Common search keys are :max, :host, :port, and :user. In
-addition, :create specifies how tokens will be or created.
+addition, :create specifies if and how tokens will be created.
Finally, :type can specify which backend types you want to check.
A string value is always matched literally. A symbol is matched
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 3240ee8..452a42f 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -1039,16 +1039,18 @@ to specify a command to run."
;; we should use shell-quote-argument here
" -path "
(mapconcat
- #'(lambda (ignore)
- (cond ((stringp ignore)
- (shell-quote-argument
- (concat "*/" ignore)))
- ((consp ignore)
- (and (funcall (car ignore) dir)
- (shell-quote-argument
- (concat "*/"
- (cdr ignore)))))))
- grep-find-ignored-directories
+ 'identity
+ (delq nil (mapcar
+ #'(lambda (ignore)
+ (cond ((stringp ignore)
+ (shell-quote-argument
+ (concat "*/" ignore)))
+ ((consp ignore)
+ (and (funcall (car ignore) dir)
+ (shell-quote-argument
+ (concat "*/"
+ (cdr ignore)))))))
+ grep-find-ignored-directories))
" -o -path ")
" "
(shell-quote-argument ")")
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index 70a2b1a..b54b88d 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -82,25 +82,6 @@ Used in `octave-mode' and `inferior-octave-mode' buffers.")
(defvar octave-comment-start-skip "\\(^\\|\\S<\\)\\(?:%!\\|\\s<+\\)\\s-*"
"Octave-specific `comment-start-skip' (which see).")
-(defvar octave-begin-keywords
- '("classdef" "do" "enumeration" "events" "for" "function" "if" "methods"
- "parfor" "properties" "switch" "try" "unwind_protect" "while"))
-
-(defvar octave-else-keywords
- '("case" "catch" "else" "elseif" "otherwise" "unwind_protect_cleanup"))
-
-(defvar octave-end-keywords
- '("endclassdef" "endenumeration" "endevents" "endfor" "endfunction" "endif"
- "endmethods" "endparfor" "endproperties" "endswitch" "end_try_catch"
- "end_unwind_protect" "endwhile" "until" "end"))
-
-(defvar octave-reserved-words
- (append octave-begin-keywords
- octave-else-keywords
- octave-end-keywords
- '("break" "continue" "global" "persistent" "return"))
- "Reserved words in Octave.")
-
(defvar octave-function-header-regexp
(concat "^\\s-*\\_<\\(function\\)\\_>"
"\\([^=;(\n]*=[ \t]*\\|[ \t]*\\)\\(\\(?:\\w\\|\\s_\\)+\\)\\_>")
@@ -231,20 +212,17 @@ parenthetical grouping.")
(defcustom octave-font-lock-texinfo-comment t
"Control whether to highlight the texinfo comment block."
:type 'boolean
- :group 'octave
:version "24.4")
(defcustom octave-blink-matching-block t
"Control the blinking of matching Octave block keywords.
Non-nil means show matching begin of block when inserting a space,
newline or semicolon after an else or end keyword."
- :type 'boolean
- :group 'octave)
+ :type 'boolean)
(defcustom octave-block-offset 2
"Extra indentation applied to statements in Octave block structures."
- :type 'integer
- :group 'octave)
+ :type 'integer)
(defvar octave-block-comment-start
(concat (make-string 2 octave-comment-char) " ")
@@ -252,8 +230,7 @@ newline or semicolon after an else or end keyword."
(defcustom octave-continuation-offset 4
"Extra indentation applied to Octave continuation lines."
- :type 'integer
- :group 'octave)
+ :type 'integer)
(eval-and-compile
(defconst octave-continuation-marker-regexp "\\\\\\|\\.\\.\\."))
@@ -274,109 +251,135 @@ newline or semicolon after an else or end keyword."
(defcustom octave-mode-hook nil
"Hook to be run when Octave mode is started."
- :type 'hook
- :group 'octave)
+ :type 'hook)
(defcustom octave-send-show-buffer t
"Non-nil means display `inferior-octave-buffer' after sending to it."
- :type 'boolean
- :group 'octave)
+ :type 'boolean)
(defcustom octave-send-line-auto-forward t
"Control auto-forward after sending to the inferior Octave process.
Non-nil means always go to the next Octave code line after sending."
- :type 'boolean
- :group 'octave)
+ :type 'boolean)
(defcustom octave-send-echo-input t
"Non-nil means echo input sent to the inferior Octave process."
- :type 'boolean
- :group 'octave)
+ :type 'boolean)
;;; SMIE indentation
(require 'smie)
-;; Use '__operators__' in Octave REPL to get a full list.
-(defconst octave-operator-table
- '((assoc ";" "\n") (assoc ",") ; The doc claims they have equal precedence!?
- (right "=" "+=" "-=" "*=" "/=")
- (assoc "&&") (assoc "||") ; The doc claims they have equal precedence!?
- (assoc "&") (assoc "|") ; The doc claims they have equal precedence!?
- (nonassoc "<" "<=" "==" ">=" ">" "!=" "~=")
- (nonassoc ":") ;No idea what this is.
- (assoc "+" "-")
- (assoc "*" "/" "\\" ".\\" ".*" "./")
- (nonassoc "'" ".'")
- (nonassoc "++" "--" "!" "~") ;And unary "+" and "-".
- (right "^" "**" ".^" ".**")
- ;; It's not really an operator, but for indentation purposes it
- ;; could be convenient to treat it as one.
- (assoc "...")))
-
-(defconst octave-smie-bnf-table
- '((atom)
- ;; We can't distinguish the first element in a sequence with
- ;; precedence grammars, so we can't distinguish the condition
- ;; if the `if' from the subsequent body, for example.
- ;; This has to be done later in the indentation rules.
- (exp (exp "\n" exp)
- ;; We need to mention at least one of the operators in this part
- ;; of the grammar: if the BNF and the operator table have
- ;; no overlap, SMIE can't know how they relate.
- (exp ";" exp)
- ("try" exp "catch" exp "end_try_catch")
- ("try" exp "catch" exp "end")
- ("unwind_protect" exp
- "unwind_protect_cleanup" exp "end_unwind_protect")
- ("unwind_protect" exp "unwind_protect_cleanup" exp "end")
- ("for" exp "endfor")
- ("for" exp "end")
- ("parfor" exp "endparfor")
- ("parfor" exp "end")
- ("do" exp "until" atom)
- ("while" exp "endwhile")
- ("while" exp "end")
- ("if" exp "endif")
- ("if" exp "else" exp "endif")
- ("if" exp "elseif" exp "else" exp "endif")
- ("if" exp "elseif" exp "elseif" exp "else" exp "endif")
- ("if" exp "elseif" exp "elseif" exp "else" exp "end")
- ("switch" exp "case" exp "endswitch")
- ("switch" exp "case" exp "otherwise" exp "endswitch")
- ("switch" exp "case" exp "case" exp "otherwise" exp "endswitch")
- ("switch" exp "case" exp "case" exp "otherwise" exp "end")
- ("function" exp "endfunction")
- ("function" exp "end")
- ("enumeration" exp "endenumeration")
- ("enumeration" exp "end")
- ("events" exp "endevents")
- ("events" exp "end")
- ("methods" exp "endmethods")
- ("methods" exp "end")
- ("properties" exp "endproperties")
- ("properties" exp "end")
- ("classdef" exp "endclassdef")
- ("classdef" exp "end"))
- ;; (fundesc (atom "=" atom))
- ))
+(let-when-compile
+ ((operator-table
+ ;; Use '__operators__' in Octave REPL to get a full list?
+ '((assoc ";" "\n") (assoc ",") ;The doc says they have equal precedence!?
+ (right "=" "+=" "-=" "*=" "/=")
+ (assoc "&&") (assoc "||") ; The doc claims they have equal precedence!?
+ (assoc "&") (assoc "|") ; The doc claims they have equal precedence!?
+ (nonassoc "<" "<=" "==" ">=" ">" "!=" "~=")
+ (nonassoc ":") ;No idea what this is.
+ (assoc "+" "-")
+ (assoc "*" "/" "\\" ".\\" ".*" "./")
+ (nonassoc "'" ".'")
+ (nonassoc "++" "--" "!" "~") ;And unary "+" and "-".
+ (right "^" "**" ".^" ".**")
+ ;; It's not really an operator, but for indentation purposes it
+ ;; could be convenient to treat it as one.
+ (assoc "...")))
+
+ (matchedrules
+ ;; We can't distinguish the first element in a sequence with
+ ;; precedence grammars, so we can't distinguish the condition
+ ;; of the `if' from the subsequent body, for example.
+ ;; This has to be done later in the indentation rules.
+ '(("try" exp "catch" exp "end_try_catch")
+ ("unwind_protect" exp
+ "unwind_protect_cleanup" exp "end_unwind_protect")
+ ("for" exp "endfor")
+ ("parfor" exp "endparfor")
+ ("while" exp "endwhile")
+ ("if" exp "endif")
+ ("if" exp "else" exp "endif")
+ ("if" exp "elseif" exp "else" exp "endif")
+ ("if" exp "elseif" exp "elseif" exp "else" exp "endif")
+ ("switch" exp "case" exp "endswitch")
+ ("switch" exp "case" exp "otherwise" exp "endswitch")
+ ("switch" exp "case" exp "case" exp "otherwise" exp "endswitch")
+ ("function" exp "endfunction")
+ ("enumeration" exp "endenumeration")
+ ("events" exp "endevents")
+ ("methods" exp "endmethods")
+ ("properties" exp "endproperties")
+ ("classdef" exp "endclassdef")
+ ))
+
+ (bnf-table
+ `((atom)
+ ;; FIXME: We don't parse these declarations correctly since
+ ;; SMIE *really* likes to parse "a b = 2 c" as "(a b) = (2 c)".
+ ;; IOW to do it right, we'd need to change octave-smie-*ward-token
+ ;; so that the spaces between vars in var-decls are lexed as
+ ;; something like ",".
+ ;; Doesn't seem worth the trouble/slowdown for now.
+ ;; We could hack smie-rules so as to work around the bad parse,
+ ;; but even that doesn't seem worth the trouble.
+ (var-decls (atom "=" atom)) ;; (var-decls "," var-decls)
+ (single-exp (atom "=" atom))
+ (exp (exp "\n" exp)
+ ;; We need to mention at least one of the operators in this part
+ ;; of the grammar: if the BNF and the operator table have
+ ;; no overlap, SMIE can't know how they relate.
+ (exp ";" exp)
+ ("do" exp "until" single-exp)
+ ,@matchedrules
+ ;; For every rule that ends in "endfoo", add a corresponding
+ ;; rule which uses "end" instead.
+ ,@(mapcar (lambda (rule) (nconc (butlast rule) '("end")))
+ matchedrules)
+ ("global" var-decls) ("persistent" var-decls)
+ ;; These aren't super-important, but having them here
+ ;; makes it easier to extract all keywords.
+ ("break") ("continue") ("return")
+ ;; The following rules do not correspond to valid code AFAIK,
+ ;; but they lead to a grammar that degrades more gracefully
+ ;; on incomplete/incorrect code. It also helps us in
+ ;; computing octave--block-offset-keywords.
+ ("try" exp "end") ("unwind_protect" exp "end")
+ )
+ ;; (fundesc (atom "=" atom))
+ )))
(defconst octave-smie-grammar
- (smie-prec2->grammar
- (smie-merge-prec2s
- (smie-bnf->prec2 octave-smie-bnf-table
- '((assoc "\n" ";")))
+ (eval-when-compile
+ (smie-prec2->grammar
+ (smie-merge-prec2s
+ (smie-bnf->prec2 bnf-table '((assoc "\n" ";")))
+ (smie-precs->prec2 operator-table)))))
- (smie-precs->prec2 octave-operator-table))))
+(defconst octave-operator-regexp
+ (eval-when-compile
+ (regexp-opt (remove "\n" (apply #'append
+ (mapcar #'cdr operator-table)))))))
;; Tokenizing needs to be refined so that ";;" is treated as two
;; tokens and also so as to recognize the \n separator (and
;; corresponding continuation lines).
-(defconst octave-operator-regexp
- (regexp-opt (remove "\n" (apply 'append
- (mapcar 'cdr octave-operator-table)))))
+(defun octave-smie--funcall-p ()
+ "Return non-nil if we're in an expression context. Moves point."
+ (looking-at "[ \t]*("))
+
+(defun octave-smie--end-index-p ()
+ (let ((ppss (syntax-ppss)))
+ (and (nth 1 ppss)
+ (memq (char-after (nth 1 ppss)) '(?\( ?\[ ?\{)))))
+
+(defun octave-smie--in-parens-p ()
+ (let ((ppss (syntax-ppss)))
+ (and (nth 1 ppss)
+ (eq ?\( (char-after (nth 1 ppss))))))
(defun octave-smie-backward-token ()
(let ((pos (point)))
@@ -390,10 +393,7 @@ Non-nil means always go to the next Octave code line after
sending."
(forward-comment (- (point)))
nil)
t)
- ;; Ignore it if it's within parentheses.
- (let ((ppss (syntax-ppss)))
- (not (and (nth 1 ppss)
- (eq ?\( (char-after (nth 1 ppss)))))))
+ (not (octave-smie--in-parens-p)))
(skip-chars-forward " \t")
;; Why bother distinguishing \n and ;?
";") ;;"\n"
@@ -403,7 +403,15 @@ Non-nil means always go to the next Octave code line after
sending."
(goto-char (match-beginning 0))
(match-string-no-properties 0))
(t
- (smie-default-backward-token)))))
+ (let ((tok (smie-default-backward-token)))
+ (cond
+ ((equal tok "enumeration")
+ (if (save-excursion (smie-default-forward-token)
+ (octave-smie--funcall-p))
+ "enumeration (function)"
+ tok))
+ ((equal tok "end") (if (octave-smie--end-index-p) "end (index)" tok))
+ (t tok)))))))
(defun octave-smie-forward-token ()
(skip-chars-forward " \t")
@@ -417,10 +425,7 @@ Non-nil means always go to the next Octave code line after
sending."
(not (or (save-excursion (skip-chars-backward " \t")
;; Only add implicit ; when needed.
(or (bolp) (eq (char-before) ?\;)))
- ;; Ignore it if it's within parentheses.
- (let ((ppss (syntax-ppss)))
- (and (nth 1 ppss)
- (eq ?\( (char-after (nth 1 ppss))))))))
+ (octave-smie--in-parens-p))))
(if (eolp) (forward-char 1) (forward-comment 1))
;; Why bother distinguishing \n and ;?
";") ;;"\n"
@@ -436,7 +441,25 @@ Non-nil means always go to the next Octave code line after
sending."
(goto-char (match-end 0))
(match-string-no-properties 0))
(t
- (smie-default-forward-token))))
+ (let ((tok (smie-default-forward-token)))
+ (cond
+ ((equal tok "enumeration")
+ (if (octave-smie--funcall-p)
+ "enumeration (function)"
+ tok))
+ ((equal tok "end") (if (octave-smie--end-index-p) "end (index)" tok))
+ (t tok))))))
+
+(defconst octave--block-offset-keywords
+ (let* ((end-prec (nth 1 (assoc "end" octave-smie-grammar)))
+ (end-matchers
+ (delq nil
+ (mapcar (lambda (x) (if (eq end-prec (nth 2 x)) (car x)))
+ octave-smie-grammar))))
+ ;; Not sure if it would harm to keep "switch", but the previous code
+ ;; excluded it, presumably because there shouldn't be any code on
+ ;; the lines between "switch" and "case".
+ (delete "switch" end-matchers)))
(defun octave-smie-rules (kind token)
(pcase (cons kind token)
@@ -445,15 +468,12 @@ Non-nil means always go to the next Octave code line
after sending."
;; - changes to octave-block-offset wouldn't take effect immediately.
;; - edebug wouldn't show the use of this variable.
(`(:elem . basic) octave-block-offset)
+ (`(:list-intro . ,(or "global" "persistent")) t)
;; Since "case" is in the same BNF rules as switch..end, SMIE by default
;; aligns it with "switch".
(`(:before . "case") (if (not (smie-rule-sibling-p)) octave-block-offset))
(`(:after . ";")
- (if (smie-rule-parent-p "classdef" "events" "enumeration" "function" "if"
- "while" "else" "elseif" "for" "parfor"
- "properties" "methods" "otherwise" "case"
- "try" "catch" "unwind_protect"
- "unwind_protect_cleanup")
+ (if (apply #'smie-rule-parent-p octave--block-offset-keywords)
(smie-rule-parent octave-block-offset)
;; For (invalid) code between switch and case.
;; (if (smie-rule-parent-p "switch") 4)
@@ -473,28 +493,33 @@ Non-nil means always go to the next Octave code line
after sending."
(comment-choose-indent)))))
+(defvar octave-reserved-words
+ (delq nil
+ (mapcar (lambda (x)
+ (setq x (car x))
+ (and (stringp x) (string-match "\\`[[:alpha:]]" x) x))
+ octave-smie-grammar))
+ "Reserved words in Octave.")
+
(defvar octave-font-lock-keywords
(list
;; Fontify all builtin keywords.
- (cons (concat "\\_<\\("
- (regexp-opt octave-reserved-words)
- "\\)\\_>")
+ (cons (concat "\\_<" (regexp-opt octave-reserved-words) "\\_>")
'font-lock-keyword-face)
- ;; Note: 'end' also serves as the last index in an indexing expression.
+ ;; Note: 'end' also serves as the last index in an indexing expression,
+ ;; and 'enumerate' is also a function.
;; Ref: http://www.mathworks.com/help/matlab/ref/end.html
+ ;; Ref: http://www.mathworks.com/help/matlab/ref/enumeration.html
(list (lambda (limit)
- (while (re-search-forward "\\_<end\\_>" limit 'move)
+ (while (re-search-forward "\\_<en\\(?:d\\|umeratio\\(n\\)\\)\\_>"
+ limit 'move)
(let ((beg (match-beginning 0))
(end (match-end 0)))
(unless (octave-in-string-or-comment-p)
- (condition-case nil
- (progn
- (goto-char beg)
- (backward-up-list)
- (when (memq (char-after) '(?\( ?\[ ?\{))
- (put-text-property beg end 'face nil))
- (goto-char end))
- (error (goto-char end))))))
+ (when (if (match-end 1)
+ (octave-smie--funcall-p)
+ (octave-smie--end-index-p))
+ (put-text-property beg end 'face nil)))))
nil))
;; Fontify all operators.
(cons octave-operator-regexp 'font-lock-builtin-face)
@@ -609,27 +634,23 @@ Key bindings:
(defcustom inferior-octave-program "octave"
"Program invoked by `inferior-octave'."
- :type 'string
- :group 'octave)
+ :type 'string)
(defcustom inferior-octave-buffer "*Inferior Octave*"
"Name of buffer for running an inferior Octave process."
- :type 'string
- :group 'octave)
+ :type 'string)
(defcustom inferior-octave-prompt
;; For Octave >= 3.8, default is always 'octave', see
;; http://hg.savannah.gnu.org/hgweb/octave/rev/708173343c50
"\\(?:^octave\\(?:.bin\\|.exe\\)?\\(?:-[.0-9]+\\)?\\(?::[0-9]+\\)?\\|^debug\\|^\\)>+
"
"Regexp to match prompts for the inferior Octave process."
- :type 'regexp
- :group 'octave)
+ :type 'regexp)
(defcustom inferior-octave-prompt-read-only comint-prompt-read-only
"If non-nil, the Octave prompt is read only.
See `comint-prompt-read-only' for details."
:type 'boolean
- :group 'octave
:version "24.4")
(defcustom inferior-octave-startup-file
@@ -639,7 +660,6 @@ See `comint-prompt-read-only' for details."
The contents of this file are sent to the inferior Octave process on
startup."
:type '(choice (const :tag "None" nil) file)
- :group 'octave
:version "24.4")
(defcustom inferior-octave-startup-args '("-i" "--no-line-editing")
@@ -647,13 +667,11 @@ startup."
For example, for suppressing the startup message and using `traditional'
mode, include \"-q\" and \"--traditional\"."
:type '(repeat string)
- :group 'octave
:version "24.4")
(defcustom inferior-octave-mode-hook nil
"Hook to be run when Inferior Octave mode is started."
- :type 'hook
- :group 'octave)
+ :type 'hook)
(defcustom inferior-octave-error-regexp-alist
'(("error:\\s-*\\(.*?\\) at line \\([0-9]+\\), column \\([0-9]+\\)"
@@ -663,8 +681,7 @@ mode, include \"-q\" and \"--traditional\"."
"Value for `compilation-error-regexp-alist' in inferior octave."
:version "24.4"
:type '(repeat (choice (symbol :tag "Predefined symbol")
- (sexp :tag "Error specification")))
- :group 'octave)
+ (sexp :tag "Error specification"))))
(defvar inferior-octave-compilation-font-lock-keywords
'(("\\_<PASS\\_>" . compilation-info-face)
@@ -995,7 +1012,6 @@ directory and makes this the current buffer's default
directory."
(defcustom inferior-octave-minimal-columns 80
"The minimal column width for the inferior Octave process."
:type 'integer
- :group 'octave
:version "24.4")
(defvar inferior-octave-last-column-width nil)
@@ -1180,8 +1196,7 @@ q: Don't fix\n" func file))
(defface octave-function-comment-block
'((t (:inherit font-lock-doc-face)))
- "Face used to highlight function comment block."
- :group 'octave)
+ "Face used to highlight function comment block.")
(eval-when-compile (require 'texinfo))
@@ -1602,7 +1617,6 @@ code line."
:type '(choice (const :tag "Automatic" auto)
(const :tag "One Line" oneline)
(const :tag "Multi Line" multiline))
- :group 'octave
:version "24.4")
;; (FN SIGNATURE1 SIGNATURE2 ...)
@@ -1661,7 +1675,6 @@ code line."
(defcustom octave-help-buffer "*Octave Help*"
"Buffer name for `octave-help'."
:type 'string
- :group 'octave
:version "24.4")
;; Used in a mode derived from help-mode.
@@ -1786,7 +1799,6 @@ sentence."
"A list of directories for Octave sources.
If the environment variable OCTAVE_SRCDIR is set, it is searched first."
:type '(repeat directory)
- :group 'octave
:version "24.4")
(defun octave-source-directories ()
diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index f1aa35f..b408509 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -29,7 +29,8 @@
;;; Code:
-(eval-when-compile (require 'cl-lib))
+(eval-when-compile (require 'cl-lib)
+ (require 'subr-x))
(defgroup prog-mode nil
"Generic programming mode, from which others derive."
@@ -161,13 +162,20 @@ Regexp match data 0 points to the chars."
(let ((start (match-beginning 0))
(end (match-end 0))
(match (match-string 0)))
- (if (funcall prettify-symbols-compose-predicate start end match)
+ (if (and (not (equal prettify-symbols--current-symbol-bounds (list start
end)))
+ (funcall prettify-symbols-compose-predicate start end match))
;; That's a symbol alright, so add the composition.
- (compose-region start end (cdr (assoc match alist)))
+ (progn
+ (compose-region start end (cdr (assoc match alist)))
+ (add-text-properties
+ start end
+ `(prettify-symbols-start ,start prettify-symbols-end ,end)))
;; No composition for you. Let's actually remove any
;; composition we may have added earlier and which is now
;; incorrect.
- (remove-text-properties start end '(composition))))
+ (remove-text-properties start end '(composition
+ prettify-symbols-start
+ prettify-symbols-end))))
;; Return nil because we're not adding any face property.
nil)
@@ -179,6 +187,29 @@ Regexp match data 0 points to the chars."
(defvar-local prettify-symbols--keywords nil)
+(defvar-local prettify-symbols--current-symbol-bounds nil)
+
+(defun prettify-symbols--post-command-hook ()
+ (if-let ((c (get-text-property (point) 'composition))
+ (s (get-text-property (point) 'prettify-symbols-start))
+ (e (get-text-property (point) 'prettify-symbols-end)))
+ (progn
+ (setq prettify-symbols--current-symbol-bounds (list s e))
+ (remove-text-properties s e '(composition)))
+ (when (and prettify-symbols--current-symbol-bounds
+ (or (< (point) (car prettify-symbols--current-symbol-bounds))
+ (>= (point) (cadr
prettify-symbols--current-symbol-bounds))))
+ (apply #'font-lock-flush prettify-symbols--current-symbol-bounds)
+ (setq prettify-symbols--current-symbol-bounds nil))))
+
+(defcustom prettify-symbols-unprettify-at-point t
+ "If non-nil, show the non-prettified version of a symbol when point is on it.
+The prettification will be reapplied as soon as point moves away
+from the symbol. If set to nil, the prettification persists even
+when point is on the symbol."
+ :type 'boolean
+ :group 'prog-mode)
+
;;;###autoload
(define-minor-mode prettify-symbols-mode
"Toggle Prettify Symbols mode.
@@ -206,8 +237,12 @@ support it."
(font-lock-add-keywords nil prettify-symbols--keywords)
(setq-local font-lock-extra-managed-props
(cons 'composition font-lock-extra-managed-props))
+ (when prettify-symbols-unprettify-at-point
+ (add-hook 'post-command-hook
+ #'prettify-symbols--post-command-hook nil t))
(font-lock-flush))
;; Turn off
+ (remove-hook 'post-command-hook #'prettify-symbols--post-command-hook t)
(when prettify-symbols--keywords
(font-lock-remove-keywords nil prettify-symbols--keywords)
(setq prettify-symbols--keywords nil))
diff --git a/lisp/progmodes/prolog.el b/lisp/progmodes/prolog.el
index 3d9b0c3..ff2769e 100644
--- a/lisp/progmodes/prolog.el
+++ b/lisp/progmodes/prolog.el
@@ -840,6 +840,8 @@ This is really kludgy, and unneeded (i.e. obsolete) in
Emacs>=24."
(require 'smie)
+(defconst prolog-operator-chars "-\\\\#&*+./:<=>address@hidden")
+
(defun prolog-smie-forward-token ()
;; FIXME: Add support for 0'<char>, if needed after adding it to
;; syntax-propertize-functions.
@@ -848,7 +850,7 @@ This is really kludgy, and unneeded (i.e. obsolete) in
Emacs>=24."
(point)
(progn (cond
((looking-at "[!;]") (forward-char 1))
- ((not (zerop (skip-chars-forward "#&*+-./:<=>address@hidden"))))
+ ((not (zerop (skip-chars-forward prolog-operator-chars))))
((not (zerop (skip-syntax-forward "w_'"))))
;; In case of non-ASCII punctuation.
((not (zerop (skip-syntax-forward ".")))))
@@ -861,8 +863,8 @@ This is really kludgy, and unneeded (i.e. obsolete) in
Emacs>=24."
(buffer-substring-no-properties
(point)
(progn (cond
- ((memq (char-before) '(?! ?\;)) (forward-char -1))
- ((not (zerop (skip-chars-backward "#&*+-./:<=>address@hidden"))))
+ ((memq (char-before) '(?! ?\; ?\,)) (forward-char -1))
+ ((not (zerop (skip-chars-backward prolog-operator-chars))))
((not (zerop (skip-syntax-backward "w_'"))))
;; In case of non-ASCII punctuation.
((not (zerop (skip-syntax-backward ".")))))
@@ -947,12 +949,36 @@ This is really kludgy, and unneeded (i.e. obsolete) in
Emacs>=24."
;; ; c)
;;
;; based on the space between the open paren and the "a".
- (unless (and (smie-rule-parent-p "(")
+ (unless (and (smie-rule-parent-p "(" ";")
(save-excursion
(smie-indent-forward-token)
(smie-backward-sexp 'halfsexp)
- (not (eq ?\( (char-before)))))
+ (if (smie-rule-parent-p "(")
+ (not (eq (char-before) ?\())
+ (smie-indent-backward-token)
+ (smie-rule-bolp))))
prolog-indent-width))
+ (`(:after . ";")
+ ;; Align with same-line comment as in:
+ ;; ; %% Toto
+ ;; foo
+ (and (smie-rule-bolp)
+ (looking-at ";[ \t]*\\(%\\)")
+ (let ((offset (- (save-excursion (goto-char (match-beginning 1))
+ (current-column))
+ (current-column))))
+ ;; Only do it for small offsets, since the comment may actually be
+ ;; an "end-of-line" comment at comment-column!
+ (if (<= offset prolog-indent-width) offset))))
+ (`(:after . ",")
+ ;; Special indent for:
+ ;; foopredicate(x) :- !,
+ ;; toto.
+ (and (eq (char-before) ?!)
+ (save-excursion
+ (smie-indent-backward-token) ;Skip !
+ (equal ":-" (car (smie-indent-backward-token))))
+ (smie-rule-parent prolog-indent-width)))
(`(:after . ,(or `":-" `"-->")) prolog-indent-width)))
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 049c93d..fbb4a90 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1991,9 +1991,30 @@ Does not preserve point."
(t tok)))))))
(defcustom sh-indent-after-continuation t
- "If non-nil, try to make sure text is indented after a line continuation."
- :version "24.3"
- :type 'boolean
+ "If non-nil, indent relative to the continued line's beginning.
+Continued lines can either be indented as \"one long wrapped line\" without
+paying attention to the actual syntactic structure, as in:
+
+ for f \
+ in a; do \
+ toto; \
+ done
+
+or as lines that just don't have implicit semi-colons between them, as in:
+
+ for f \
+ in a; do \
+ toto; \
+ done
+
+With `always' you get the former behavior whereas with nil you get the latter.
+With t, you get the latter as long as that would indent the continuation line
+deeper than the initial line."
+ :version "25.1"
+ :type '(choice
+ (const nil :tag "Never")
+ (const t :tag "Only if needed to make it deeper")
+ (const always :tag "Always"))
:group 'sh-indentation)
(defun sh-smie--continuation-start-indent ()
@@ -2004,24 +2025,49 @@ May return nil if the line should not be treated as
continued."
(unless (sh-smie--looking-back-at-continuation-p)
(current-indentation))))
+(defun sh-smie--indent-continuation ()
+ (cond
+ ((not (and sh-indent-after-continuation
+ (save-excursion
+ (ignore-errors
+ (skip-chars-backward " \t")
+ (sh-smie--looking-back-at-continuation-p)))))
+ nil)
+ ((eq sh-indent-after-continuation 'always)
+ (save-excursion
+ (forward-line -1)
+ (if (sh-smie--looking-back-at-continuation-p)
+ (current-indentation)
+ (+ (current-indentation) sh-indentation))))
+ (t
+ ;; Just make sure a line-continuation is indented deeper.
+ (save-excursion
+ (let ((indent (let ((sh-indent-after-continuation nil))
+ (smie-indent-calculate)))
+ (max most-positive-fixnum))
+ (if (not (numberp indent)) indent
+ (while (progn
+ (forward-line -1)
+ (let ((ci (current-indentation)))
+ (cond
+ ;; Previous line is less indented, we're good.
+ ((< ci indent) nil)
+ ((sh-smie--looking-back-at-continuation-p)
+ (setq max (min max ci))
+ ;; Previous line is itself a continuation.
+ ;; If it's indented like us, we're good, otherwise
+ ;; check the line before that one.
+ (> ci indent))
+ (t ;Previous line is the beginning of the continued line.
+ (setq indent (min (+ ci sh-indentation) max))
+ nil)))))
+ indent))))))
+
(defun sh-smie-sh-rules (kind token)
(pcase (cons kind token)
(`(:elem . basic) sh-indentation)
(`(:after . "case-)") (- (sh-var-value 'sh-indent-for-case-alt)
(sh-var-value 'sh-indent-for-case-label)))
- ((and `(:before . ,_)
- ;; After a line-continuation, make sure the rest is indented.
- (guard sh-indent-after-continuation)
- (guard (save-excursion
- (ignore-errors
- (skip-chars-backward " \t")
- (sh-smie--looking-back-at-continuation-p))))
- (let initial (sh-smie--continuation-start-indent))
- (guard (let* ((sh-indent-after-continuation nil)
- (indent (smie-indent-calculate)))
- (and (numberp indent) (numberp initial)
- (<= indent initial)))))
- `(column . ,(+ initial sh-indentation)))
(`(:before . ,(or `"(" `"{" `"[" "while" "if" "for" "case"))
(if (not (smie-rule-prev-p "&&" "||" "|"))
(when (smie-rule-hanging-p)
@@ -2363,6 +2409,7 @@ Calls the value of `sh-set-shell-hook' if set."
(if (looking-at "[ \t]*\\\\\n")
(goto-char (match-end 0))
(funcall orig))))
+ (add-hook 'smie-indent-functions #'sh-smie--indent-continuation nil
t)
(smie-setup (symbol-value (funcall mksym "grammar"))
(funcall mksym "rules")
:forward-token (funcall mksym "forward-token")
diff --git a/src/macfont.m b/src/macfont.m
index 97a255b..bab9f7c 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -190,6 +190,14 @@ cfstring_create_with_string_noencode (Lisp_Object s)
return string;
}
+static CFIndex
+mac_font_get_weight (CTFontRef font)
+{
+ NSFont *nsFont = (NSFont *) font;
+
+ return [[NSFontManager sharedFontManager] weightOfFont:nsFont];
+}
+
static CGFloat
mac_screen_font_get_advance_width_for_glyph (ScreenFontRef font, CGGlyph glyph)
{
@@ -198,57 +206,53 @@ mac_screen_font_get_advance_width_for_glyph
(ScreenFontRef font, CGGlyph glyph)
return advancement.width;
}
+#if !USE_CT_GLYPH_INFO
static CGGlyph
mac_font_get_glyph_for_cid (CTFontRef font, CTCharacterCollection collection,
CGFontIndex cid)
{
-#if USE_CT_GLYPH_INFO
- return mac_ctfont_get_glyph_for_cid ((CTFontRef) font, collection, cid);
-#else
- {
- CGGlyph result = kCGFontIndexInvalid;
- NSFont *nsFont = (NSFont *) font;
- unichar characters[] = {0xfffd};
- NSString *string =
- [NSString stringWithCharacters:characters
- length:ARRAYELTS (characters)];
- NSGlyphInfo *glyphInfo =
- [NSGlyphInfo glyphInfoWithCharacterIdentifier:cid
- collection:collection
- baseString:string];
- NSDictionary *attributes =
- [NSDictionary dictionaryWithObjectsAndKeys:nsFont,NSFontAttributeName,
- glyphInfo,NSGlyphInfoAttributeName,nil];
- NSTextStorage *textStorage =
- [[NSTextStorage alloc] initWithString:string
- attributes:attributes];
- NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
- NSTextContainer *textContainer = [[NSTextContainer alloc] init];
- NSFont *fontInTextStorage;
-
- [layoutManager addTextContainer:textContainer];
- [textContainer release];
- [textStorage addLayoutManager:layoutManager];
- [layoutManager release];
-
- /* Force layout. */
- (void) [layoutManager glyphRangeForTextContainer:textContainer];
-
- fontInTextStorage = [textStorage attribute:NSFontAttributeName atIndex:0
- effectiveRange:NULL];
- if (fontInTextStorage == nsFont
- || [[fontInTextStorage fontName] isEqualToString:[nsFont fontName]])
- {
- NSGlyph glyph = [layoutManager glyphAtIndex:0];
+ CGGlyph result = kCGFontIndexInvalid;
+ NSFont *nsFont = (NSFont *) font;
+ unichar characters[] = {0xfffd};
+ NSString *string =
+ [NSString stringWithCharacters:characters
+ length:ARRAYELTS (characters)];
+ NSGlyphInfo *glyphInfo =
+ [NSGlyphInfo glyphInfoWithCharacterIdentifier:cid
+ collection:collection
+ baseString:string];
+ NSDictionary *attributes =
+ [NSDictionary dictionaryWithObjectsAndKeys:nsFont,NSFontAttributeName,
+ glyphInfo,NSGlyphInfoAttributeName,nil];
+ NSTextStorage *textStorage =
+ [[NSTextStorage alloc] initWithString:string
+ attributes:attributes];
+ NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
+ NSTextContainer *textContainer = [[NSTextContainer alloc] init];
+ NSFont *fontInTextStorage;
- if (glyph < [nsFont numberOfGlyphs])
- result = glyph;
- }
+ [layoutManager addTextContainer:textContainer];
+ [textContainer release];
+ [textStorage addLayoutManager:layoutManager];
+ [layoutManager release];
- [textStorage release];
+ /* Force layout. */
+ (void) [layoutManager glyphRangeForTextContainer:textContainer];
- return result;
- }
+ fontInTextStorage = [textStorage attribute:NSFontAttributeName atIndex:0
+ effectiveRange:NULL];
+ if (fontInTextStorage == nsFont
+ || [[fontInTextStorage fontName] isEqualToString:[nsFont fontName]])
+ {
+ NSGlyph glyph = [layoutManager glyphAtIndex:0];
+
+ if (glyph < [nsFont numberOfGlyphs])
+ result = glyph;
+ }
+
+ [textStorage release];
+
+ return result;
}
#endif
@@ -762,6 +766,46 @@ cfnumber_get_font_symbolic_traits_value (CFNumberRef
number,
return false;
}
+static CGFloat
+mac_font_descriptor_get_adjusted_weight (CTFontDescriptorRef desc, CGFloat val)
+{
+ long percent_val = lround (val * 100);
+
+ if (percent_val == -40 || percent_val == 56)
+ {
+ CTFontRef font = NULL;
+ CFStringRef name =
+ CTFontDescriptorCopyAttribute (desc, kCTFontNameAttribute);
+
+ if (name)
+ {
+ font = CTFontCreateWithName (name, 0, NULL);
+ CFRelease (name);
+ }
+ if (font)
+ {
+ CFIndex weight = mac_font_get_weight (font);
+
+ if (percent_val == -40)
+ {
+ /* Workaround for crash when displaying Oriya characters
+ with Arial Unicode MS on OS X 10.11. */
+ if (weight == 5)
+ val = 0;
+ }
+ else /* percent_val == 56 */
+ {
+ if (weight == 9)
+ /* Adjustment for HiraginoSans-W7 on OS X 10.11. */
+ val = 0.4;
+ }
+ CFRelease (font);
+ }
+ }
+
+ return val;
+}
+
static void
macfont_store_descriptor_attributes (CTFontDescriptorRef desc,
Lisp_Object spec_or_entity)
@@ -785,6 +829,7 @@ macfont_store_descriptor_attributes (CTFontDescriptorRef
desc,
enum font_property_index index;
CFStringRef trait;
CGPoint points[6];
+ CGFloat (*adjust_func) (CTFontDescriptorRef, CGFloat);
} numeric_traits[] =
{{FONT_WEIGHT_INDEX, kCTFontWeightTrait,
{{-0.4, 50}, /* light */
@@ -792,11 +837,12 @@ macfont_store_descriptor_attributes (CTFontDescriptorRef
desc,
{0, 100}, /* normal */
{0.24, 140}, /* (semi-bold + normal) / 2 */
{0.4, 200}, /* bold */
- {CGFLOAT_MAX, CGFLOAT_MAX}}},
+ {CGFLOAT_MAX, CGFLOAT_MAX}},
+ mac_font_descriptor_get_adjusted_weight},
{FONT_SLANT_INDEX, kCTFontSlantTrait,
- {{0, 100}, {0.1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}},
+ {{0, 100}, {0.1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}, NULL},
{FONT_WIDTH_INDEX, kCTFontWidthTrait,
- {{0, 100}, {1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}}};
+ {{0, 100}, {1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}, NULL}};
int i;
for (i = 0; i < ARRAYELTS (numeric_traits); i++)
@@ -806,6 +852,8 @@ macfont_store_descriptor_attributes (CTFontDescriptorRef
desc,
{
CGPoint *point = numeric_traits[i].points;
+ if (numeric_traits[i].adjust_func)
+ floatval = (*numeric_traits[i].adjust_func) (desc, floatval);
while (point->x < floatval)
point++;
if (point == numeric_traits[i].points)
@@ -3379,18 +3427,24 @@ mac_font_descriptor_supports_languages
(CTFontDescriptorRef descriptor,
result = false;
else
{
- CFIndex desc_languages_count, i, languages_count;
+ CFRange range = CFRangeMake (0, CFArrayGetCount (desc_languages));
+ CFIndex i, languages_count = CFArrayGetCount (languages);
- desc_languages_count = CFArrayGetCount (desc_languages);
- languages_count = CFArrayGetCount (languages);
for (i = 0; i < languages_count; i++)
- if (!CFArrayContainsValue (desc_languages,
- CFRangeMake (0, desc_languages_count),
- CFArrayGetValueAtIndex (languages, i)))
- {
- result = false;
- break;
- }
+ {
+ CFStringRef language = CFArrayGetValueAtIndex (languages, i);
+
+ if (!CFArrayContainsValue (desc_languages, range, language)
+ /* PingFang SC contains "zh" and "zh-Hant" as covered
+ languages, but does not contain "zh-Hans". */
+ && !(CFEqual (language, CFSTR ("zh-Hans"))
+ && CFArrayContainsValue (desc_languages, range,
+ CFSTR ("zh"))))
+ {
+ result = false;
+ break;
+ }
+ }
CFRelease (desc_languages);
}
diff --git a/src/window.c b/src/window.c
index 53543f2..ab85b8c 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1689,8 +1689,10 @@ Return nil if that position is scrolled vertically out
of view. If a
character is only partially visible, nil is returned, unless the
optional argument PARTIALLY is non-nil. If POS is only out of view
because of horizontal scrolling, return non-nil. If POS is t, it
-specifies the position of the last visible glyph in WINDOW. POS
-defaults to point in WINDOW; WINDOW defaults to the selected window.
+specifies the position of either the first position displayed on the
+last visible screen line in WINDOW, or the end-of-buffer position,
+whichever comes first. POS defaults to point in WINDOW; WINDOW defaults
+to the selected window.
If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil,
the return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]),
diff --git a/test/indent/octave.m b/test/indent/octave.m
index a704146..4758f99 100644
--- a/test/indent/octave.m
+++ b/test/indent/octave.m
@@ -1,6 +1,19 @@
## -*- mode: octave; coding: utf-8 -*-
0; # Don't make this a function file
function res = tcomp (fn)
+
+ global x y ...
+ z1 z2
+ persistent x y ...
+ z1 z2
+ global x y = 2 ...
+ z1 z2 # FIXME
+
+ do
+ something
+ until x = ...
+ y
+
%% res = tcomp (fn)
%% imports components and rearranges them.
@@ -10,6 +23,15 @@ function res = tcomp (fn)
data = dlmread(fn, 3, 0);
+ enumeration
+ first (1)
+ second (2)
+ end
+
+ y = enumeration (x); #Beware: "enumeration" can also be a function!
+ y = foo(enumeration (x),
+ 2); #Beware: "enumeration" can also be a function!
+
x = data(:,2:end);
y = 'hello';
z = y';
diff --git a/test/indent/prolog.prolog b/test/indent/prolog.prolog
index 6bf9437..9ac6df1 100644
--- a/test/indent/prolog.prolog
+++ b/test/indent/prolog.prolog
@@ -1,16 +1,18 @@
%% -*- mode: prolog; coding: utf-8; fill-column: 78 -*-
%% bug#21526
-test1 :-
+test21526_1 :-
( a ->
- ( a ->
- b
- ; c
- )
- ; c
+ ( a ->
+ b
+ ; c
+ )
+ ; % Toto
+ c ->
+ d
).
-test2 :-
+test21526_2 :-
( a
-> ( a,
b
@@ -19,7 +21,31 @@ test2 :-
b2
; c1,
c2
- )
+ ).
+
+test21526_3 :-
+ X \= Y,
+ \+ a,
+ b,
+ \+ \+ c,
+ d.
+
+test21526_4 :-
+ ( \+ a ->
+ b
+ ; \+ c,
+ \+ d
+ ).
+
+
+test21526_5 :-
+ (a;
+ b ->
+ c).
+
+test21526_predicate(c) :- !,
+ test_goal1,
+ test_goal2.
%% Testing correct tokenizing.
foo(X) :- 0'= = X.
@@ -74,11 +100,11 @@ subst(X, V, FV, lambda(Y, Ti, Bi), lambda(Y1, To, Bo)) :-
%% If X is equal to Y, X is shadowed, so no subst can take place.
-> Y1 = Y, Bo = Bi
; (member((Y, _), FV)
- %% If Y appears in FV, it can appear in V, so we need to
- %% rename it to avoid name capture.
- -> new_atom(Y, Y1),
- subst(Y, Y1, [], Bi, Bi1)
- ; Y1 = Y, Bi1 = Bi),
+ %% If Y appears in FV, it can appear in V, so we need to
+ %% rename it to avoid name capture.
+ -> new_atom(Y, Y1),
+ subst(Y, Y1, [], Bi, Bi1)
+ ; Y1 = Y, Bi1 = Bi),
%% Perform substitution on the body.
subst(X, V, FV, Bi1, Bo)
).