压缩/简化Lisp
所以我创建了一个lisp来分解多行文字,然后在分解之前将其对齐到之前的对齐方式。它工作得很好,运行时间也不长,但我只是想知道是否有更好的方法来编写它。这对我来说似乎很笨拙,我相信有比我的新手尝试更好的方法。
(defun c:XtoJ()
(setq UserQA (getvar "QAFLAGS"))
(setvar "QAFLAGS" 1)
(setq topleft (ssget "_X" '((0 . "MTEXT")(71 . 1)))) ;Select TopLeft MTEXT
(command "._explode" topleft "") ;Explode TopLeft MTEXT
(setq middleleft (ssget "_X" '((0 . "MTEXT")(71 . 4)))) ;Select MiddleLeft MTEXT
(command "._explode" middleleft "") ;Explode MiddleLeft MTEXT
(setq bottomleft (ssget "_X" '((0 . "MTEXT")(71 . 7)))) ;Select BottomLeft MTEXT
(command "._explode" bottomleft "") ;Explode BottomLeft MTEXT
(setq lefttext (ssget "_X" '((0 . "TEXT")(72 . 0)))) ;Select All Left Justified TEXT
(setq topright (ssget "_X" '((0 . "MTEXT")(71 . 3)))) ;TopRight Start
(command "._explode" topright "") ;TopRight Explode
(setq topright (ssget "_X" '((0 . "TEXT")(72 . 0))))
(command "justifytext" topright "" "R") ;TopRight End
(command "justifytext" lefttext "" "L") ;Fix LeftText
(setq middleright (ssget "_X" '((0 . "MTEXT")(71 . 6)))) ;MiddleRight Start
(command "._explode" middleright "") ;MiddleRight Explode
(setq middleright (ssget "_X" '((0 . "TEXT")(72 . 0))))
(command "justifytext" middleright "" "R") ;MiddleRight End
(command "justifytext" lefttext "" "L") ;Fix LeftText
(setq bottomright (ssget "_X" '((0 . "MTEXT")(71 . 9)))) ;BottomRight Start
(command "._explode" bottomright "") ;BottomRight Explode
(setq bottomright (ssget "_X" '((0 . "TEXT")(72 . 0))))
(command "justifytext" bottomright "" "R") ;BottomRight End
(command "justifytext" lefttext "" "L") ;Fix LeftText
(setq topcenter (ssget "_X" '((0 . "MTEXT")(71 . 2)))) ;TopCenter Start
(command "._explode" topcenter "") ;TopCenter Explode
(setq topcenter (ssget "_X" '((0 . "TEXT")(72 . 0))))
(command "justifytext" topcenter "" "C") ;TopCenter End
(command "justifytext" lefttext "" "L") ;Fix LeftText
(setq middlecenter (ssget "_X" '((0 . "MTEXT")(71 . 5)))) ;MiddleCenter Start
(command "._explode" middlecenter "") ;MiddleCenter Explode
(setq middlecenter (ssget "_X" '((0 . "TEXT")(72 . 0))))
(command "justifytext" middlecenter "" "C") ;MiddleCenter End
(command "justifytext" lefttext "" "L") ;Fix LeftText
(setq bottomcenter (ssget "_X" '((0 . "MTEXT")(71 . ))) ;BottomCenter Start
(command "._explode" bottomcenter "") ;BottomCenter Explode
(setq bottomcenter (ssget "_X" '((0 . "TEXT")(72 . 0))))
(command "justifytext" bottomcenter "" "C") ;BottomCenter End
(command "justifytext" lefttext "" "L") ;Fix LeftText
(setvar "QAFLAGS" UserQA)
) 笔记在我的文本编辑器中排列好了,但复制得不是很好。。。我会编辑它,但由于某种原因忘记了如何编辑帖子。 我稍微修改了一下代码。 哎呀,我引用了,而不是代码。
(defun c:XtoJ()
(setq UserQA (getvar "QAFLAGS"))
(setvar "QAFLAGS" 1)
(setq topleft (ssget "_X" '((0 . "MTEXT")(71 . 1)))) ;Select TopLeft MTEXT
(command "._explode" topleft "") ;Explode TopLeft MTEXT
(setq middleleft (ssget "_X" '((0 . "MTEXT")(71 . 4)))) ;Select MiddleLeft MTEXT
(command "._explode" middleleft "") ;Explode MiddleLeft MTEXT
(setq bottomleft (ssget "_X" '((0 . "MTEXT")(71 . 7)))) ;Select BottomLeft MTEXT
(command "._explode" bottomleft "") ;Explode BottomLeft MTEXT
(setq topright (ssget "_X" '((0 . "MTEXT")(71 . 3)))) ;TopRight Start
(command "._explode" topright "") ;TopRight Explode
(setq topright (ssget "P"))
(command "justifytext" topright "" "R") ;TopRight End
(setq middleright (ssget "_X" '((0 . "MTEXT")(71 . 6)))) ;MiddleRight Start
(command "._explode" middleright "") ;MiddleRight Explode
(setq middleright (ssget "P"))
(command "justifytext" middleright "" "R") ;MiddleRight End
(setq bottomright (ssget "_X" '((0 . "MTEXT")(71 . 9)))) ;BottomRight Start
(command "._explode" bottomright "") ;BottomRight Explode
(setq bottomright (ssget "P"))
(command "justifytext" bottomright "" "R") ;BottomRight End
(setq topcenter (ssget "_X" '((0 . "MTEXT")(71 . 2)))) ;TopCenter Start
(command "._explode" topcenter "") ;TopCenter Explode
(setq topcenter (ssget "P"))
(command "justifytext" topcenter "" "C") ;TopCenter End
(setq middlecenter (ssget "_X" '((0 . "MTEXT")(71 . 5)))) ;MiddleCenter Start
(command "._explode" middlecenter "") ;MiddleCenter Explode
(setq middlecenter (ssget "P"))
(command "justifytext" middlecenter "" "C") ;MiddleCenter End
(setq bottomcenter (ssget "_X" '((0 . "MTEXT")(71 . ))) ;BottomCenter Start
(command "._explode" bottomcenter "") ;BottomCenter Explode
(setq bottomcenter (ssget "P"))
(command "justifytext" bottomcenter "" "C") ;BottomCenter End
(setvar "QAFLAGS" UserQA)
) 嗨,AES。
编辑消息位于您创建的所有帖子的右下角。另一种选择是制作新帖子,然后抑制旧帖子(再次通过编辑>删除)。
删除ssget“text”很好,它删除了一些bug,对吗?
我可以补充一件事,现在您的代码可能按预期工作。。。您不需要在变量中存储“previous”就可以在下一个命令中使用它。按原样使用(你会在我的代码中看到我的意思)。还要注意,我是如何将foreach与一些命令一起使用的,而不是将每组命令重复9次。如果返回一个选择集,我还将所有条件都设为条件。如果将nil作为参数提供,某些命令可能不会爆炸,但最好避免这种情况。它还可以防止无用地执行代码。这可以缩短到这样的程度:
;Jef! 2017-06-12
(defun c:moo ( / tmp)
(foreach itm (list '(1 . "TL") '(2 . "TC") '(3 . "TR")'(4 . "ML") '(5 . "MC") '(6 . "MR")'(7 . "BL") '(8 . "BC") '(9 . "BR"))
(if (setq tmp (ssget "_X" (list '(0 . "MTEXT")(cons 71 (car itm)))))
(and(vl-cmdf "._explode" tmp "")
(vl-cmdf "._justifytext" "P" "" (cdr itm))
)
)
)
)
页:
[1]