- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Emacs 的大佬。我在本月初开始使用 Emacs。
我想将小的 Vim 脚本移植到 Emacs。这些脚本也将使我们能够在 Emacs 中进行这样的计算。
http://www.youtube.com/watch?v=yDR0dTPu6M4
我试图移植下面写的 Vim 脚本。
function! s:ExecPySf_1liner()
let l:strAt = getline(".")
call writefile([strAt], "temp.pysf")
let l:strAt = system("python -u -m sfPP -fl temp.pysf")
if @0 == 0
let @0 = l:strAt
else
let @0 = l:strAt
endif
let @" = @0
if match(&clipboard, "unnamed") >= 0
let @* = @0
endif
echo @0
endfunction
(defun ExecPySf_1liner ()
(let ( (strAt
(buffer-substring-no-properties (point-at-bol) (point-at-eol))
)
)
)
)
1 read one line under the cursor.
2 write down the one line string into temp.pysf file in current directory
3 execute "python -u -m sfPP -fl temp.pysf" in a shell.
4 display the returned calculated string in echo arear
5 and copy the string in the clipboard to enable a user to past the calculated result.
(defun __getLineOmittingComment ()
"Get position after ';;' string. If there is no ;; then return line-beginning-posiion"
(interactive)
(goto-char (line-beginning-position))
(let (( posAt (search-forward ";;" (line-end-position) t) ))
(if (equal posAt nil) (line-beginning-position) posAt)
)
)
(defun ExecPySf_1liner()
"Evaluates the current line in PythonSf, then copies the result to the clipboard."
(interactive)
(write-region (__getLineOmittingComment) (line-end-position) "temp.pysf" nil)
(let ((strAt
(shell-command-to-string "python -u -m sfPP -fl temp.pysf" )
))
(message strAt)
(kill-new strAt)))
import sympy as ts; Lgndr=lambda a,b:(lambda c=a%b:0 if ts.gcd(c,b)!=1 else 1 if any((c-k^2)%b==0 for k in range(1,b//2+2)) else -1)(); [Lgndr(3,p) for p in ts.primerange(3,100)]
===============================
[0, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1]
You should look at IPython. It comes with an Emacs mode that will do all this and more
You should look at IPython :). It comes with an Emacs mode that will do all this and more. :) ? I can understand your opinion. But I claim that TO USE Emacs AS IPython is better than TO USE IPython AS Emacs.
' xy"' in 'abcd"xy"efg'
===============================
False
type __tempConverted.py
from __future__ import division
# -*- encoding: utf-8 -*-
from pysf.sfFnctns import *
setDctGlobals(globals())
from pysf.customize import *
if os.path.exists('./sfCrrntIni.py'):
from sfCrrntIni import *
rightSideValueAt__= ' xy"' in 'abcd"xy"efg'
print "==============================="
print rightSideValueAt__
putPv(rightSideValueAt__, '_dt')
'"xy"' in 'abcd"xy"efg'
===============================
True
source(np.source)
In file: C:\Python27\lib\site-packages\numpy\lib\utils.py
def source(object, output=sys.stdout):
snipped
import inspect
try:
print >> output, "In file: %s\n" % inspect.getsourcefile(object)
print >> output, inspect.getsource(object)
except:
print >> output, "Not available for this object."
===============================
None
You should look at IPython I have been watching IPython youtube video:IPython in-depth by bits to write an article:"Use Vim/Emacs as IPython"
最佳答案
这是我提出的一些事情:
(defun get-current-line ()
(buffer-substring-no-properties (line-beginning-position)
(line-end-position)))
(defun run-python-command (str)
(shell-command-to-string
(concat "/usr/bin/env python -u -m sfPP -c "
(shell-quote-argument (concat "print(" str ")")))))
(defun eval-line-in-python ()
"Evaluates the current line in python, then copies the result to the clipboard."
(interactive)
(let ((str (run-python-command (get-current-line))))
(message str)
(kill-new str)))
M-x eval-line-in-python
运行它.
关于python - 我想要一个在光标下执行 Python 单行的 elisp 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14784347/
使用登录后,我想吐出用户名。 但是,当我尝试单击登录按钮时, 它给了我力量。 我看着logcat,但是什么也没显示。 这种编码是在说。 它将根据我在登录屏幕中输入的名称来烘烤用户名。 不会有任何密码。
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎是题外话,因为它缺乏足够的信息来诊断问题。 更详细地描述您的问题或include a min
我是一名优秀的程序员,十分优秀!