commit 5283593ced29a2c98e4af3607a68ee7a6d10fcac (HEAD, refs/remotes/origin/master) Author: Martin Rudalics Date: Sun Mar 20 16:52:39 2016 +0100 Resurrect earlier fix of resize_frame_windows * src/window.c (resize_frame_windows): Resurrect earlier fix for calculating the number of columns of the minibuffer window which was lost in subsequent merges. diff --git a/src/window.c b/src/window.c index 3cfb6fc..77a43b7 100644 --- a/src/window.c +++ b/src/window.c @@ -4064,9 +4064,11 @@ values. */) } -/* Resize frame F's windows when number of lines of F is set to SIZE. - HORFLAG means resize windows when number of columns of F is set to - SIZE. PIXELWISE means to interpret SIZE as pixels. */ +/* Resize frame F's windows when F's width or height is set to SIZE. + If HORFLAG is zero, F's width was set to SIZE, otherwise its height + was set. SIZE is interpreted in F's canonical character units + (a.k.a. "columns" or "lines"), unless PIXELWISE is non-zero, which + means to interpret SIZE in pixel units. */ void resize_frame_windows (struct frame *f, int size, bool horflag, bool pixelwise) { @@ -4167,7 +4169,7 @@ resize_frame_windows (struct frame *f, int size, bool horflag, bool pixelwise) m = XWINDOW (mini); if (horflag) { - m->total_cols = size; + m->total_cols = new_size; m->pixel_width = new_pixel_size; } else commit 68f13422042d086b6210a66282169a2dd0974ea3 Author: Lars Magne Ingebrigtsen Date: Sun Mar 20 16:08:55 2016 +0100 Move the cert files to the data directory diff --git a/test/data/net/cert.pem b/test/data/net/cert.pem new file mode 100644 index 0000000..4df4e92 --- /dev/null +++ b/test/data/net/cert.pem @@ -0,0 +1,25 @@ +-----BEGIN CERTIFICATE----- +MIIELTCCAxWgAwIBAgIJAI6LqlFyaPRkMA0GCSqGSIb3DQEBCwUAMIGsMQswCQYD +VQQGEwJBVTEYMBYGA1UECAwPTmV3IFNvdXRoIFdhbGVzMQ8wDQYDVQQHDAZTeWRu +ZXkxITAfBgNVBAoMGEVtYWNzIFRlc3QgU2VydmljZXNzIExMQzESMBAGA1UECwwJ +QXV0b21hdGVkMRcwFQYDVQQDDA50ZXN0LmVtYWNzLnpvdDEiMCAGCSqGSIb3DQEJ +ARYTZW1hY3MtZGV2ZWxAZnNmLm9yZzAeFw0xNjAyMDgwNDA0MzJaFw0xNjAzMDkw +NDA0MzJaMIGsMQswCQYDVQQGEwJBVTEYMBYGA1UECAwPTmV3IFNvdXRoIFdhbGVz +MQ8wDQYDVQQHDAZTeWRuZXkxITAfBgNVBAoMGEVtYWNzIFRlc3QgU2VydmljZXNz +IExMQzESMBAGA1UECwwJQXV0b21hdGVkMRcwFQYDVQQDDA50ZXN0LmVtYWNzLnpv +dDEiMCAGCSqGSIb3DQEJARYTZW1hY3MtZGV2ZWxAZnNmLm9yZzCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAM52lP7k1rBpctBX1irRVgDerxqlFSTkvg8L +WmRCfwm3XY8EZWqM/8Eex5soH7myRlWfUH/cKxbqScZqXotj0hlPxdRkM6gWgHS9 +Mml7wnz2LZGvD5PfMfs+yBHKAMrqortFXCKksHsYIJ66l9gJMm1G5XjWha6CaEr/ +k2bE5Ovw0fB2B4vH0OqhJzGyenJOspXZz1ttn3h3UC5fbDXS8fUM9k/FbgJKypWr +zB3P12GcMR939FsR5sqa8nNoCMw+WBzs4XuM5Ad+s/UtEaZvmtwvLwmdB7cgCEyM +x5gaM969SlpOmuy7dDTCCK3lBl6B5dgFKvVcChYwSW+xJz5tfL0CAwEAAaNQME4w +HQYDVR0OBBYEFG3YhH7ZzEdOGstkT67uUh1RylNjMB8GA1UdIwQYMBaAFG3YhH7Z +zEdOGstkT67uUh1RylNjMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEB +ADnJL2tBMnPepywA57yDfJz54FvrqRd+UAjSiB7/QySDpHnTM3b3sXWfwAkXPTjM +c+jRW2kfdnL6OQW2tpcpPZANGnwK8MJrtGcbHhtPXjgDRhVZp64hsB7ayS+l0Dm7 +2ZBbi2SF8FgZVcQy0WD01ir2raSODo124dMrq+3aHP77YLbiNEKj+wFoDbndQ1FQ +gtIJBE80FADoqc7LnBrpA20aVlfqhKZqe+leYDSZ+CE1iwlPdvD+RTUxVDs5EfpB +qVOHDlzEfVmcMnddKTV8pNYuo93AG4s0KdrGG9RwSvtLaOoHd2i6RmIs+Yiumbau +mXodMxxAEW/cM7Ita/2QVmk= +-----END CERTIFICATE----- diff --git a/test/data/net/key.pem b/test/data/net/key.pem new file mode 100644 index 0000000..5db58f5 --- /dev/null +++ b/test/data/net/key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDOdpT+5NawaXLQ +V9Yq0VYA3q8apRUk5L4PC1pkQn8Jt12PBGVqjP/BHsebKB+5skZVn1B/3CsW6knG +al6LY9IZT8XUZDOoFoB0vTJpe8J89i2Rrw+T3zH7PsgRygDK6qK7RVwipLB7GCCe +upfYCTJtRuV41oWugmhK/5NmxOTr8NHwdgeLx9DqoScxsnpyTrKV2c9bbZ94d1Au +X2w10vH1DPZPxW4CSsqVq8wdz9dhnDEfd/RbEebKmvJzaAjMPlgc7OF7jOQHfrP1 +LRGmb5rcLy8JnQe3IAhMjMeYGjPevUpaTprsu3Q0wgit5QZegeXYBSr1XAoWMElv +sSc+bXy9AgMBAAECggEAaqHkIiGeoE5V9jTncAXeHWTlmyVX3k4luy9p6A5P/nyt +3YevuXBJRzzWatQ2Tno8yUwXD3Ju7s7ie4/EdMmBYYFJ84AtDctRXPm6Z7B7qn6a +2ntH2F+WOOUb/9QMxMCae44/H8VfQLQdZN2KPxHA8Z+ENPzW3mKL6vBE+PcIJLK2 +kTXQdCEIuUb1v4kxKYfjyyHAQ9yHvocUvZdodGHrpmWOr/2QCrqCjwiKnXyvdJMi +JQ4a3dU+JG5Zwr2hScyeLgS4p+M3A2NY+oIACn2rCcsIKC6uvBK3wAbhssaY8z9c +5kap862oMBNmPCxPuQTIIO7ptla0EWHktpFxnu7GIQKBgQDvKyXt82zGHiOZ9acx +4fV7t3NF2MNd9fOn59NYWYRSs2gaEjit6BnsCgiKZOJJ2YFsggBiQMiWuEzwqIdW +bOH8W5AubTxnE2OjeIpH5r8AXI6I/pKdOedM86oeElbL0p53OZqSqBK6vA5SnE76 +fZwC505h/mqH2E6AdKpcyL7sJwKBgQDc/jc4MkVnqF7xcYoJrYEbnkhwqRxIM+0Y +HY2qXszWQPgjae3NK1rw/PEOATzWrHLvRS/utQ8yeLUAZIGsFY8+c1kjvkvl4ZK2 +OnsEOVLmEwjDqqnq3JFYCVSkXfLBGRD3wGldzkCQljOiGuJ/Co1rGHk7CfBmxX2p +kxdts5OKewKBgQDTRsSc7Zs7cMh2a0GlmTyoa6iTHSeIy4rQ2sQimgGApSfjUBFt +30l28G4XA4O7RT9FwZnhMeWA75JYTigwOsNvkNtPiAQB8mjksclGNxqnkRwA/RI7 +fjlMCzxOkFjIeWivXd2kjIDvIM1uQNKsCWZWUks12e/1zSmb5HPSvyuZpQKBgQDQ +qVgKP604ysmav9HOgXy+Tx2nAoYpxp2/f2gbzZcrVfz1szdN2fnsQWh6CMEhEYMU +WQeBJIRM65w72qp1iYXPOaqZDT0suWiFl4I/4sBbbO2BkssNb2Xs8iJxcCOeH8Td +qVfTssNTwf7OuQPTYGtXC6ysCh5ra13Tl4cvlbdhsQKBgFHXP+919wSncLS+2ySD +waBzG6GyVOgV+FE3DrM3Xp4S6fldWYAndKHQ1HjJVDY8SkC2Tk1D7QSQnmS+ZzYs +YqzcnkPCTHLb6wCErs4ZiW0gn9xJnfxyv6wPujsayL4TMsmsqkj/IAB61UjwaA/a +Z+rUw/WkcNPD59AD1J0eeSZu +-----END PRIVATE KEY----- diff --git a/test/lisp/net/cert.pem b/test/lisp/net/cert.pem deleted file mode 100644 index 4df4e92..0000000 --- a/test/lisp/net/cert.pem +++ /dev/null @@ -1,25 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIELTCCAxWgAwIBAgIJAI6LqlFyaPRkMA0GCSqGSIb3DQEBCwUAMIGsMQswCQYD -VQQGEwJBVTEYMBYGA1UECAwPTmV3IFNvdXRoIFdhbGVzMQ8wDQYDVQQHDAZTeWRu -ZXkxITAfBgNVBAoMGEVtYWNzIFRlc3QgU2VydmljZXNzIExMQzESMBAGA1UECwwJ -QXV0b21hdGVkMRcwFQYDVQQDDA50ZXN0LmVtYWNzLnpvdDEiMCAGCSqGSIb3DQEJ -ARYTZW1hY3MtZGV2ZWxAZnNmLm9yZzAeFw0xNjAyMDgwNDA0MzJaFw0xNjAzMDkw -NDA0MzJaMIGsMQswCQYDVQQGEwJBVTEYMBYGA1UECAwPTmV3IFNvdXRoIFdhbGVz -MQ8wDQYDVQQHDAZTeWRuZXkxITAfBgNVBAoMGEVtYWNzIFRlc3QgU2VydmljZXNz -IExMQzESMBAGA1UECwwJQXV0b21hdGVkMRcwFQYDVQQDDA50ZXN0LmVtYWNzLnpv -dDEiMCAGCSqGSIb3DQEJARYTZW1hY3MtZGV2ZWxAZnNmLm9yZzCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAM52lP7k1rBpctBX1irRVgDerxqlFSTkvg8L -WmRCfwm3XY8EZWqM/8Eex5soH7myRlWfUH/cKxbqScZqXotj0hlPxdRkM6gWgHS9 -Mml7wnz2LZGvD5PfMfs+yBHKAMrqortFXCKksHsYIJ66l9gJMm1G5XjWha6CaEr/ -k2bE5Ovw0fB2B4vH0OqhJzGyenJOspXZz1ttn3h3UC5fbDXS8fUM9k/FbgJKypWr -zB3P12GcMR939FsR5sqa8nNoCMw+WBzs4XuM5Ad+s/UtEaZvmtwvLwmdB7cgCEyM -x5gaM969SlpOmuy7dDTCCK3lBl6B5dgFKvVcChYwSW+xJz5tfL0CAwEAAaNQME4w -HQYDVR0OBBYEFG3YhH7ZzEdOGstkT67uUh1RylNjMB8GA1UdIwQYMBaAFG3YhH7Z -zEdOGstkT67uUh1RylNjMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEB -ADnJL2tBMnPepywA57yDfJz54FvrqRd+UAjSiB7/QySDpHnTM3b3sXWfwAkXPTjM -c+jRW2kfdnL6OQW2tpcpPZANGnwK8MJrtGcbHhtPXjgDRhVZp64hsB7ayS+l0Dm7 -2ZBbi2SF8FgZVcQy0WD01ir2raSODo124dMrq+3aHP77YLbiNEKj+wFoDbndQ1FQ -gtIJBE80FADoqc7LnBrpA20aVlfqhKZqe+leYDSZ+CE1iwlPdvD+RTUxVDs5EfpB -qVOHDlzEfVmcMnddKTV8pNYuo93AG4s0KdrGG9RwSvtLaOoHd2i6RmIs+Yiumbau -mXodMxxAEW/cM7Ita/2QVmk= ------END CERTIFICATE----- diff --git a/test/lisp/net/key.pem b/test/lisp/net/key.pem deleted file mode 100644 index 5db58f5..0000000 --- a/test/lisp/net/key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDOdpT+5NawaXLQ -V9Yq0VYA3q8apRUk5L4PC1pkQn8Jt12PBGVqjP/BHsebKB+5skZVn1B/3CsW6knG -al6LY9IZT8XUZDOoFoB0vTJpe8J89i2Rrw+T3zH7PsgRygDK6qK7RVwipLB7GCCe -upfYCTJtRuV41oWugmhK/5NmxOTr8NHwdgeLx9DqoScxsnpyTrKV2c9bbZ94d1Au -X2w10vH1DPZPxW4CSsqVq8wdz9dhnDEfd/RbEebKmvJzaAjMPlgc7OF7jOQHfrP1 -LRGmb5rcLy8JnQe3IAhMjMeYGjPevUpaTprsu3Q0wgit5QZegeXYBSr1XAoWMElv -sSc+bXy9AgMBAAECggEAaqHkIiGeoE5V9jTncAXeHWTlmyVX3k4luy9p6A5P/nyt -3YevuXBJRzzWatQ2Tno8yUwXD3Ju7s7ie4/EdMmBYYFJ84AtDctRXPm6Z7B7qn6a -2ntH2F+WOOUb/9QMxMCae44/H8VfQLQdZN2KPxHA8Z+ENPzW3mKL6vBE+PcIJLK2 -kTXQdCEIuUb1v4kxKYfjyyHAQ9yHvocUvZdodGHrpmWOr/2QCrqCjwiKnXyvdJMi -JQ4a3dU+JG5Zwr2hScyeLgS4p+M3A2NY+oIACn2rCcsIKC6uvBK3wAbhssaY8z9c -5kap862oMBNmPCxPuQTIIO7ptla0EWHktpFxnu7GIQKBgQDvKyXt82zGHiOZ9acx -4fV7t3NF2MNd9fOn59NYWYRSs2gaEjit6BnsCgiKZOJJ2YFsggBiQMiWuEzwqIdW -bOH8W5AubTxnE2OjeIpH5r8AXI6I/pKdOedM86oeElbL0p53OZqSqBK6vA5SnE76 -fZwC505h/mqH2E6AdKpcyL7sJwKBgQDc/jc4MkVnqF7xcYoJrYEbnkhwqRxIM+0Y -HY2qXszWQPgjae3NK1rw/PEOATzWrHLvRS/utQ8yeLUAZIGsFY8+c1kjvkvl4ZK2 -OnsEOVLmEwjDqqnq3JFYCVSkXfLBGRD3wGldzkCQljOiGuJ/Co1rGHk7CfBmxX2p -kxdts5OKewKBgQDTRsSc7Zs7cMh2a0GlmTyoa6iTHSeIy4rQ2sQimgGApSfjUBFt -30l28G4XA4O7RT9FwZnhMeWA75JYTigwOsNvkNtPiAQB8mjksclGNxqnkRwA/RI7 -fjlMCzxOkFjIeWivXd2kjIDvIM1uQNKsCWZWUks12e/1zSmb5HPSvyuZpQKBgQDQ -qVgKP604ysmav9HOgXy+Tx2nAoYpxp2/f2gbzZcrVfz1szdN2fnsQWh6CMEhEYMU -WQeBJIRM65w72qp1iYXPOaqZDT0suWiFl4I/4sBbbO2BkssNb2Xs8iJxcCOeH8Td -qVfTssNTwf7OuQPTYGtXC6ysCh5ra13Tl4cvlbdhsQKBgFHXP+919wSncLS+2ySD -waBzG6GyVOgV+FE3DrM3Xp4S6fldWYAndKHQ1HjJVDY8SkC2Tk1D7QSQnmS+ZzYs -YqzcnkPCTHLb6wCErs4ZiW0gn9xJnfxyv6wPujsayL4TMsmsqkj/IAB61UjwaA/a -Z+rUw/WkcNPD59AD1J0eeSZu ------END PRIVATE KEY----- diff --git a/test/lisp/net/network-stream-tests.el b/test/lisp/net/network-stream-tests.el index dbbf40b..91cc8b9 100644 --- a/test/lisp/net/network-stream-tests.el +++ b/test/lisp/net/network-stream-tests.el @@ -158,8 +158,8 @@ (defun make-tls-server (port) (start-process "gnutls" (generate-new-buffer "*tls*") "gnutls-serv" "--http" - "--x509keyfile" "lisp/net/key.pem" - "--x509certfile" "lisp/net/cert.pem" + "--x509keyfile" "data/net/key.pem" + "--x509certfile" "data/net/cert.pem" "--port" (format "%s" port))) (ert-deftest connect-to-tls-ipv4-wait () commit 78bcd428573f4eed83bf143d296fbd38a3ffd71e Author: Lars Magne Ingebrigtsen Date: Sun Mar 20 15:15:32 2016 +0100 Further empty
  • tweaks * lisp/net/shr.el (shr-tag-li): When showing several empty
  • elements, ensure that they really get inserted on a new line. diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 4adb4a6..6079415 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -1617,7 +1617,9 @@ The preference is a float determined from `shr-prefer-media-type'." (put-text-property start (1+ start) 'shr-continuation-indentation shr-indentation) (put-text-property start (1+ start) 'shr-prefix-length (length bullet)) - (shr-generic dom))))) + (shr-generic dom)))) + (unless (bolp) + (insert "\n"))) (defun shr-mark-fill (start) ;; We may not have inserted any text to fill. diff --git a/test/data/shr/li-empty.html b/test/data/shr/li-empty.html new file mode 100644 index 0000000..05cfee7 --- /dev/null +++ b/test/data/shr/li-empty.html @@ -0,0 +1 @@ +
    diff --git a/test/data/shr/li-empty.txt b/test/data/shr/li-empty.txt new file mode 100644 index 0000000..8320bc0 --- /dev/null +++ b/test/data/shr/li-empty.txt @@ -0,0 +1,3 @@ +1 +2 +3 commit 61b2e837d8eefcba7ae8dbe442a818f05d5ed6f0 Author: Lars Magne Ingebrigtsen Date: Sun Mar 20 14:47:22 2016 +0100 Don't remove too much white space at the end of documents * lisp/net/shr.el (shr--remove-blank-lines-at-the-end): Don't remove too much white space -- leave it on the last line (in case there's a background color). diff --git a/lisp/net/shr.el b/lisp/net/shr.el index cd55f22..4adb4a6 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -281,15 +281,12 @@ DOM should be a parse tree as generated by (defun shr--remove-blank-lines-at-the-end (start end) (save-restriction (save-excursion - (current-buffer) (narrow-to-region start end) (goto-char end) (when (and (re-search-backward "[^ \n]" nil t) (not (eobp))) - (forward-char 1) - (delete-region (point) (point-max)) - (unless (bolp) - (insert "\n")))))) + (forward-line 1) + (delete-region (point) (point-max)))))) (defun shr-copy-url (&optional image-url) "Copy the URL under point to the kill ring. diff --git a/test/data/shr/ul-empty.txt b/test/data/shr/ul-empty.txt index acb41c4..8993555 100644 --- a/test/data/shr/ul-empty.txt +++ b/test/data/shr/ul-empty.txt @@ -1,3 +1,3 @@ * -Lala +Lala \ No newline at end of file commit 9dcf5998935c8aaa846d7585b81f0dcfe1935b3d Author: Alan Mackenzie Date: Sun Mar 20 13:19:48 2016 +0000 Amend parse-partial-sexp correctly to handle two character comment delimiters Do this by adding a new field to the parser state: the syntax of the last character scanned, should that be the first char of a (potential) two char construct, nil otherwise. This should make the parser state complete. Also document element 9 of the parser state. Also refactor the code a bit. * src/syntax.c (struct lisp_parse_state): Add a new field. (SYNTAX_FLAGS_COMSTARTEND_FIRST): New function. (internalize_parse_state): New function, extracted from scan_sexps_forward. (back_comment): Call internalize_parse_state. (forw_comment): Return the syntax of the last character scanned to the caller when that character might be the first of a two character construct. (Fforward_comment, scan_lists): New dummy variables, passed to forw_comment. (scan_sexps_forward): Remove a redundant state parameter. Access all `state' information via the address parameter `state'. Remove the code which converts from external to internal form of `state'. Access buffer contents only from `from' onwards. Reformulate code at the top of the main loop correctly to recognize comment openers when starting in the middle of one. Call forw_comment with extra argument (for return of syntax value of possible first char of a two char construct). (Fparse_partial_sexp): Document elements 9, 10 of the parser state in the doc string. Clarify the doc string in general. Call internalize_parse_state. Take account of the new elements when consing up the output parser state. * doc/lispref/syntax.texi: (Parser State): Document element 9 and the new element 10. Minor wording corrections (remove reference to "trivial cases"). (Low Level Parsing): Minor corrections. * etc/NEWS: Note new element 10, and documentation of element 9 of parser state. diff --git a/doc/lispref/syntax.texi b/doc/lispref/syntax.texi index d5a7eba..f81c164 100644 --- a/doc/lispref/syntax.texi +++ b/doc/lispref/syntax.texi @@ -791,10 +791,10 @@ Hooks}). @subsection Parser State @cindex parser state - A @dfn{parser state} is a list of ten elements describing the state -of the syntactic parser, after it parses the text between a specified -starting point and a specified end point in the buffer. Parsing -functions such as @code{syntax-ppss} + A @dfn{parser state} is a list of (currently) eleven elements +describing the state of the syntactic parser, after it parses the text +between a specified starting point and a specified end point in the +buffer. Parsing functions such as @code{syntax-ppss} @ifnottex (@pxref{Position Parse}) @end ifnottex @@ -851,15 +851,20 @@ position where the string began. When outside of strings and comments, this element is @code{nil}. @item -Internal data for continuing the parsing. The meaning of this -data is subject to change; it is used if you pass this list -as the @var{state} argument to another call. +The list of the positions of the currently open parentheses, starting +with the outermost. + +@item +When the last buffer position scanned was the (potential) first +character of a two character construct (comment delimiter or +escaped/char-quoted character pair), the @var{syntax-code} +(@pxref{Syntax Table Internals}) of that position. Otherwise +@code{nil}. @end enumerate Elements 1, 2, and 6 are ignored in a state which you pass as an -argument to continue parsing, and elements 8 and 9 are used only in -trivial cases. Those elements are mainly used internally by the -parser code. +argument to continue parsing. Elements 9 and 10 are mainly used +internally by the parser code. One additional piece of useful information is available from a parser state using this function: @@ -898,11 +903,11 @@ The depth starts at 0, or at whatever is given in @var{state}. If the fourth argument @var{stop-before} is non-@code{nil}, parsing stops when it comes to any character that starts a sexp. If -@var{stop-comment} is non-@code{nil}, parsing stops when it comes to the -start of an unnested comment. If @var{stop-comment} is the symbol +@var{stop-comment} is non-@code{nil}, parsing stops after the start of +an unnested comment. If @var{stop-comment} is the symbol @code{syntax-table}, parsing stops after the start of an unnested -comment or a string, or the end of an unnested comment or a string, -whichever comes first. +comment or a string, or after the end of an unnested comment or a +string, whichever comes first. If @var{state} is @code{nil}, @var{start} is assumed to be at the top level of parenthesis structure, such as the beginning of a function diff --git a/etc/NEWS b/etc/NEWS index d963dee..ea32153 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -175,6 +175,18 @@ a new window when opening man pages when there's already one, use (inhibit-same-window . nil) (mode . Man-mode)))) ++++ +** `parse-partial-sexp' state has a new element. Element 10 is +non-nil when the last character scanned might be the first character +of a two character construct, i.e. a comment delimiter or escaped +character. Its value is the syntax of that last character. + ++++ +** `parse-partial-sexp''s state, element 9, has now been confirmed as +permanent and documented, and may be used by Lisp programs. Its value +is a list of currently open parenthesis positions, starting with the +outermost parenthesis. + * Changes in Emacs 25.2 on Non-Free Operating Systems diff --git a/src/syntax.c b/src/syntax.c index fdcfdfc..ffe0ea5 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -81,6 +81,11 @@ SYNTAX_FLAGS_COMEND_SECOND (int flags) return (flags >> 19) & 1; } static bool +SYNTAX_FLAGS_COMSTARTEND_FIRST (int flags) +{ + return (flags & 0x50000) != 0; +} +static bool SYNTAX_FLAGS_PREFIX (int flags) { return (flags >> 20) & 1; @@ -153,6 +158,10 @@ struct lisp_parse_state ptrdiff_t comstr_start; /* Position of last comment/string starter. */ Lisp_Object levelstarts; /* Char numbers of starts-of-expression of levels (starting from outermost). */ + int prev_syntax; /* Syntax of previous position scanned, when + that position (potentially) holds the first char + of a 2-char construct, i.e. comment delimiter + or Sescape, etc. Smax otherwise. */ }; /* These variables are a cache for finding the start of a defun. @@ -176,7 +185,8 @@ static Lisp_Object skip_syntaxes (bool, Lisp_Object, Lisp_Object); static Lisp_Object scan_lists (EMACS_INT, EMACS_INT, EMACS_INT, bool); static void scan_sexps_forward (struct lisp_parse_state *, ptrdiff_t, ptrdiff_t, ptrdiff_t, EMACS_INT, - bool, Lisp_Object, int); + bool, int); +static void internalize_parse_state (Lisp_Object, struct lisp_parse_state *); static bool in_classes (int, Lisp_Object); static void parse_sexp_propertize (ptrdiff_t charpos); @@ -911,10 +921,11 @@ back_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, } do { + internalize_parse_state (Qnil, &state); scan_sexps_forward (&state, defun_start, defun_start_byte, comment_end, TYPE_MINIMUM (EMACS_INT), - 0, Qnil, 0); + 0, 0); defun_start = comment_end; if (!adjusted) { @@ -2310,11 +2321,15 @@ in_classes (int c, Lisp_Object iso_classes) PREV_SYNTAX is the SYNTAX_WITH_FLAGS of the previous character (or 0 If the search cannot start in the middle of a two-character). - If successful, return true and store the charpos of the comment's end - into *CHARPOS_PTR and the corresponding bytepos into *BYTEPOS_PTR. - Else, return false and store the charpos STOP into *CHARPOS_PTR, the - corresponding bytepos into *BYTEPOS_PTR and the current nesting - (as defined for state.incomment) in *INCOMMENT_PTR. + If successful, return true and store the charpos of the comment's + end into *CHARPOS_PTR and the corresponding bytepos into + *BYTEPOS_PTR. Else, return false and store the charpos STOP into + *CHARPOS_PTR, the corresponding bytepos into *BYTEPOS_PTR and the + current nesting (as defined for state->incomment) in + *INCOMMENT_PTR. Should the last character scanned in an incomplete + comment be a possible first character of a two character construct, + we store its SYNTAX_WITH_FLAGS into *last_syntax_ptr. Otherwise, + we store Smax into *last_syntax_ptr. The comment end is the last character of the comment rather than the character just after the comment. @@ -2326,7 +2341,7 @@ static bool forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, EMACS_INT nesting, int style, int prev_syntax, ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr, - EMACS_INT *incomment_ptr) + EMACS_INT *incomment_ptr, int *last_syntax_ptr) { register int c, c1; register enum syntaxcode code; @@ -2337,7 +2352,8 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, /* Enter the loop in the middle so that we find a 2-char comment ender if we start in the middle of it. */ syntax = prev_syntax; - if (syntax != 0) goto forw_incomment; + code = syntax & 0xff; + if (syntax != 0 && from < stop) goto forw_incomment; while (1) { @@ -2346,6 +2362,12 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, *incomment_ptr = nesting; *charpos_ptr = from; *bytepos_ptr = from_byte; + *last_syntax_ptr = + (code == Sescape || code == Scharquote + || SYNTAX_FLAGS_COMEND_FIRST (syntax) + || (nesting > 0 + && SYNTAX_FLAGS_COMSTART_FIRST (syntax))) + ? syntax : Smax ; return 0; } c = FETCH_CHAR_AS_MULTIBYTE (from_byte); @@ -2386,7 +2408,9 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, SYNTAX_FLAGS_COMMENT_NESTED (other_syntax)) ? nesting > 0 : nesting < 0)) { - if (--nesting <= 0) + syntax = Smax; /* So that "|#" (lisp) can not return + the syntax of "#" in *last_syntax_ptr. */ + if (--nesting <= 0) /* We have encountered a comment end of the same style as the comment sequence which began this comment section. */ break; @@ -2408,6 +2432,7 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, /* We have encountered a nested comment of the same style as the comment sequence which began this comment section. */ { + syntax = Smax; /* So that "#|#" isn't also a comment ender. */ INC_BOTH (from, from_byte); UPDATE_SYNTAX_TABLE_FORWARD (from); nesting++; @@ -2415,6 +2440,8 @@ forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop, } *charpos_ptr = from; *bytepos_ptr = from_byte; + *last_syntax_ptr = Smax; /* Any syntactic power the last byte had is + used up. */ return 1; } @@ -2436,6 +2463,7 @@ between them, return t; otherwise return nil. */) EMACS_INT count1; ptrdiff_t out_charpos, out_bytepos; EMACS_INT dummy; + int dummy2; CHECK_NUMBER (count); count1 = XINT (count); @@ -2499,7 +2527,7 @@ between them, return t; otherwise return nil. */) } /* We're at the start of a comment. */ found = forw_comment (from, from_byte, stop, comnested, comstyle, 0, - &out_charpos, &out_bytepos, &dummy); + &out_charpos, &out_bytepos, &dummy, &dummy2); from = out_charpos; from_byte = out_bytepos; if (!found) { @@ -2659,6 +2687,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) ptrdiff_t from_byte; ptrdiff_t out_bytepos, out_charpos; EMACS_INT dummy; + int dummy2; bool multibyte_symbol_p = sexpflag && multibyte_syntax_as_symbol; if (depth > 0) min_depth = 0; @@ -2755,7 +2784,8 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) UPDATE_SYNTAX_TABLE_FORWARD (from); found = forw_comment (from, from_byte, stop, comnested, comstyle, 0, - &out_charpos, &out_bytepos, &dummy); + &out_charpos, &out_bytepos, &dummy, + &dummy2); from = out_charpos, from_byte = out_bytepos; if (!found) { @@ -3119,7 +3149,7 @@ the prefix syntax flag (p). */) } /* Parse forward from FROM / FROM_BYTE to END, - assuming that FROM has state OLDSTATE (nil means FROM is start of function), + assuming that FROM has state STATE, and return a description of the state of the parse at END. If STOPBEFORE, stop at the start of an atom. If COMMENTSTOP is 1, stop at the start of a comment. @@ -3127,12 +3157,11 @@ the prefix syntax flag (p). */) after the beginning of a string, or after the end of a string. */ static void -scan_sexps_forward (struct lisp_parse_state *stateptr, +scan_sexps_forward (struct lisp_parse_state *state, ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t end, EMACS_INT targetdepth, bool stopbefore, - Lisp_Object oldstate, int commentstop) + int commentstop) { - struct lisp_parse_state state; enum syntaxcode code; int c1; bool comnested; @@ -3148,7 +3177,7 @@ scan_sexps_forward (struct lisp_parse_state *stateptr, Lisp_Object tem; ptrdiff_t prev_from; /* Keep one character before FROM. */ ptrdiff_t prev_from_byte; - int prev_from_syntax; + int prev_from_syntax, prev_prev_from_syntax; bool boundary_stop = commentstop == -1; bool nofence; bool found; @@ -3165,6 +3194,7 @@ scan_sexps_forward (struct lisp_parse_state *stateptr, do { prev_from = from; \ prev_from_byte = from_byte; \ temp = FETCH_CHAR_AS_MULTIBYTE (prev_from_byte); \ + prev_prev_from_syntax = prev_from_syntax; \ prev_from_syntax = SYNTAX_WITH_FLAGS (temp); \ INC_BOTH (from, from_byte); \ if (from < end) \ @@ -3174,88 +3204,38 @@ do { prev_from = from; \ immediate_quit = 1; QUIT; - if (NILP (oldstate)) - { - depth = 0; - state.instring = -1; - state.incomment = 0; - state.comstyle = 0; /* comment style a by default. */ - state.comstr_start = -1; /* no comment/string seen. */ - } - else - { - tem = Fcar (oldstate); - if (!NILP (tem)) - depth = XINT (tem); - else - depth = 0; - - oldstate = Fcdr (oldstate); - oldstate = Fcdr (oldstate); - oldstate = Fcdr (oldstate); - tem = Fcar (oldstate); - /* Check whether we are inside string_fence-style string: */ - state.instring = (!NILP (tem) - ? (CHARACTERP (tem) ? XFASTINT (tem) : ST_STRING_STYLE) - : -1); - - oldstate = Fcdr (oldstate); - tem = Fcar (oldstate); - state.incomment = (!NILP (tem) - ? (INTEGERP (tem) ? XINT (tem) : -1) - : 0); - - oldstate = Fcdr (oldstate); - tem = Fcar (oldstate); - start_quoted = !NILP (tem); + depth = state->depth; + start_quoted = state->quoted; + prev_prev_from_syntax = Smax; + prev_from_syntax = state->prev_syntax; - /* if the eighth element of the list is nil, we are in comment - style a. If it is non-nil, we are in comment style b */ - oldstate = Fcdr (oldstate); - oldstate = Fcdr (oldstate); - tem = Fcar (oldstate); - state.comstyle = (NILP (tem) - ? 0 - : (RANGED_INTEGERP (0, tem, ST_COMMENT_STYLE) - ? XINT (tem) - : ST_COMMENT_STYLE)); - - oldstate = Fcdr (oldstate); - tem = Fcar (oldstate); - state.comstr_start = - RANGED_INTEGERP (PTRDIFF_MIN, tem, PTRDIFF_MAX) ? XINT (tem) : -1; - oldstate = Fcdr (oldstate); - tem = Fcar (oldstate); - while (!NILP (tem)) /* >= second enclosing sexps. */ - { - Lisp_Object temhd = Fcar (tem); - if (RANGED_INTEGERP (PTRDIFF_MIN, temhd, PTRDIFF_MAX)) - curlevel->last = XINT (temhd); - if (++curlevel == endlevel) - curlevel--; /* error ("Nesting too deep for parser"); */ - curlevel->prev = -1; - curlevel->last = -1; - tem = Fcdr (tem); - } + tem = state->levelstarts; + while (!NILP (tem)) /* >= second enclosing sexps. */ + { + Lisp_Object temhd = Fcar (tem); + if (RANGED_INTEGERP (PTRDIFF_MIN, temhd, PTRDIFF_MAX)) + curlevel->last = XINT (temhd); + if (++curlevel == endlevel) + curlevel--; /* error ("Nesting too deep for parser"); */ + curlevel->prev = -1; + curlevel->last = -1; + tem = Fcdr (tem); } - state.quoted = 0; - mindepth = depth; - curlevel->prev = -1; curlevel->last = -1; - SETUP_SYNTAX_TABLE (prev_from, 1); - temp = FETCH_CHAR (prev_from_byte); - prev_from_syntax = SYNTAX_WITH_FLAGS (temp); - UPDATE_SYNTAX_TABLE_FORWARD (from); + state->quoted = 0; + mindepth = depth; + + SETUP_SYNTAX_TABLE (from, 1); /* Enter the loop at a place appropriate for initial state. */ - if (state.incomment) + if (state->incomment) goto startincomment; - if (state.instring >= 0) + if (state->instring >= 0) { - nofence = state.instring != ST_STRING_STYLE; + nofence = state->instring != ST_STRING_STYLE; if (start_quoted) goto startquotedinstring; goto startinstring; @@ -3266,11 +3246,8 @@ do { prev_from = from; \ while (from < end) { int syntax; - INC_FROM; - code = prev_from_syntax & 0xff; - if (from < end - && SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax) + if (SYNTAX_FLAGS_COMSTART_FIRST (prev_from_syntax) && (c1 = FETCH_CHAR (from_byte), syntax = SYNTAX_WITH_FLAGS (c1), SYNTAX_FLAGS_COMSTART_SECOND (syntax))) @@ -3280,32 +3257,39 @@ do { prev_from = from; \ /* Record the comment style we have entered so that only the comment-end sequence of the same style actually terminates the comment section. */ - state.comstyle + state->comstyle = SYNTAX_FLAGS_COMMENT_STYLE (syntax, prev_from_syntax); comnested = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) | SYNTAX_FLAGS_COMMENT_NESTED (syntax)); - state.incomment = comnested ? 1 : -1; - state.comstr_start = prev_from; + state->incomment = comnested ? 1 : -1; + state->comstr_start = prev_from; INC_FROM; + prev_from_syntax = Smax; /* the syntax has already been + "used up". */ code = Scomment; } - else if (code == Scomment_fence) - { - /* Record the comment style we have entered so that only - the comment-end sequence of the same style actually - terminates the comment section. */ - state.comstyle = ST_COMMENT_STYLE; - state.incomment = -1; - state.comstr_start = prev_from; - code = Scomment; - } - else if (code == Scomment) - { - state.comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax, 0); - state.incomment = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) ? - 1 : -1); - state.comstr_start = prev_from; - } + else + { + INC_FROM; + code = prev_from_syntax & 0xff; + if (code == Scomment_fence) + { + /* Record the comment style we have entered so that only + the comment-end sequence of the same style actually + terminates the comment section. */ + state->comstyle = ST_COMMENT_STYLE; + state->incomment = -1; + state->comstr_start = prev_from; + code = Scomment; + } + else if (code == Scomment) + { + state->comstyle = SYNTAX_FLAGS_COMMENT_STYLE (prev_from_syntax, 0); + state->incomment = (SYNTAX_FLAGS_COMMENT_NESTED (prev_from_syntax) ? + 1 : -1); + state->comstr_start = prev_from; + } + } if (SYNTAX_FLAGS_PREFIX (prev_from_syntax)) continue; @@ -3350,26 +3334,28 @@ do { prev_from = from; \ case Scomment_fence: /* Can't happen because it's handled above. */ case Scomment: - if (commentstop || boundary_stop) goto done; + if (commentstop || boundary_stop) goto done; startincomment: /* The (from == BEGV) test was to enter the loop in the middle so that we find a 2-char comment ender even if we start in the middle of it. We don't want to do that if we're just at the beginning of the comment (think of (*) ... (*)). */ found = forw_comment (from, from_byte, end, - state.incomment, state.comstyle, - (from == BEGV || from < state.comstr_start + 3) - ? 0 : prev_from_syntax, - &out_charpos, &out_bytepos, &state.incomment); + state->incomment, state->comstyle, + from == BEGV ? 0 : prev_from_syntax, + &out_charpos, &out_bytepos, &state->incomment, + &prev_from_syntax); from = out_charpos; from_byte = out_bytepos; - /* Beware! prev_from and friends are invalid now. - Luckily, the `done' doesn't use them and the INC_FROM - sets them to a sane value without looking at them. */ + /* Beware! prev_from and friends (except prev_from_syntax) + are invalid now. Luckily, the `done' doesn't use them + and the INC_FROM sets them to a sane value without + looking at them. */ if (!found) goto done; INC_FROM; - state.incomment = 0; - state.comstyle = 0; /* reset the comment style */ - if (boundary_stop) goto done; + state->incomment = 0; + state->comstyle = 0; /* reset the comment style */ + prev_from_syntax = Smax; /* For the comment closer */ + if (boundary_stop) goto done; break; case Sopen: @@ -3396,16 +3382,16 @@ do { prev_from = from; \ case Sstring: case Sstring_fence: - state.comstr_start = from - 1; + state->comstr_start = from - 1; if (stopbefore) goto stop; /* this arg means stop at sexp start */ curlevel->last = prev_from; - state.instring = (code == Sstring + state->instring = (code == Sstring ? (FETCH_CHAR_AS_MULTIBYTE (prev_from_byte)) : ST_STRING_STYLE); if (boundary_stop) goto done; startinstring: { - nofence = state.instring != ST_STRING_STYLE; + nofence = state->instring != ST_STRING_STYLE; while (1) { @@ -3419,7 +3405,7 @@ do { prev_from = from; \ /* Check C_CODE here so that if the char has a syntax-table property which says it is NOT a string character, it does not end the string. */ - if (nofence && c == state.instring && c_code == Sstring) + if (nofence && c == state->instring && c_code == Sstring) break; switch (c_code) @@ -3442,7 +3428,7 @@ do { prev_from = from; \ } } string_end: - state.instring = -1; + state->instring = -1; curlevel->prev = curlevel->last; INC_FROM; if (boundary_stop) goto done; @@ -3461,25 +3447,96 @@ do { prev_from = from; \ stop: /* Here if stopping before start of sexp. */ from = prev_from; /* We have just fetched the char that starts it; */ from_byte = prev_from_byte; + prev_from_syntax = prev_prev_from_syntax; goto done; /* but return the position before it. */ endquoted: - state.quoted = 1; + state->quoted = 1; done: - state.depth = depth; - state.mindepth = mindepth; - state.thislevelstart = curlevel->prev; - state.prevlevelstart + state->depth = depth; + state->mindepth = mindepth; + state->thislevelstart = curlevel->prev; + state->prevlevelstart = (curlevel == levelstart) ? -1 : (curlevel - 1)->last; - state.location = from; - state.location_byte = from_byte; - state.levelstarts = Qnil; + state->location = from; + state->location_byte = from_byte; + state->levelstarts = Qnil; while (curlevel > levelstart) - state.levelstarts = Fcons (make_number ((--curlevel)->last), - state.levelstarts); + state->levelstarts = Fcons (make_number ((--curlevel)->last), + state->levelstarts); + state->prev_syntax = (SYNTAX_FLAGS_COMSTARTEND_FIRST (prev_from_syntax) + || state->quoted) ? prev_from_syntax : Smax; immediate_quit = 0; +} + +/* Convert a (lisp) parse state to the internal form used in + scan_sexps_forward. */ +static void +internalize_parse_state (Lisp_Object external, struct lisp_parse_state *state) +{ + Lisp_Object tem; + + if (NILP (external)) + { + state->depth = 0; + state->instring = -1; + state->incomment = 0; + state->quoted = 0; + state->comstyle = 0; /* comment style a by default. */ + state->comstr_start = -1; /* no comment/string seen. */ + state->levelstarts = Qnil; + state->prev_syntax = Smax; + } + else + { + tem = Fcar (external); + if (!NILP (tem)) + state->depth = XINT (tem); + else + state->depth = 0; + + external = Fcdr (external); + external = Fcdr (external); + external = Fcdr (external); + tem = Fcar (external); + /* Check whether we are inside string_fence-style string: */ + state->instring = (!NILP (tem) + ? (CHARACTERP (tem) ? XFASTINT (tem) : ST_STRING_STYLE) + : -1); + + external = Fcdr (external); + tem = Fcar (external); + state->incomment = (!NILP (tem) + ? (INTEGERP (tem) ? XINT (tem) : -1) + : 0); + + external = Fcdr (external); + tem = Fcar (external); + state->quoted = !NILP (tem); - *stateptr = state; + /* if the eighth element of the list is nil, we are in comment + style a. If it is non-nil, we are in comment style b */ + external = Fcdr (external); + external = Fcdr (external); + tem = Fcar (external); + state->comstyle = (NILP (tem) + ? 0 + : (RANGED_INTEGERP (0, tem, ST_COMMENT_STYLE) + ? XINT (tem) + : ST_COMMENT_STYLE)); + + external = Fcdr (external); + tem = Fcar (external); + state->comstr_start = + RANGED_INTEGERP (PTRDIFF_MIN, tem, PTRDIFF_MAX) ? XINT (tem) : -1; + external = Fcdr (external); + tem = Fcar (external); + state->levelstarts = tem; + + external = Fcdr (external); + tem = Fcar (external); + state->prev_syntax = NILP (tem) ? Smax : XINT (tem); + } } DEFUN ("parse-partial-sexp", Fparse_partial_sexp, Sparse_partial_sexp, 2, 6, 0, @@ -3488,6 +3545,7 @@ Parsing stops at TO or when certain criteria are met; point is set to where parsing stops. If fifth arg OLDSTATE is omitted or nil, parsing assumes that FROM is the beginning of a function. + Value is a list of elements describing final state of parsing: 0. depth in parens. 1. character address of start of innermost containing list; nil if none. @@ -3501,16 +3559,22 @@ Value is a list of elements describing final state of parsing: 6. the minimum paren-depth encountered during this scan. 7. style of comment, if any. 8. character address of start of comment or string; nil if not in one. - 9. Intermediate data for continuation of parsing (subject to change). + 9. List of positions of currently open parens, outermost first. +10. When the last position scanned holds the first character of a + (potential) two character construct, the syntax of that position, + otherwise nil. That construct can be a two character comment + delimiter or an Escaped or Char-quoted character. +11..... Possible further internal information used by `parse-partial-sexp'. + If third arg TARGETDEPTH is non-nil, parsing stops if the depth in parentheses becomes equal to TARGETDEPTH. -Fourth arg STOPBEFORE non-nil means stop when come to +Fourth arg STOPBEFORE non-nil means stop when we come to any character that starts a sexp. Fifth arg OLDSTATE is a list like what this function returns. It is used to initialize the state of the parse. Elements number 1, 2, 6 are ignored. -Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. - If it is symbol `syntax-table', stop after the start of a comment or a +Sixth arg COMMENTSTOP non-nil means stop after the start of a comment. + If it is the symbol `syntax-table', stop after the start of a comment or a string, or after end of a comment or a string. */) (Lisp_Object from, Lisp_Object to, Lisp_Object targetdepth, Lisp_Object stopbefore, Lisp_Object oldstate, Lisp_Object commentstop) @@ -3527,15 +3591,17 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. target = TYPE_MINIMUM (EMACS_INT); /* We won't reach this depth. */ validate_region (&from, &to); + internalize_parse_state (oldstate, &state); scan_sexps_forward (&state, XINT (from), CHAR_TO_BYTE (XINT (from)), XINT (to), - target, !NILP (stopbefore), oldstate, + target, !NILP (stopbefore), (NILP (commentstop) ? 0 : (EQ (commentstop, Qsyntax_table) ? -1 : 1))); SET_PT_BOTH (state.location, state.location_byte); - return Fcons (make_number (state.depth), + return + Fcons (make_number (state.depth), Fcons (state.prevlevelstart < 0 ? Qnil : make_number (state.prevlevelstart), Fcons (state.thislevelstart < 0 @@ -3553,11 +3619,15 @@ Sixth arg COMMENTSTOP non-nil means stop at the start of a comment. ? Qsyntax_table : make_number (state.comstyle)) : Qnil), - Fcons (((state.incomment - || (state.instring >= 0)) - ? make_number (state.comstr_start) - : Qnil), - Fcons (state.levelstarts, Qnil)))))))))); + Fcons (((state.incomment + || (state.instring >= 0)) + ? make_number (state.comstr_start) + : Qnil), + Fcons (state.levelstarts, + Fcons (state.prev_syntax == Smax + ? Qnil + : make_number (state.prev_syntax), + Qnil))))))))))); } void commit 565df7265dd73b4812fcb02cd1663fce4dc40be7 Author: Lars Magne Ingebrigtsen Date: Sun Mar 20 14:07:47 2016 +0100 Allow the shr test files to have trailing blank space. * .gitattributes: Allow the shr test files to have trailing blank space. diff --git a/.gitattributes b/.gitattributes index 13e58a8..24fe4c7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -33,6 +33,9 @@ test/etags/html-src/algrthms.html whitespace=cr-at-eol # The upstream maintainer does not want to remove trailing whitespace. doc/misc/texinfo.tex -whitespace=blank-at-eol +# The shr test files can have trailing whitespace. +test/data/shr/*.txt -whitespace=blank-at-eol + # Some files should not be treated as text when diffing or merging. *.cur binary *.gpg binary commit ebe63f43dfa6912ba8f2d4fd509392d34d77f36e Author: Lars Magne Ingebrigtsen Date: Sun Mar 20 14:07:24 2016 +0100 Add tests for empty
    • diff --git a/test/data/shr/ul-empty.html b/test/data/shr/ul-empty.html new file mode 100644 index 0000000..e5a75ab --- /dev/null +++ b/test/data/shr/ul-empty.html @@ -0,0 +1,4 @@ +
        +
      • +
      +Lala diff --git a/test/data/shr/ul-empty.txt b/test/data/shr/ul-empty.txt new file mode 100644 index 0000000..acb41c4 --- /dev/null +++ b/test/data/shr/ul-empty.txt @@ -0,0 +1,3 @@ +* + +Lala commit 17ba74742c2e6085b044d10c1e03f32a04b09d78 Author: Paul Eggert Date: Sun Mar 20 05:56:42 2016 -0700 * src/alloc.c (purecopy): Use AUTO_STRING. diff --git a/src/alloc.c b/src/alloc.c index eaa92ee..66dbde0 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -5427,7 +5427,7 @@ purecopy (Lisp_Object obj) } else { - Lisp_Object fmt = build_pure_c_string ("Don't know how to purify: %S"); + AUTO_STRING (fmt, "Don't know how to purify: %S"); Fsignal (Qerror, list1 (CALLN (Fformat, fmt, obj))); } commit f2da80d0e1ccd121c4891e869a45aeb9c6b1795d Author: Lars Magne Ingebrigtsen Date: Sun Mar 20 13:57:11 2016 +0100 Ignore invalid base64 encoded embedded images * lisp/net/shr.el (shr-image-from-data): Ignore invalid base64 encoded embedded images (bug#22928). diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 4f64618..cd55f22 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -946,7 +946,8 @@ If EXTERNAL, browse the URL using `shr-external-browser'." (let ((param (match-string 4 data)) (payload (url-unhex-string (match-string 5 data)))) (when (string-match "^.*\\(;[ \t]*base64\\)$" param) - (setq payload (base64-decode-string payload))) + (setq payload (ignore-errors + (base64-decode-string payload)))) payload))) ;; Behind display-graphic-p test. commit 4f6ea3988b66cf132c67fd0cc26d12eb9a300ba1 Author: Lars Magne Ingebrigtsen Date: Sun Mar 20 13:52:36 2016 +0100 Render empty
        • correctly * lisp/net/shr.el (shr-tag-ul): Render empty
            • correctly (bug#22964). diff --git a/lisp/net/shr.el b/lisp/net/shr.el index eae50a7..4f64618 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -1589,6 +1589,10 @@ The preference is a float determined from `shr-prefer-media-type'." (shr-ensure-paragraph) (let ((shr-list-mode 'ul)) (shr-generic dom)) + ;; If we end on an empty
            • , then make sure we really end on a new + ;; paragraph. + (unless (bolp) + (insert "\n")) (shr-ensure-paragraph)) (defun shr-tag-ol (dom) commit 292921facaff2f02ac4e8602c1f7ecbdcfe7ef45 Author: Lars Magne Ingebrigtsen Date: Sun Mar 20 13:43:42 2016 +0100 Fix

              and

              newlines with or without
            • in shr * lisp/net/shr.el (shr-ensure-newline): Respect that we're in a
            • , if we are, and don't insert newlines there. (shr-ensure-paragraph): When mixing newlines and paragraph ensurements, don't insert too many blank lines. (shr-tag-div): A
              shouldn't introduce a paragraph, but a new line. diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 0a7ea14..eae50a7 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -805,8 +805,13 @@ size, and full-buffer size." (url-expand-file-name url (concat (car base) (cadr base)))))) (defun shr-ensure-newline () - (unless (zerop (current-column)) - (insert "\n"))) + (unless (bobp) + (let ((prefix (get-text-property (line-beginning-position) + 'shr-prefix-length))) + (unless (or (zerop (current-column)) + (and prefix + (= prefix (- (point) (line-beginning-position))))) + (insert "\n"))))) (defun shr-ensure-paragraph () (unless (bobp) @@ -834,6 +839,10 @@ size, and full-buffer size." (line-end-position)) (line-end-position))))) (delete-region (match-beginning 0) (match-end 0))) + ;; We have a single blank line. + ((and (eolp) (bolp)) + (insert "\n")) + ;; Insert new paragraph. (t (insert "\n\n")))))) @@ -1247,7 +1256,7 @@ ones, in case fg and bg are nil." (shr-ensure-paragraph)) (defun shr-tag-div (dom) - (shr-ensure-paragraph) + (shr-ensure-newline) (shr-generic dom) (shr-ensure-newline)) commit 21c89971c31d8f5c14814d2a18749495ed191d8f Author: Lars Magne Ingebrigtsen Date: Sun Mar 20 13:41:59 2016 +0100 Add more shr HTML rendering tests diff --git a/test/data/shr/div-div.html b/test/data/shr/div-div.html new file mode 100644 index 0000000..1c191ae --- /dev/null +++ b/test/data/shr/div-div.html @@ -0,0 +1 @@ +
              foo
              Bar
              diff --git a/test/data/shr/div-div.txt b/test/data/shr/div-div.txt new file mode 100644 index 0000000..62715e1 --- /dev/null +++ b/test/data/shr/div-div.txt @@ -0,0 +1,2 @@ +foo +Bar diff --git a/test/data/shr/div-p.html b/test/data/shr/div-p.html index 810b2f7..fcbdfc4 100644 --- a/test/data/shr/div-p.html +++ b/test/data/shr/div-p.html @@ -1 +1 @@ -
              foo

              Bar +

              foo

              Bar

              diff --git a/test/data/shr/li-div.html b/test/data/shr/li-div.html new file mode 100644 index 0000000..eca3c51 --- /dev/null +++ b/test/data/shr/li-div.html @@ -0,0 +1,10 @@ +
                +
              • +
                +

                This is the first paragraph of a list item.

                +

                This is the second paragraph of a list item.

              • +
              • +
                This is the first paragraph of a list item.
                +
                This is the second paragraph of a list item.
                +
              • +
              diff --git a/test/data/shr/li-div.txt b/test/data/shr/li-div.txt new file mode 100644 index 0000000..9fc54f2 --- /dev/null +++ b/test/data/shr/li-div.txt @@ -0,0 +1,6 @@ +* This is the first paragraph of a list item. + + This is the second paragraph of a list item. + +* This is the first paragraph of a list item. + This is the second paragraph of a list item. diff --git a/test/lisp/net/shr-tests.el b/test/lisp/net/shr-tests.el index 6078817..6606ec5 100644 --- a/test/lisp/net/shr-tests.el +++ b/test/lisp/net/shr-tests.el @@ -23,10 +23,14 @@ ;;; Code: +(require 'shr) + (defun shr-test (name) (with-temp-buffer (insert-file-contents (format "data/shr/%s.html" name)) - (let ((dom (libxml-parse-html-region (point-min) (point-max)))) + (let ((dom (libxml-parse-html-region (point-min) (point-max))) + (shr-width 80) + (shr-use-fonts nil)) (erase-buffer) (shr-insert-document dom) (cons (buffer-substring-no-properties (point-min) (point-max)) @@ -37,9 +41,10 @@ (ert-deftest rendering () (skip-unless (fboundp 'libxml-parse-html-region)) (dolist (file (directory-files "data/shr" nil "\\.html\\'")) - (let ((result (shr-test (replace-regexp-in-string - "\\.html\\'" "" file)))) - (should (equal (car result) (cdr result)))))) + (let* ((name (replace-regexp-in-string "\\.html\\'" "" file)) + (result (shr-test name))) + (unless (equal (car result) (cdr result)) + (should (not (list name (car result) (cdr result)))))))) (require 'shr) commit 4f9c775700d250d8626ce679a1fdd6da58a9fa11 Author: Lars Magne Ingebrigtsen Date: Sun Mar 20 12:55:36 2016 +0100 Add a test harness for shr HTML rendering and one test diff --git a/test/data/shr/div-p.html b/test/data/shr/div-p.html new file mode 100644 index 0000000..810b2f7 --- /dev/null +++ b/test/data/shr/div-p.html @@ -0,0 +1 @@ +
              foo

              Bar diff --git a/test/data/shr/div-p.txt b/test/data/shr/div-p.txt new file mode 100644 index 0000000..859d731 --- /dev/null +++ b/test/data/shr/div-p.txt @@ -0,0 +1,3 @@ +foo + +Bar diff --git a/test/lisp/net/shr-tests.el b/test/lisp/net/shr-tests.el new file mode 100644 index 0000000..6078817 --- /dev/null +++ b/test/lisp/net/shr-tests.el @@ -0,0 +1,46 @@ +;;; network-stream-tests.el --- tests for network processes -*- lexical-binding: t; -*- + +;; Copyright (C) 2016 Free Software Foundation, Inc. + +;; Author: Lars Ingebrigtsen + +;; 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 +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;;; Code: + +(defun shr-test (name) + (with-temp-buffer + (insert-file-contents (format "data/shr/%s.html" name)) + (let ((dom (libxml-parse-html-region (point-min) (point-max)))) + (erase-buffer) + (shr-insert-document dom) + (cons (buffer-substring-no-properties (point-min) (point-max)) + (with-temp-buffer + (insert-file-contents (format "data/shr/%s.txt" name)) + (buffer-string)))))) + +(ert-deftest rendering () + (skip-unless (fboundp 'libxml-parse-html-region)) + (dolist (file (directory-files "data/shr" nil "\\.html\\'")) + (let ((result (shr-test (replace-regexp-in-string + "\\.html\\'" "" file)))) + (should (equal (car result) (cdr result)))))) + +(require 'shr) + +;;; shr-stream-tests.el ends here commit c688c44ddfda28ac94dec2ad57c5ca3ed263ff1d Author: Lars Magne Ingebrigtsen Date: Sun Mar 20 12:54:24 2016 +0100 Remove code left over from when overlays were used for padding * lisp/net/shr.el (shr-previous-newline-padding-width): Remove. (shr-remove-trailing-whitespace): Ditto. (shr-insert-document): Don't call them. diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 6bb6898..0a7ea14 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -275,7 +275,6 @@ DOM should be a parse tree as generated by (shr-descend dom) (shr-fill-lines start (point)) (shr--remove-blank-lines-at-the-end start (point)) - (shr-remove-trailing-whitespace start (point)) (when shr-warning (message "%s" shr-warning)))) @@ -292,19 +291,6 @@ DOM should be a parse tree as generated by (unless (bolp) (insert "\n")))))) -(defun shr-remove-trailing-whitespace (start end) - (let ((width (window-width))) - (save-restriction - (narrow-to-region start end) - (goto-char start) - (while (not (eobp)) - (end-of-line) - (when (> (shr-previous-newline-padding-width (current-column)) width) - (dolist (overlay (overlays-at (point))) - (when (overlay-get overlay 'before-string) - (overlay-put overlay 'before-string nil)))) - (forward-line 1))))) - (defun shr-copy-url (&optional image-url) "Copy the URL under point to the kill ring. If IMAGE-URL (the prefix) is non-nil, or there is no link under @@ -1172,18 +1158,6 @@ ones, in case fg and bg are nil." t))) new-colors))) -(defun shr-previous-newline-padding-width (width) - (let ((overlays (overlays-at (point))) - (previous-width 0)) - (if (null overlays) - width - (dolist (overlay overlays) - (setq previous-width - (+ previous-width - (length (plist-get (overlay-properties overlay) - 'before-string))))) - (+ width previous-width)))) - ;;; Tag-specific rendering rules. (defun shr-tag-html (dom) commit 35d58020b6e173b137429786d174ffdb8894a812 Author: Lars Magne Ingebrigtsen Date: Sun Mar 20 12:52:28 2016 +0100 Remove trailing blank lines in shr * lisp/net/shr.el (shr--remove-blank-lines-at-the-end): New function. (shr-insert-document): Use it to remove trailing blank lines at the end of documents, since these never seem to be very useful. diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 3877719..6bb6898 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -274,10 +274,24 @@ DOM should be a parse tree as generated by (set-window-hscroll nil 0) (shr-descend dom) (shr-fill-lines start (point)) + (shr--remove-blank-lines-at-the-end start (point)) (shr-remove-trailing-whitespace start (point)) (when shr-warning (message "%s" shr-warning)))) +(defun shr--remove-blank-lines-at-the-end (start end) + (save-restriction + (save-excursion + (current-buffer) + (narrow-to-region start end) + (goto-char end) + (when (and (re-search-backward "[^ \n]" nil t) + (not (eobp))) + (forward-char 1) + (delete-region (point) (point-max)) + (unless (bolp) + (insert "\n")))))) + (defun shr-remove-trailing-whitespace (start end) (let ((width (window-width))) (save-restriction commit 0b7836dda668a64577778d05ce02d65301bb631b Author: Lars Magne Ingebrigtsen Date: Sun Mar 20 12:12:27 2016 +0100 Don't bug out on nil `patch-buf' arguments * lisp/vc/ediff.el (ediff-patch-file): Don't bug out on nil `patch-buf' arguments. diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el index be4ced9..a4244c9 100644 --- a/lisp/vc/ediff.el +++ b/lisp/vc/ediff.el @@ -1367,8 +1367,8 @@ buffer. If odd -- assume it is in a file." (require 'ediff-ptch) (setq patch-buf (ediff-get-patch-buffer - (if arg (prefix-numeric-value arg)) - (get-buffer patch-buf))) + (and arg (prefix-numeric-value arg)) + (and patch-buf (get-buffer patch-buf)))) (setq source-dir (cond (ediff-use-last-dir ediff-last-dir-patch) ((and (not ediff-patch-default-directory) (buffer-file-name patch-buf)) commit 6e70769e311e5614ceeb2e66483b33af4ad432c6 Author: Ernest Adrogué Date: Sun Mar 20 12:01:23 2016 +0100 Add a Catalan language environment * international/mule-cmds.el (locale-language-names): Map locale language name `ca' to language environment `Catalan'. * language/european.el: Add definition of language environment for the Catalan language. * leim/quail/latin-pre.el: Add quail rule to the `catalan-prefix' input method to support input of middle dot characters through composition (bug#18279). diff --git a/etc/NEWS b/etc/NEWS index 9695a55..d963dee 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -54,6 +54,10 @@ has been added. They are: `file-attribute-type', `file-attribute-device-number' --- +** The locale language name `ca' is now mapped to the language +environment `Catalan', which has been added. + +--- ** `align-regexp' has a separate history for its interactive argument `align-regexp' no longer shares its history with all other history-less functions that use `read-string' diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index dc96990..5501fa1 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -2235,7 +2235,7 @@ See `set-language-info-alist' for use in programs." ("br" . "Latin-1") ; Breton ("bs" . "Latin-2") ; Bosnian ("byn" . "UTF-8") ; Bilin; Blin - ("ca" . "Latin-1") ; Catalan + ("ca" "Catalan" iso-8859-1) ; Catalan ; co Corsican ("cs" "Czech" iso-8859-2) ("cy" "Welsh" iso-8859-14) diff --git a/lisp/language/european.el b/lisp/language/european.el index a939719..11c5e03 100644 --- a/lisp/language/european.el +++ b/lisp/language/european.el @@ -614,6 +614,28 @@ method and applying Turkish case rules for the characters i, I, ı, İ."))) (documentation . "Support for Brazilian Portuguese.")) '("European")) +(set-language-info-alist + "Catalan" '((charset iso-8859-1) + (coding-system iso-8859-1 iso-8859-15) + (coding-priority iso-8859-1) + (input-method . "catalan-prefix") + (nonascii-translation . iso-8859-1) + (unibyte-display . iso-8859-1) + (setup-function + . (lambda () + (modify-syntax-entry ?· "w" (standard-syntax-table)))) + (exit-function + . (lambda () + (modify-syntax-entry ?· "_" (standard-syntax-table)))) + (sample-text . "\ +Catalan (Català) Avui demà i ahir s'esfullarà una rosa.") + (documentation . "\ +This language environment uses the ISO-8859-1 character set, +sets the default input method to \"catalan-prefix\", and sets +the syntax of the middle dot character `·' to word.")) + '("European")) + + (define-coding-system 'mac-roman "Mac Roman Encoding (MIME:MACINTOSH)." diff --git a/lisp/leim/quail/latin-pre.el b/lisp/leim/quail/latin-pre.el index 078f9f9..138a97a 100644 --- a/lisp/leim/quail/latin-pre.el +++ b/lisp/leim/quail/latin-pre.el @@ -188,6 +188,7 @@ diaeresis | \" | \"i -> ï \"\" -> ¨ tilde | ~ | ~n -> ñ cedilla | ~ | ~c -> ç + middle dot | ~ | ~. -> · symbol | ~ | ~> -> » ~< -> « ~! -> ¡ ~? -> ¿ " nil t nil nil nil nil nil nil nil nil t) @@ -223,6 +224,7 @@ ("~<" ?\«) ("~!" ?¡) ("~?" ?¿) + ("~." ?·) ("~ " ?~) )