summaryrefslogtreecommitdiff
path: root/test/lisp/ffap-tests.el
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>2020-08-15 12:11:41 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2020-08-15 12:11:41 +0200
commitf3afb23d26b948cfa095b221ca32090a2858e8f1 (patch)
treeb7e82e75f8a370ab7a10fa74489c8d1b58e3b75e /test/lisp/ffap-tests.el
parentf712cdbe9e9bdca3d4c7c27e9ac59686ab4c7620 (diff)
downloademacs-f3afb23d26b948cfa095b221ca32090a2858e8f1.tar.gz
Add support for ffap guessing at file names containing spaces
* lisp/ffap.el (ffap-file-name-with-spaces): New variable (bug#8439). (ffap-search-backward-file-end, ffap-search-forward-file-end) (ffap-dir-separator-near-point): New functions. (ffap-string-at-point): Use the variable and the new functions to guess at files containing strings.
Diffstat (limited to 'test/lisp/ffap-tests.el')
-rw-r--r--test/lisp/ffap-tests.el40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el
index 30c8f794577..e8c12669c1a 100644
--- a/test/lisp/ffap-tests.el
+++ b/test/lisp/ffap-tests.el
@@ -77,6 +77,46 @@ left alone when opening a URL in an external browser."
(should (compare-window-configurations (current-window-configuration) old))
(should (equal urls '("https://www.gnu.org")))))
+(defun ffap-test-string (space string)
+ (let ((ffap-file-name-with-spaces space))
+ (with-temp-buffer
+ (insert string)
+ (goto-char (point-min))
+ (forward-char 10)
+ (ffap-string-at-point))))
+
+(ert-deftest ffap-test-with-spaces ()
+ (should
+ (equal
+ (ffap-test-string
+ t "c:/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program here.txt")
+ "/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program here.txt"))
+ (should
+ (equal
+ (ffap-test-string
+ nil "c:/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program here.txt")
+ "c:/Program"))
+ (should
+ (equal
+ (ffap-test-string
+ t "c:/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program Files/Hummingbird/")
+ "/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program Files/Hummingbird/"))
+ (should
+ (equal
+ (ffap-test-string
+ t "c:\\Program Files\\Open Text Evaluation Media\\Open Text Exceed 14 x86\\Program Files\\Hummingbird\\")
+ "\\Program Files\\Open Text Evaluation Media\\Open Text Exceed 14 x86\\Program Files\\Hummingbird\\"))
+ (should
+ (equal
+ (ffap-test-string
+ t "c:\\Program Files\\Freescale\\CW for MPC55xx and MPC56xx 2.10\\PowerPC_EABI_Tools\\Command_Line_Tools\\CLT_Usage_Notes.txt")
+ "\\Program Files\\Freescale\\CW for MPC55xx and MPC56xx 2.10\\PowerPC_EABI_Tools\\Command_Line_Tools\\CLT_Usage_Notes.txt"))
+ (should
+ (equal
+ (ffap-test-string
+ t "C:\\temp\\program.log on Windows or /var/log/program.log on Unix.")
+ "\\temp\\program.log")))
+
(provide 'ffap-tests)
;;; ffap-tests.el ends here