Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Made hyde-home buffer local to handle multiple blogs and fixed new bugs

  • Loading branch information...
commit 181f9d2f91c2678a22243c5485162fa7999fd893 1 parent a2eacd6
Noufal Ibrahim authored

Showing 2 changed files with 19 additions and 19 deletions. Show diff stats Hide diff stats

  1. 1  hyde-git.el
  2. 37  hyde.el
1  hyde-git.el
@@ -60,6 +60,7 @@
60 60
 (defun hyde/git/push (repo)
61 61
   "Pushes the repository"
62 62
   (let ((cmd (format "cd '%s' && git push %s %s > /dev/null" repo hyde/git/remote hyde/git/remote-branch)))
  63
+    (message cmd)
63 64
     (shell-command cmd)))
64 65
 
65 66
 (defun hyde/git/rename (base from to)
37  hyde.el
@@ -32,11 +32,6 @@
32 32
   :type 'hook
33 33
   :group 'hyde)
34 34
 
35  
-(defcustom hyde-home 
36  
-  "/home/noufal/blog"
37  
-  "Default blog directory"
38  
-  :type 'directory
39  
-  :group 'hyde)
40 35
 
41 36
 (defcustom hyde-deploy-dir
42 37
   "_site"
@@ -272,13 +267,17 @@ user"
272 267
 							  (format-time-string "%Y-%m-%d-")
273 268
 							  (downcase (replace-regexp-in-string " " "_" title))))))
274 269
 
275  
-    (find-file post-file-name)
276  
-    (insert "---\n")
277  
-    (insert "layout: post\n")
278  
-    (insert (format "title: \"%s\"\n" title))
279  
-    (insert "---\n\n")
280  
-    (save-buffer)
  270
+    (save-excursion
  271
+      (find-file post-file-name)
  272
+      (insert "---\n")
  273
+      (insert "layout: post\n")
  274
+      (insert (format "title: \"%s\"\n" title))
  275
+      (insert "---\n\n")
  276
+      (save-buffer))
281 277
     (hyde/hyde-add-file post-file-name)
  278
+    (find-file post-file-name)
  279
+
  280
+     ;; hyde-home not available in markdown buffer (FIXME)
282 281
     (hyde-markdown-mode)))
283 282
 
284 283
 (defun hyde/quit ()
@@ -336,7 +335,7 @@ user"
336 335
     (insert "Key:\n-----\n . Committed and pushed\n C Committed but not yet pushed\n M Local saved changes (uncommitted)\n E Local unsaved changes\n")
337 336
     (toggle-read-only 1))
338 337
 
339  
-(defun hyde/read-config ()
  338
+(defun hyde/read-config (hyde-home)
340 339
   "Loads up the config file to set the blog deployment and other information"
341 340
   (let (
342 341
 	(config-file (concat hyde-home "/.hyde.el"))
@@ -346,11 +345,10 @@ user"
346 345
     ))
347 346
   
348 347
 
349  
-(defun hyde/hyde-mode ()
  348
+(defun hyde/hyde-mode (home)
350 349
   "The Hyde major mode to edit Jekyll posts."
351 350
   (kill-all-local-variables)
352  
-  (dolist (x '(hyde-home
353  
-	       hyde-deploy-dir
  351
+  (dolist (x '(hyde-deploy-dir
354 352
 	       hyde-posts-dir
355 353
 	       hyde-drafts-dir
356 354
 	       hyde/hyde-list-posts-command
@@ -359,24 +357,25 @@ user"
359 357
 	       hyde/git/remote
360 358
 	       hyde/git/remote-branch))
361 359
     (make-variable-buffer-local x))
  360
+  (set (make-local-variable 'hyde-home) home)
362 361
   (use-local-map hyde-mode-map)
363 362
   (set (make-local-variable 'font-lock-defaults) '(hyde-font-lock-keywords))
364 363
   (setq major-mode 'hyde/hyde-mode
365 364
 	mode-name "Hyde")
366  
-  (hyde/read-config)
  365
+  (hyde/read-config hyde-home)
367 366
   (hyde/load-posts)
368 367
   (hl-line-mode t)
369 368
   (run-hooks hyde-mode-hook))
370 369
 
371 370
 
372 371
 ;; Entry point
373  
-(defun hyde (hyde-home)
  372
+(defun hyde (home)
374 373
   "Enters hyde mode"
375 374
   (interactive "DBlog : ")
376 375
   (let (
377  
-	(hyde-buffer (concat "*Hyde : " hyde-home "*"))
  376
+	(hyde-buffer (concat "*Hyde : " home "*"))
378 377
 	)
379 378
     (switch-to-buffer (get-buffer-create hyde-buffer)))
380  
-  (hyde/hyde-mode))
  379
+  (hyde/hyde-mode home))
381 380
 
382 381
 (provide 'hyde)

0 notes on commit 181f9d2

Please sign in to comment.
Something went wrong with that request. Please try again.