Emacs: further improvements in printf skeleton
parent
26903ae6c0
commit
15654e3e2f
|
@ -128,8 +128,6 @@ restored."
|
||||||
;; Skel
|
;; Skel
|
||||||
;;==============================================================================
|
;;==============================================================================
|
||||||
;; TODO: elements: (setq skeleton-further-elements '((q "\"")))
|
;; TODO: elements: (setq skeleton-further-elements '((q "\"")))
|
||||||
|
|
||||||
;; TODO: insert % variables progressively
|
|
||||||
(add-hook
|
(add-hook
|
||||||
'c++-mode-hook
|
'c++-mode-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
@ -138,18 +136,18 @@ restored."
|
||||||
"fprintf/printf snippet
|
"fprintf/printf snippet
|
||||||
|
|
||||||
If no file descriptor is provided, switch do printf. The format
|
If no file descriptor is provided, switch do printf. The format
|
||||||
string is properly parsed (%% are not taken into account)."
|
string is properly parsed (%% are not taken into account).
|
||||||
|
|
||||||
|
Requires the `count-percents' function."
|
||||||
nil
|
nil
|
||||||
'(setq v1 (skeleton-read "File desc: " "stdout"))
|
'(setq v1 (skeleton-read "File desc: " "stdout"))
|
||||||
(if (string= v1 "") "printf (" (concat "fprintf (" v1 ", "))
|
(if (string= v1 "") "printf (" (concat "fprintf (" v1 ", "))
|
||||||
"\"" (setq v1 (skeleton-read "Format string: " "%s\\n")) "\""
|
"\"" (setq v1 (skeleton-read "Format string: " "%s\\n")) "\""
|
||||||
'(setq v2 (count-percents v1))
|
'(setq v2 (count-percents v1))
|
||||||
'(setq v1 0)
|
'(setq v1 0)
|
||||||
'(setq str "")
|
|
||||||
'(while (< v1 v2)
|
'(while (< v1 v2)
|
||||||
(setq v1 (1+ v1))
|
(setq v1 (1+ v1))
|
||||||
(setq str (concat str ", " (skeleton-read "Value: "))))
|
(skeleton-insert '(nil (concat ", " (skeleton-read "Value: ")))))
|
||||||
str
|
|
||||||
");")
|
");")
|
||||||
|
|
||||||
))
|
))
|
||||||
|
|
Loading…
Reference in New Issue