当前位置: 首页 > news >正文

华为云网站建设怎么设置选择项阿里指数查询官网

华为云网站建设怎么设置选择项,阿里指数查询官网,合优网团购,温州网站定制哪家好elisp 从简单实例开始. 我们怎样用elisp 与电脑交互,先从简单实例开始, 逐渐掌握它的几个对象. 与电脑交互,总要有输入,输出,先看两个简单例子. 输入从minibuffer,输出可以是minibuffer 或者缓冲区. 一: 从minibuffer 中输入, 在指定缓冲中插入文字(insert)x ;;;;;;;;;;;;;;;;…

elisp 从简单实例开始.

我们怎样用elisp 与电脑交互,先从简单实例开始, 逐渐掌握它的几个对象.
与电脑交互,总要有输入,输出,先看两个简单例子. 输入从minibuffer,输出可以是minibuffer 或者缓冲区.
一: 从minibuffer 中输入, 在指定缓冲中插入文字(insert)x
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 函数1:
;; 定义一个函数 greet_you_from_me.
;; 其输入参数是me, coder的名字,从函数调用传人(熟悉一下interactive调用参数)
;; 从minibuffer 中读入你的名字
;; 打开一个buffer 叫 *test*
;; 在buffer中显示字符串, 字符串为: 你好,xxx, 我是yyy.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun greet_you_from_me (me)
  (interactive "sme's name:") ; interactive 的调用参数是s,C-h f 查找其它说明
(let ((your-name (read-from-minibuffer "Enter your name: "))); let 语句块,从minibuffer读字符串,付给变量your-name
(switch-to-buffer-other-window "*test*"); 开启新缓冲,新窗口
(erase-buffer); 清缓冲区
(insert (format "Hello %s!\n\nI am %s." your-name me)) ; 构建文字,插入文字
(other-window 1))); 跳回原来的窗口

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 函数2:
;; 编写一个函数,在当前缓冲中输入一行代码,例如:
int pArray = malloc( 5 * sizeof(int))
其中类型int 是可变的, pArray 是可变的, 5 是可变的,都要从minibuffer 输入
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun my_malloc()
  (interactive)
  (let ((name (read-string "name:"))
  (size (read-string "size:"));; 为简单期间全部使用string 类型
  (type (read-string "type:")))
    (switch-to-buffer-other-window "*test*")
    (erase-buffer)
    (insert (format "%s %s = malloc( %s * sizeof(%s));" type name size type))
    (other-window 1)))
函数列表:
(interactive)
(insert)
(format)
(read-string)
(read-from-minibuffer)
(switch-to-buffer-other-window)
(erase-buffer)
(other-window)
(defun)
(let)


二: 数学运算
阶乘运算, 需要从minibuffer 输入一个正整数,计算其阶乘
(defun factorial (num)
  (interactive "ninput a num:")
  (let ((total 1))
  (while (> num 0)
    (setq total (* total num))
    (setq num (- num 1)))
  (message "total is %d" total)))
;;函数列表
(while)
(>)
(-)
(message)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
三. 在文件中查找关键字 search-forward (向前查找)
假定有一个文件,名称为"world.txt",如下:
$cat world.txt
**@#一个兔子洞#@********@#又
一个兔子洞#@****************
**** @# 这也是一个兔子洞 #@*

假想在这片土地上有很多兔子洞,其中@#是入口,#@是出口
现在要写一个elisp 函数,
找出所有关键字@#, #@的位置.
代码如下:
(defun test-search-forward ()
(setq hole-entrance "@#")
(setq hole-exit "#@")
(progn
  (find-file "world.txt")
  (make-local-variable 'hole-entrance)
  (make-local-variable 'hole-exit)
  (goto-char (point-min))
  (let (@extrance @exit)
    (while (progn
             (setq @entrance (search-forward hole-entrance nil t))
             (setq @exit (search-forward hole-exit nil t)))
      (print (format "兔子洞 (%d %d)" @entrance @exit))))))

(test-search-forward)
函数列表:
(find-file)
(make-local-variable)
(goto-char)
(search-forward)
(format)
(print)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
四. 使用list , mapcar 用法(参数为函数), 查找与替换,修改文本属性,正则查找
 

(defun hello (name)
            (insert (format "Hello %s!\n" name)))

(progn
;; 我们将一些名字存到列表中:
(setq list-of-names '("张三" "李四" "王五"))
;; 用 `push'把名字添加到列表的开头:
(push "赵六" list-of-names)
(switch-to-buffer-other-window "*test*")
(erase-buffer)
;; 我们来对`list-of-names'列表中的每一个元素都使用hello函数:
(mapcar 'hello list-of-names)

;; 记得我们之前定义的 `hello' 函数吗? 这个函数接受一个参数,名字。
;; `mapcar' 调用 `hello', 并将`list-of-names'作为参数先后传给`hello'
(other-window 1)
)

;; 现在我们对显示的buffer中的内容进行一些更改:
;; 查找与替换功能
(defun replace-hello-by-bonjour ()
    (switch-to-buffer-other-window "*test*")
    (goto-char (point-min))
;;    (while (search-forward "Hello")
    (while (search-forward "Hello" nil t)      
      (replace-match "Bonjour"))
    (other-window 1))

;; (goto-char (point-min)) 将光标移到buffer的开始
;; (search-forward "Hello") 查找字符串"Hello"
;; (while x y) 当x返回某个值时执行y这个s式
;; 当x返回`nil' (空), 退出循环

(replace-hello-by-bonjour)

;; 你会看到所有在*test* buffer中出现的"Hello"字样都被换成了"Bonjour"
;; 你也会得到以下错误提示: "Search failed: Hello".
;; 如果要避免这个错误, 你需要告诉 `search-forward' 这个命令是否在
;; buffer的某个地方停止查找, 并且在什么都没找到时是否应该不给出错误提示
;; (search-forward "Hello" nil t) 可以达到这个要求:
;; `nil' 参数的意思是 : 查找并不限于某个范围内
;; `t' 参数的意思是: 当什么都没找到时,不给出错误提示
;; 在下面的函数中,我们用到了s式,并且不给出任何错误提示:

;; 给这些名字上个色:
(defun boldify-names ()
    (switch-to-buffer-other-window "*test*")
    (goto-char (point-min))
    (while (re-search-forward "Bonjour \\(.+\\)!" nil t)
      (add-text-properties (match-beginning 1)
                           (match-end 1)
                           (list 'face 'bold)))
    (other-window 1))

(boldify-names)

;; 这个函数使用了 `re-search-forward': 正则表达式查找
;; 和查找一个字符串不同,你用这个命令可以查找一个模式,即正则表达式
;; 正则表达式 "Bonjour \\(.+\\)!" 的意思是:
;; 字符串 "Bonjour ", 之后跟着
;; 一组           |  \\( ... \\) 结构
;; 任意字符       |  . 的含义
;; 有可能重复的   |  + 的含义
;; 之后跟着 "!" 这个字符串
;; `add-text-properties' 可以添加文字属性, 比如文字样式
;; 好的,我们成功了!
函数列表
(mapcar)
(goto-char)
(search-forward)
(re-search-forward)
(add-text-properties)
(match-beginning)
(match-end)

http://www.zhongyajixie.com/news/42818.html

相关文章:

  • 做服装广告素材网站有哪些seort什么意思
  • 在门户网站中seo站内优化站外优化
  • 外国人做外贸都会浏览哪些网站北京seo优化哪家好
  • 邮件服务器是不是网站服务器批量外链工具
  • 龙岗专业网站建设正规电商平台有哪些
  • 工作总结ppt模板免费下载 素材廊坊推广seo霸屏
  • 免费电商网站建设平台佛山网站建设工作
  • wordpress 小工具样式南京seo培训
  • 网站第二次备案成都关键词排名系统
  • 短视频带货免费平台怎么给网站做优化
  • 成都网站建设专业乐云seo网络的推广
  • 可信网站注册外贸seo公司
  • 移动互联网的长期趋势是网站改版seo建议
  • 中央新一届领导任命公告公示东莞搜索优化十年乐云seo
  • 做网站需要执照嘛网上销售有哪些方法
  • 用mvc做网站报告seo赚钱吗
  • 网站建设 营销搜索引擎优化seo怎么做
  • 潍坊网站建设最新报价网站优化检测
  • 专门做校招的网站网站建设一般多少钱
  • html5支持最好的浏览器吉林关键词优化的方法
  • 怎么做网站优化推广注册网站流程和费用
  • wordpress base做网站优化哪家公司好
  • 服务型网站建设百度推广平台登陆
  • 公司法人变更怎么办理小辉seo
  • 可靠的机票网站建设爱站工具包下载
  • 广告设计网站哪个好今日国家新闻
  • 免费建站并且绑定域名泉州百度关键词优化
  • 聊城开发区建设局网站福州百度seo代理
  • 自己开网站能赚钱吗营销战略
  • 有免费的网站域名吗北京本地网络推广平台