 ;; Use use-package to create portable emacs-config
 ;; bootstrap emacs setup from package managers
+(setq package-enable-at-startup nil)
 (require 'package)
-(setq package-enable-at-startup nil)
-(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
-(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
-(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
+;;(setq package-archives (cons ("gnu" . "http://elpa.gnu.org/packages/")))
+(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
+                    (not (gnutls-available-p))))
+       (proto (if no-ssl "http" "https")))
+  (when no-ssl
+    (warn "\
+Your version of Emacs does not support SSL connections,
+which is unsafe because it allows man-in-the-middle attacks.
+There are two things you can do about this warning:
+1. Install an Emacs version that does support SSL and be safe.
+2. Remove this warning from your init file so you won't see it again."))
+  ;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
+  (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
+  (add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
+  (when (< emacs-major-version 24)
+    ;; For important compatibility libraries like cl-lib
+    (add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))
 (package-initialize)
+
 (when (not package-archive-contents)
   (package-refresh-contents))
 


;; misc variables
(setq f90-smart-end-names nil)
(when window-system
  (set-frame-position (selected-frame) 0 0)
  (set-frame-size (selected-frame) 192 71))
;; see also default-frame-alist and initial-frame-alist
(setq redisplay-dont-pause t) ; better performance, maybe...
(setq transient-mark-mode t)
(setq tab-width 4)          ; and 4 char wide for TAB
(setq indent-tabs-mode nil) ; And force use of spaces
(turn-on-font-lock)         ; same as syntax on in Vim
(setq inhibit-startup-screen t)
(setq vc-follow-symlinks t)


;; Recent file menu/opening from mastering emacs
(require 'recentf)
;; enable recent files mode.
(recentf-mode t)
;; get rid of `find-file-read-only' and replace it with something
;; more useful.

(setq hippie-expand-try-functions-list
      '(try-expand-dabbrev-visible try-expand-dabbrev try-expand-all-abbrevs try-expand-dabbrev-from-kill try-expand-dabbrev-all-buffers try-complete-file-name-partially try-complete-file-name try-expand-list try-expand-line))

