[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/d-mode f487a71 058/346: Add the function to support alignm
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/d-mode f487a71 058/346: Add the function to support alignment of multi-line fluent API using expressions. |
Date: |
Sun, 29 Aug 2021 11:00:03 -0400 (EDT) |
branch: elpa/d-mode
commit f487a71dcea6c378f8c5004d13dfbb0116d87edb
Author: Russel Winder <russel@winder.org.uk>
Commit: Russel Winder <russel@winder.org.uk>
Add the function to support alignment of multi-line fluent API using
expressions.
---
d-mode.el | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 72 insertions(+), 2 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index db66e27..b27e868 100644
--- a/d-mode.el
+++ b/d-mode.el
@@ -6,7 +6,7 @@
;; Contributors: Russel Winder
;; Maintainer: Russel Winder
;; Created: March 2007
-;; Date: 2014-09-15
+;; Date: 2014-09-17
;; Version: 2.0.7-SNAPSHOT
;; Keywords: D programming language emacs cc-mode
@@ -452,7 +452,8 @@ Key bindings:
(setq-local syntax-propertize-function
(syntax-propertize-rules ("`\\(\\\\\\)`" (1 "."))))))
-;; Hideous hacks!
+;;----------------------------------------------------------------------------
+;; "Hideous hacks" to support appropriate fon-lock behaviour.
;;
;; * auto/immutable: If we leve them in c-modifier-kwds (like
;; c++-mode) then in the form "auto var;" var will be highlighted in
@@ -496,6 +497,75 @@ Key bindings:
(d-match-fun-decl (1 font-lock-type-face) (2 font-lock-function-name-face)))
t)
+;;----------------------------------------------------------------------------
+;;
+;; Support for "Adjusting Alignment Rules for UCFS-Chains in D",
+;; cf.
https://stackoverflow.com/questions/25797945/adjusting-alignment-rules-for-ucfs-chains-in-d
+;;
+;; The code here was originally created by Sergei Nosov
+;; (https://stackoverflow.com/users/1969069/sergei-nosov) based on the
c-lineup-cascaded-calls code, see
+;; StackOverflow, and then amended by Nordlöw
(https://stackoverflow.com/users/683710/nordl%C3%B6w) it
+;; provides a function that people can make use of in their d-mode-hook thus:
+;;
+;; (add-hook 'd-mode-hook
+;; '(lambda ()
+;; (add-to-list 'c-offsets-alist '(arglist-cont-nonempty .
c-lineup-cascaded-calls))
+;; (add-to-list 'c-offsets-alist '(statement-cont .
c-lineup-cascaded-calls))))
+
+(defun d-lineup-cascaded-calls (langelem)
+ "This is a modified `c-lineup-cascaded-calls' function for the
+D programming language which accounts for optional parenthesis
+and compile-time parameters in function calls."
+
+ (if (and (eq (c-langelem-sym langelem) 'arglist-cont-nonempty)
+ (not (eq (c-langelem-2nd-pos c-syntactic-element)
+ (c-most-enclosing-brace (c-parse-state)))))
+ ;; The innermost open paren is not our one, so don't do
+ ;; anything. This can occur for arglist-cont-nonempty with
+ ;; nested arglist starts on the same line.
+ nil
+
+ (save-excursion
+ (back-to-indentation)
+ (let ((operator (and (looking-at "\\.")
+ (regexp-quote (match-string 0))))
+ (stmt-start (c-langelem-pos langelem)) col)
+
+ (when (and operator
+ (looking-at operator)
+ (or (and
+ (zerop (c-backward-token-2 1 t stmt-start))
+ (eq (char-after) ?\()
+ (zerop (c-backward-token-2 2 t stmt-start))
+ (looking-at operator))
+ (and
+ (zerop (c-backward-token-2 1 t stmt-start))
+ (looking-at operator))
+ (and
+ (zerop (c-backward-token-2 1 t stmt-start))
+ (looking-at operator))
+ )
+ )
+ (setq col (current-column))
+
+ (while (or (and
+ (zerop (c-backward-token-2 1 t stmt-start))
+ (eq (char-after) ?\()
+ (zerop (c-backward-token-2 2 t stmt-start))
+ (looking-at operator))
+ (and
+ (zerop (c-backward-token-2 1 t stmt-start))
+ (looking-at operator))
+ (and
+ (zerop (c-backward-token-2 1 t stmt-start))
+ (looking-at operator))
+ )
+ (setq col (current-column)))
+
+ (vector col))))))
+
+;;----------------------------------------------------------------------------
+
(provide 'd-mode)
- [nongnu] elpa/d-mode 79940f2 085/346: Cleanup and fix test error reporting., (continued)
- [nongnu] elpa/d-mode 79940f2 085/346: Cleanup and fix test error reporting., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode fbd1f8b 089/346: Merge pull request #44 from snosov1/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode e19d704 090/346: Closes #21., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode a927264 092/346: Allow tests to specify lisp code and expected output., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode b4cbdfc 094/346: Workaround issue #50., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 3e80976 097/346: recognize deprecation warnings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 6323cd4 098/346: Recognize postfix @-keywords in function declarations for imenu, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 600c70b 108/346: Merge pull request #65 from CyberShadow/pull-20160329-054927, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 3e73378 112/346: Update the badges/shields in the README., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode a99d127 054/346: Fix keywords list construction to include doc-comment keywords., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f487a71 058/346: Add the function to support alignment of multi-line fluent API using expressions.,
ELPA Syncer <=
- [nongnu] elpa/d-mode 05cd7b9 038/346: Fix classes with inherit lists, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 27e7c62 041/346: Merge pull request #14 from finalpatch/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 011d0cf 043/346: Merge pull request #17 from nordlow/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode a612105 052/346: Add (require 'cl) as per Issue #23., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 72c1bbd 056/346: Update the README., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f400055 062/346: Some tidying up of comments, no change of code., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 27fbe66 065/346: Workaround for special case of 'else static if'., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 85a0900 067/346: Update the URL to the D main website., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode c108583 072/346: (require 'compile), ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 5c5a2b1 071/346: Merge pull request #37 from dmakarov/master, ELPA Syncer, 2021/08/29